Skip to content

Commit a491100

Browse files
authored
Rollup merge of rust-lang#68014 - estebank:unify-e0599, r=cramertj
Unify output of "variant not found" errors Fix rust-lang#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

+6-2
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

+3-2
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

+1-1
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

+3-3
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

+4-4
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();
+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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();

src/test/ui/coherence/coherence_inherent_cc.stderr

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

src/test/ui/confuse-field-and-method/issue-18343.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-18343.rs:6:28: 6:33]>` in the current scope
1+
error[E0599]: no method named `closure` found for struct `Obj<[closure@$DIR/issue-18343.rs:6:28: 6:33]>` in the current scope
22
--> $DIR/issue-18343.rs:7:7
33
|
44
LL | struct Obj<F> where F: FnMut() -> u32 {

src/test/ui/confuse-field-and-method/issue-2392.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
1+
error[E0599]: no method named `closure` found for struct `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
22
--> $DIR/issue-2392.rs:36:15
33
|
44
LL | struct Obj<F> where F: FnOnce() -> u32 {
@@ -12,7 +12,7 @@ help: to call the function stored in `closure`, surround the field access with p
1212
LL | (o_closure.closure)();
1313
| ^ ^
1414

15-
error[E0599]: no method named `not_closure` found for type `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
15+
error[E0599]: no method named `not_closure` found for struct `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
1616
--> $DIR/issue-2392.rs:38:15
1717
|
1818
LL | struct Obj<F> where F: FnOnce() -> u32 {
@@ -23,7 +23,7 @@ LL | o_closure.not_closure();
2323
| |
2424
| field, not a method
2525

26-
error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
26+
error[E0599]: no method named `closure` found for struct `Obj<fn() -> u32 {func}>` in the current scope
2727
--> $DIR/issue-2392.rs:42:12
2828
|
2929
LL | struct Obj<F> where F: FnOnce() -> u32 {
@@ -37,7 +37,7 @@ help: to call the function stored in `closure`, surround the field access with p
3737
LL | (o_func.closure)();
3838
| ^ ^
3939

40-
error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
40+
error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope
4141
--> $DIR/issue-2392.rs:45:14
4242
|
4343
LL | struct BoxedObj {
@@ -51,7 +51,7 @@ help: to call the function stored in `boxed_closure`, surround the field access
5151
LL | (boxed_fn.boxed_closure)();
5252
| ^ ^
5353

54-
error[E0599]: no method named `boxed_closure` found for type `BoxedObj` in the current scope
54+
error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope
5555
--> $DIR/issue-2392.rs:48:19
5656
|
5757
LL | struct BoxedObj {
@@ -65,7 +65,7 @@ help: to call the function stored in `boxed_closure`, surround the field access
6565
LL | (boxed_closure.boxed_closure)();
6666
| ^ ^
6767

68-
error[E0599]: no method named `closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
68+
error[E0599]: no method named `closure` found for struct `Obj<fn() -> u32 {func}>` in the current scope
6969
--> $DIR/issue-2392.rs:53:12
7070
|
7171
LL | struct Obj<F> where F: FnOnce() -> u32 {
@@ -79,7 +79,7 @@ help: to call the function stored in `closure`, surround the field access with p
7979
LL | (w.wrap.closure)();
8080
| ^ ^
8181

82-
error[E0599]: no method named `not_closure` found for type `Obj<fn() -> u32 {func}>` in the current scope
82+
error[E0599]: no method named `not_closure` found for struct `Obj<fn() -> u32 {func}>` in the current scope
8383
--> $DIR/issue-2392.rs:55:12
8484
|
8585
LL | struct Obj<F> where F: FnOnce() -> u32 {
@@ -90,7 +90,7 @@ LL | w.wrap.not_closure();
9090
| |
9191
| field, not a method
9292

93-
error[E0599]: no method named `closure` found for type `Obj<std::boxed::Box<(dyn std::ops::FnOnce() -> u32 + 'static)>>` in the current scope
93+
error[E0599]: no method named `closure` found for struct `Obj<std::boxed::Box<(dyn std::ops::FnOnce() -> u32 + 'static)>>` in the current scope
9494
--> $DIR/issue-2392.rs:58:24
9595
|
9696
LL | struct Obj<F> where F: FnOnce() -> u32 {
@@ -104,7 +104,7 @@ help: to call the function stored in `closure`, surround the field access with p
104104
LL | (check_expression().closure)();
105105
| ^ ^
106106

107-
error[E0599]: no method named `f1` found for type `FuncContainer` in the current scope
107+
error[E0599]: no method named `f1` found for struct `FuncContainer` in the current scope
108108
--> $DIR/issue-2392.rs:64:31
109109
|
110110
LL | struct FuncContainer {
@@ -118,7 +118,7 @@ help: to call the function stored in `f1`, surround the field access with parent
118118
LL | ((*self.container).f1)(1);
119119
| ^ ^
120120

121-
error[E0599]: no method named `f2` found for type `FuncContainer` in the current scope
121+
error[E0599]: no method named `f2` found for struct `FuncContainer` in the current scope
122122
--> $DIR/issue-2392.rs:65:31
123123
|
124124
LL | struct FuncContainer {
@@ -132,7 +132,7 @@ help: to call the function stored in `f2`, surround the field access with parent
132132
LL | ((*self.container).f2)(1);
133133
| ^ ^
134134

135-
error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope
135+
error[E0599]: no method named `f3` found for struct `FuncContainer` in the current scope
136136
--> $DIR/issue-2392.rs:66:31
137137
|
138138
LL | struct FuncContainer {

src/test/ui/confuse-field-and-method/issue-32128.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `example` found for type `Example` in the current scope
1+
error[E0599]: no method named `example` found for struct `Example` in the current scope
22
--> $DIR/issue-32128.rs:12:10
33
|
44
LL | struct Example {

src/test/ui/confuse-field-and-method/issue-33784.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `closure` found for type `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
1+
error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
22
--> $DIR/issue-33784.rs:27:7
33
|
44
LL | p.closure();
@@ -9,7 +9,7 @@ help: to call the function stored in `closure`, surround the field access with p
99
LL | (p.closure)();
1010
| ^ ^
1111

12-
error[E0599]: no method named `fn_ptr` found for type `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
12+
error[E0599]: no method named `fn_ptr` found for reference `&&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
1313
--> $DIR/issue-33784.rs:29:7
1414
|
1515
LL | q.fn_ptr();
@@ -20,7 +20,7 @@ help: to call the function stored in `fn_ptr`, surround the field access with pa
2020
LL | (q.fn_ptr)();
2121
| ^ ^
2222

23-
error[E0599]: no method named `c_fn_ptr` found for type `&D` in the current scope
23+
error[E0599]: no method named `c_fn_ptr` found for reference `&D` in the current scope
2424
--> $DIR/issue-33784.rs:32:7
2525
|
2626
LL | s.c_fn_ptr();

src/test/ui/confuse-field-and-method/private-field.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `dog_age` found for type `animal::Dog` in the current scope
1+
error[E0599]: no method named `dog_age` found for struct `animal::Dog` in the current scope
22
--> $DIR/private-field.rs:16:23
33
|
44
LL | pub struct Dog {

src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0107]: wrong number of const arguments: expected 0, found 1
44
LL | let _: u32 = 5i32.try_into::<32>().unwrap();
55
| ^^ unexpected const argument
66

7-
error[E0599]: no method named `f` found for type `S` in the current scope
7+
error[E0599]: no method named `f` found for struct `S` in the current scope
88
--> $DIR/invalid-const-arg-for-type-param.rs:7:7
99
|
1010
LL | struct S;

src/test/ui/consts/too_generic_eval_ice.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no associated item named `HOST_SIZE` found for type `Foo<A, B>` in the current scope
1+
error[E0599]: no associated item named `HOST_SIZE` found for struct `Foo<A, B>` in the current scope
22
--> $DIR/too_generic_eval_ice.rs:7:19
33
|
44
LL | pub struct Foo<A, B>(A, B);

src/test/ui/copy-a-resource.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `clone` found for type `Foo` in the current scope
1+
error[E0599]: no method named `clone` found for struct `Foo` in the current scope
22
--> $DIR/copy-a-resource.rs:18:16
33
|
44
LL | struct Foo {

src/test/ui/derives/derive-assoc-type-not-impl.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no method named `clone` found for type `Bar<NotClone>` in the current scope
1+
error[E0599]: no method named `clone` found for struct `Bar<NotClone>` in the current scope
22
--> $DIR/derive-assoc-type-not-impl.rs:18:30
33
|
44
LL | struct Bar<T: Foo> {

src/test/ui/did_you_mean/bad-assoc-pat.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ fn main() {
22
match 0u8 {
33
[u8]::AssocItem => {}
44
//~^ ERROR missing angle brackets in associated item path
5-
//~| ERROR no associated item named `AssocItem` found for type `[u8]` in the current scope
5+
//~| ERROR no associated item named `AssocItem` found
66
(u8, u8)::AssocItem => {}
77
//~^ ERROR missing angle brackets in associated item path
8-
//~| ERROR no associated item named `AssocItem` found for type `(u8, u8)` in the current sco
8+
//~| ERROR no associated item named `AssocItem` found
99
_::AssocItem => {}
1010
//~^ ERROR missing angle brackets in associated item path
11-
//~| ERROR no associated item named `AssocItem` found for type `_` in the current scope
11+
//~| ERROR no associated item named `AssocItem` found
1212
}
1313
match &0u8 {
1414
&(u8,)::AssocItem => {}
1515
//~^ ERROR missing angle brackets in associated item path
16-
//~| ERROR no associated item named `AssocItem` found for type `(u8,)` in the current scope
16+
//~| ERROR no associated item named `AssocItem` found
1717
}
1818
}
1919

2020
macro_rules! pat {
2121
($ty: ty) => ($ty::AssocItem)
2222
//~^ ERROR missing angle brackets in associated item path
23-
//~| ERROR no associated item named `AssocItem` found for type `u8` in the current scope
23+
//~| ERROR no associated item named `AssocItem` found
2424
}
2525
macro_rules! ty {
2626
() => (u8)
@@ -31,6 +31,6 @@ fn check_macros() {
3131
pat!(u8) => {}
3232
ty!()::AssocItem => {}
3333
//~^ ERROR missing angle brackets in associated item path
34-
//~| ERROR no associated item named `AssocItem` found for type `u8` in the current scope
34+
//~| ERROR no associated item named `AssocItem` found
3535
}
3636
}

src/test/ui/did_you_mean/bad-assoc-pat.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ LL | ($ty: ty) => ($ty::AssocItem)
3737
LL | pat!(u8) => {}
3838
| -------- in this macro invocation
3939

40-
error[E0599]: no associated item named `AssocItem` found for type `[u8]` in the current scope
40+
error[E0599]: no associated item named `AssocItem` found for slice `[u8]` in the current scope
4141
--> $DIR/bad-assoc-pat.rs:3:15
4242
|
4343
LL | [u8]::AssocItem => {}
4444
| ^^^^^^^^^ associated item not found in `[u8]`
4545

46-
error[E0599]: no associated item named `AssocItem` found for type `(u8, u8)` in the current scope
46+
error[E0599]: no associated item named `AssocItem` found for tuple `(u8, u8)` in the current scope
4747
--> $DIR/bad-assoc-pat.rs:6:19
4848
|
4949
LL | (u8, u8)::AssocItem => {}
@@ -55,7 +55,7 @@ error[E0599]: no associated item named `AssocItem` found for type `_` in the cur
5555
LL | _::AssocItem => {}
5656
| ^^^^^^^^^ associated item not found in `_`
5757

58-
error[E0599]: no associated item named `AssocItem` found for type `(u8,)` in the current scope
58+
error[E0599]: no associated item named `AssocItem` found for tuple `(u8,)` in the current scope
5959
--> $DIR/bad-assoc-pat.rs:14:17
6060
|
6161
LL | &(u8,)::AssocItem => {}

src/test/ui/did_you_mean/issue-40006.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ impl S {
3535
}
3636

3737
fn main() {
38-
S.hello_method(); //~ no method named `hello_method` found for type `S` in the current scope
38+
S.hello_method(); //~ no method named `hello_method` found
3939
}

src/test/ui/did_you_mean/issue-40006.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ error: missing `fn`, `type`, or `const` for associated-item declaration
5656
LL | pub hello_method(&self) {
5757
| ^ missing `fn`, `type`, or `const`
5858

59-
error[E0599]: no method named `hello_method` found for type `S` in the current scope
59+
error[E0599]: no method named `hello_method` found for struct `S` in the current scope
6060
--> $DIR/issue-40006.rs:38:7
6161
|
6262
LL | struct S;

src/test/ui/dont-suggest-private-trait-method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ struct T;
22

33
fn main() {
44
T::new();
5-
//~^ ERROR no function or associated item named `new` found for type `T` in the current scope
5+
//~^ ERROR no function or associated item named `new` found
66
}

src/test/ui/dont-suggest-private-trait-method.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0599]: no function or associated item named `new` found for type `T` in the current scope
1+
error[E0599]: no function or associated item named `new` found for struct `T` in the current scope
22
--> $DIR/dont-suggest-private-trait-method.rs:4:8
33
|
44
LL | struct T;

0 commit comments

Comments
 (0)