Skip to content

Commit a491100

Browse files
authored
Rollup merge of #68014 - estebank:unify-e0599, r=cramertj
Unify output of "variant not found" errors Fix #49566.
2 parents 793b1be + 2c5766f commit a491100

File tree

156 files changed

+260
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+260
-254
lines changed

src/librustc_typeck/astconv.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,9 +2125,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21252125
let msg = format!("expected type, found variant `{}`", assoc_ident);
21262126
tcx.sess.span_err(span, &msg);
21272127
} else if qself_ty.is_enum() {
2128-
let mut err = tcx.sess.struct_span_err(
2128+
let mut err = struct_span_err!(
2129+
tcx.sess,
21292130
assoc_ident.span,
2130-
&format!("no variant `{}` in enum `{}`", assoc_ident, qself_ty),
2131+
E0599,
2132+
"no variant named `{}` found for enum `{}`",
2133+
assoc_ident,
2134+
qself_ty,
21312135
);
21322136

21332137
let adt_def = qself_ty.ty_adt_def().expect("enum is not an ADT");

src/librustc_typeck/check/method/suggest.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
360360
tcx.sess,
361361
span,
362362
E0599,
363-
"no {} named `{}` found for type `{}` in the current scope",
363+
"no {} named `{}` found for {} `{}` in the current scope",
364364
item_kind,
365365
item_name,
366-
ty_str
366+
actual.prefix_string(),
367+
ty_str,
367368
);
368369
if let Some(span) =
369370
tcx.sess.confused_type_with_std_module.borrow().get(&span)

src/test/ui/associated-const/associated-const-no-item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ trait Foo {
33
}
44

55
const X: i32 = <i32>::ID;
6-
//~^ ERROR no associated item named `ID` found for type `i32`
6+
//~^ ERROR no associated item named `ID` found
77

88
fn main() {
99
assert_eq!(1, X);

src/test/ui/associated-item/associated-item-enum.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no variant or associated item named `mispellable` found for type `Enum` in the current scope
1+
error[E0599]: no variant or associated item named `mispellable` found for enum `Enum` in the current scope
22
--> $DIR/associated-item-enum.rs:17:11
33
|
44
LL | enum Enum { Variant }
@@ -10,7 +10,7 @@ LL | Enum::mispellable();
1010
| variant or associated item not found in `Enum`
1111
| help: there is a method with a similar name: `misspellable`
1212

13-
error[E0599]: no variant or associated item named `mispellable_trait` found for type `Enum` in the current scope
13+
error[E0599]: no variant or associated item named `mispellable_trait` found for enum `Enum` in the current scope
1414
--> $DIR/associated-item-enum.rs:18:11
1515
|
1616
LL | enum Enum { Variant }
@@ -19,7 +19,7 @@ LL | enum Enum { Variant }
1919
LL | Enum::mispellable_trait();
2020
| ^^^^^^^^^^^^^^^^^ variant or associated item not found in `Enum`
2121

22-
error[E0599]: no variant or associated item named `MISPELLABLE` found for type `Enum` in the current scope
22+
error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `Enum` in the current scope
2323
--> $DIR/associated-item-enum.rs:19:11
2424
|
2525
LL | enum Enum { Variant }

src/test/ui/auto-ref-slice-plus-ref.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `test_mut` found for type `std::vec::Vec<{integer}>` in the current scope
1+
error[E0599]: no method named `test_mut` found for struct `std::vec::Vec<{integer}>` in the current scope
22
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
33
|
44
LL | a.test_mut();
@@ -8,7 +8,7 @@ LL | a.test_mut();
88
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
99
candidate #1: `MyIter`
1010

11-
error[E0599]: no method named `test` found for type `std::vec::Vec<{integer}>` in the current scope
11+
error[E0599]: no method named `test` found for struct `std::vec::Vec<{integer}>` in the current scope
1212
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
1313
|
1414
LL | a.test();
@@ -18,7 +18,7 @@ LL | a.test();
1818
= note: the following trait defines an item `test`, perhaps you need to implement it:
1919
candidate #1: `MyIter`
2020

21-
error[E0599]: no method named `test` found for type `[{integer}; 1]` in the current scope
21+
error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
2222
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
2323
|
2424
LL | ([1]).test();
@@ -28,7 +28,7 @@ LL | ([1]).test();
2828
= note: the following trait defines an item `test`, perhaps you need to implement it:
2929
candidate #1: `MyIter`
3030

31-
error[E0599]: no method named `test` found for type `&[{integer}; 1]` in the current scope
31+
error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
3232
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
3333
|
3434
LL | (&[1]).test();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
trait A {
22
fn a(&self) {
33
|| self.b()
4-
//~^ ERROR no method named `b` found for type `&Self` in the current scope
4+
//~^ ERROR no method named `b` found
55
}
66
}
77
fn main() {}

src/test/ui/block-result/issue-3563.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `b` found for type `&Self` in the current scope
1+
error[E0599]: no method named `b` found for reference `&Self` in the current scope
22
--> $DIR/issue-3563.rs:3:17
33
|
44
LL | || self.b()

src/test/ui/bogus-tag.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no variant or associated item named `Hsl` found for type `Color` in the current scope
1+
error[E0599]: no variant or associated item named `Hsl` found for enum `Color` in the current scope
22
--> $DIR/bogus-tag.rs:7:16
33
|
44
LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), }

src/test/ui/class-cast-to-trait.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `eat` found for type `std::boxed::Box<dyn Noisy>` in the current scope
1+
error[E0599]: no method named `eat` found for struct `std::boxed::Box<dyn Noisy>` in the current scope
22
--> $DIR/class-cast-to-trait.rs:53:8
33
|
44
LL | nyan.eat();

src/test/ui/coherence/coherence_inherent.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope
1+
error[E0599]: no method named `the_fn` found for reference `&Lib::TheStruct` in the current scope
22
--> $DIR/coherence_inherent.rs:31:11
33
|
44
LL | s.the_fn();

0 commit comments

Comments
 (0)