Skip to content

Commit

Permalink
Rollup merge of #68014 - estebank:unify-e0599, r=cramertj
Browse files Browse the repository at this point in the history
Unify output of "variant not found" errors

Fix #49566.
  • Loading branch information
JohnTitor authored Jan 10, 2020
2 parents 793b1be + 2c5766f commit a491100
Show file tree
Hide file tree
Showing 156 changed files with 260 additions and 254 deletions.
8 changes: 6 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2125,9 +2125,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let msg = format!("expected type, found variant `{}`", assoc_ident);
tcx.sess.span_err(span, &msg);
} else if qself_ty.is_enum() {
let mut err = tcx.sess.struct_span_err(
let mut err = struct_span_err!(
tcx.sess,
assoc_ident.span,
&format!("no variant `{}` in enum `{}`", assoc_ident, qself_ty),
E0599,
"no variant named `{}` found for enum `{}`",
assoc_ident,
qself_ty,
);

let adt_def = qself_ty.ty_adt_def().expect("enum is not an ADT");
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
tcx.sess,
span,
E0599,
"no {} named `{}` found for type `{}` in the current scope",
"no {} named `{}` found for {} `{}` in the current scope",
item_kind,
item_name,
ty_str
actual.prefix_string(),
ty_str,
);
if let Some(span) =
tcx.sess.confused_type_with_std_module.borrow().get(&span)
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/associated-const/associated-const-no-item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ trait Foo {
}

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

fn main() {
assert_eq!(1, X);
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/associated-item/associated-item-enum.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no variant or associated item named `mispellable` found for type `Enum` in the current scope
error[E0599]: no variant or associated item named `mispellable` found for enum `Enum` in the current scope
--> $DIR/associated-item-enum.rs:17:11
|
LL | enum Enum { Variant }
Expand All @@ -10,7 +10,7 @@ LL | Enum::mispellable();
| variant or associated item not found in `Enum`
| help: there is a method with a similar name: `misspellable`

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

error[E0599]: no variant or associated item named `MISPELLABLE` found for type `Enum` in the current scope
error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `Enum` in the current scope
--> $DIR/associated-item-enum.rs:19:11
|
LL | enum Enum { Variant }
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/auto-ref-slice-plus-ref.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `test_mut` found for type `std::vec::Vec<{integer}>` in the current scope
error[E0599]: no method named `test_mut` found for struct `std::vec::Vec<{integer}>` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
|
LL | a.test_mut();
Expand All @@ -8,7 +8,7 @@ LL | a.test_mut();
= note: the following trait defines an item `test_mut`, perhaps you need to implement it:
candidate #1: `MyIter`

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

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

error[E0599]: no method named `test` found for type `&[{integer}; 1]` in the current scope
error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
|
LL | (&[1]).test();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-3563.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
trait A {
fn a(&self) {
|| self.b()
//~^ ERROR no method named `b` found for type `&Self` in the current scope
//~^ ERROR no method named `b` found
}
}
fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-3563.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `b` found for type `&Self` in the current scope
error[E0599]: no method named `b` found for reference `&Self` in the current scope
--> $DIR/issue-3563.rs:3:17
|
LL | || self.b()
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/bogus-tag.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no variant or associated item named `Hsl` found for type `Color` in the current scope
error[E0599]: no variant or associated item named `Hsl` found for enum `Color` in the current scope
--> $DIR/bogus-tag.rs:7:16
|
LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/class-cast-to-trait.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `eat` found for type `std::boxed::Box<dyn Noisy>` in the current scope
error[E0599]: no method named `eat` found for struct `std::boxed::Box<dyn Noisy>` in the current scope
--> $DIR/class-cast-to-trait.rs:53:8
|
LL | nyan.eat();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope
error[E0599]: no method named `the_fn` found for reference `&Lib::TheStruct` in the current scope
--> $DIR/coherence_inherent.rs:31:11
|
LL | s.the_fn();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/coherence/coherence_inherent_cc.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope
error[E0599]: no method named `the_fn` found for reference `&coherence_inherent_cc_lib::TheStruct` in the current scope
--> $DIR/coherence_inherent_cc.rs:23:11
|
LL | s.the_fn();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/confuse-field-and-method/issue-18343.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-18343.rs:6:28: 6:33]>` in the current scope
error[E0599]: no method named `closure` found for struct `Obj<[closure@$DIR/issue-18343.rs:6:28: 6:33]>` in the current scope
--> $DIR/issue-18343.rs:7:7
|
LL | struct Obj<F> where F: FnMut() -> u32 {
Expand Down
22 changes: 11 additions & 11 deletions src/test/ui/confuse-field-and-method/issue-2392.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `closure` found for type `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
error[E0599]: no method named `closure` found for struct `Obj<[closure@$DIR/issue-2392.rs:35:36: 35:41]>` in the current scope
--> $DIR/issue-2392.rs:36:15
|
LL | struct Obj<F> where F: FnOnce() -> u32 {
Expand All @@ -12,7 +12,7 @@ help: to call the function stored in `closure`, surround the field access with p
LL | (o_closure.closure)();
| ^ ^

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

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

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

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

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

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

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

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

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

error[E0599]: no method named `f3` found for type `FuncContainer` in the current scope
error[E0599]: no method named `f3` found for struct `FuncContainer` in the current scope
--> $DIR/issue-2392.rs:66:31
|
LL | struct FuncContainer {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/confuse-field-and-method/issue-32128.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `example` found for type `Example` in the current scope
error[E0599]: no method named `example` found for struct `Example` in the current scope
--> $DIR/issue-32128.rs:12:10
|
LL | struct Example {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/confuse-field-and-method/issue-33784.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `closure` found for type `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
error[E0599]: no method named `closure` found for reference `&Obj<[closure@$DIR/issue-33784.rs:25:43: 25:48]>` in the current scope
--> $DIR/issue-33784.rs:27:7
|
LL | p.closure();
Expand All @@ -9,7 +9,7 @@ help: to call the function stored in `closure`, surround the field access with p
LL | (p.closure)();
| ^ ^

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

error[E0599]: no method named `c_fn_ptr` found for type `&D` in the current scope
error[E0599]: no method named `c_fn_ptr` found for reference `&D` in the current scope
--> $DIR/issue-33784.rs:32:7
|
LL | s.c_fn_ptr();
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/confuse-field-and-method/private-field.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `dog_age` found for type `animal::Dog` in the current scope
error[E0599]: no method named `dog_age` found for struct `animal::Dog` in the current scope
--> $DIR/private-field.rs:16:23
|
LL | pub struct Dog {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0107]: wrong number of const arguments: expected 0, found 1
LL | let _: u32 = 5i32.try_into::<32>().unwrap();
| ^^ unexpected const argument

error[E0599]: no method named `f` found for type `S` in the current scope
error[E0599]: no method named `f` found for struct `S` in the current scope
--> $DIR/invalid-const-arg-for-type-param.rs:7:7
|
LL | struct S;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/too_generic_eval_ice.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no associated item named `HOST_SIZE` found for type `Foo<A, B>` in the current scope
error[E0599]: no associated item named `HOST_SIZE` found for struct `Foo<A, B>` in the current scope
--> $DIR/too_generic_eval_ice.rs:7:19
|
LL | pub struct Foo<A, B>(A, B);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/copy-a-resource.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `clone` found for type `Foo` in the current scope
error[E0599]: no method named `clone` found for struct `Foo` in the current scope
--> $DIR/copy-a-resource.rs:18:16
|
LL | struct Foo {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/derives/derive-assoc-type-not-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no method named `clone` found for type `Bar<NotClone>` in the current scope
error[E0599]: no method named `clone` found for struct `Bar<NotClone>` in the current scope
--> $DIR/derive-assoc-type-not-impl.rs:18:30
|
LL | struct Bar<T: Foo> {
Expand Down
12 changes: 6 additions & 6 deletions src/test/ui/did_you_mean/bad-assoc-pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ fn main() {
match 0u8 {
[u8]::AssocItem => {}
//~^ ERROR missing angle brackets in associated item path
//~| ERROR no associated item named `AssocItem` found for type `[u8]` in the current scope
//~| ERROR no associated item named `AssocItem` found
(u8, u8)::AssocItem => {}
//~^ ERROR missing angle brackets in associated item path
//~| ERROR no associated item named `AssocItem` found for type `(u8, u8)` in the current sco
//~| ERROR no associated item named `AssocItem` found
_::AssocItem => {}
//~^ ERROR missing angle brackets in associated item path
//~| ERROR no associated item named `AssocItem` found for type `_` in the current scope
//~| ERROR no associated item named `AssocItem` found
}
match &0u8 {
&(u8,)::AssocItem => {}
//~^ ERROR missing angle brackets in associated item path
//~| ERROR no associated item named `AssocItem` found for type `(u8,)` in the current scope
//~| ERROR no associated item named `AssocItem` found
}
}

macro_rules! pat {
($ty: ty) => ($ty::AssocItem)
//~^ ERROR missing angle brackets in associated item path
//~| ERROR no associated item named `AssocItem` found for type `u8` in the current scope
//~| ERROR no associated item named `AssocItem` found
}
macro_rules! ty {
() => (u8)
Expand All @@ -31,6 +31,6 @@ fn check_macros() {
pat!(u8) => {}
ty!()::AssocItem => {}
//~^ ERROR missing angle brackets in associated item path
//~| ERROR no associated item named `AssocItem` found for type `u8` in the current scope
//~| ERROR no associated item named `AssocItem` found
}
}
6 changes: 3 additions & 3 deletions src/test/ui/did_you_mean/bad-assoc-pat.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ LL | ($ty: ty) => ($ty::AssocItem)
LL | pat!(u8) => {}
| -------- in this macro invocation

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

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

error[E0599]: no associated item named `AssocItem` found for type `(u8,)` in the current scope
error[E0599]: no associated item named `AssocItem` found for tuple `(u8,)` in the current scope
--> $DIR/bad-assoc-pat.rs:14:17
|
LL | &(u8,)::AssocItem => {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/did_you_mean/issue-40006.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ impl S {
}

fn main() {
S.hello_method(); //~ no method named `hello_method` found for type `S` in the current scope
S.hello_method(); //~ no method named `hello_method` found
}
2 changes: 1 addition & 1 deletion src/test/ui/did_you_mean/issue-40006.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ error: missing `fn`, `type`, or `const` for associated-item declaration
LL | pub hello_method(&self) {
| ^ missing `fn`, `type`, or `const`

error[E0599]: no method named `hello_method` found for type `S` in the current scope
error[E0599]: no method named `hello_method` found for struct `S` in the current scope
--> $DIR/issue-40006.rs:38:7
|
LL | struct S;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/dont-suggest-private-trait-method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ struct T;

fn main() {
T::new();
//~^ ERROR no function or associated item named `new` found for type `T` in the current scope
//~^ ERROR no function or associated item named `new` found
}
2 changes: 1 addition & 1 deletion src/test/ui/dont-suggest-private-trait-method.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0599]: no function or associated item named `new` found for type `T` in the current scope
error[E0599]: no function or associated item named `new` found for struct `T` in the current scope
--> $DIR/dont-suggest-private-trait-method.rs:4:8
|
LL | struct T;
Expand Down
Loading

0 comments on commit a491100

Please sign in to comment.