diff options
| author | bors <bors@rust-lang.org> | 2018-10-13 06:48:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-10-13 06:48:17 +0000 |
| commit | fb3b47aa424447e20a7dd372fa3e883a62e5abb3 (patch) | |
| tree | c8d8f366ab16db0b29376f9983ce9fb7db60a3cb | |
| parent | c47785f6beb7f2047b2915c42d1d3d4c0ab0abf0 (diff) | |
| parent | a5de379b55d993db1dafd8e5bbc216d01be83893 (diff) | |
| download | rust-fb3b47aa424447e20a7dd372fa3e883a62e5abb3.tar.gz rust-fb3b47aa424447e20a7dd372fa3e883a62e5abb3.zip | |
Auto merge of #54980 - zackmdavis:and_the_case_of_the_universal_call, r=oli-obk
structured suggestion for E0223 ambiguous associated type (routine (and when are we going to be done finding these, anyway?) but something that stuck out to me while glancing at #54970) r? @estebank
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/did_you_mean/bad-assoc-ty.stderr | 28 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0223.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/impl_trait_projections.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-23073.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-34209.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/qualified/qualified-path-params-2.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/self/self-impl.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/structs/struct-path-associated-type.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/traits/trait-item-privacy.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/ufcs/ufcs-partially-resolved.stderr | 4 |
12 files changed, 31 insertions, 78 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index e4ad02595d1..32889ef8698 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -30,7 +30,7 @@ use std::slice; use require_c_abi_if_variadic; use util::common::ErrorReported; use util::nodemap::FxHashMap; -use errors::{FatalError, DiagnosticId}; +use errors::{Applicability, FatalError, DiagnosticId}; use lint; use std::iter; @@ -1092,11 +1092,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { trait_str: &str, name: &str) { struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type") - .span_label(span, "ambiguous associated type") - .note(&format!("specify the type using the syntax `<{} as {}>::{}`", - type_str, trait_str, name)) - .emit(); - + .span_suggestion_with_applicability( + span, + "use fully-qualified syntax", + format!("<{} as {}>::{}", type_str, trait_str, name), + Applicability::HasPlaceholders + ).emit(); } // Search for a bound on a type parameter which includes the associated item diff --git a/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr b/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr index c45873ffd53..755e83daf47 100644 --- a/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr +++ b/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr @@ -2,25 +2,19 @@ error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:16:36 | LL | fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {} - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<Type as Get>::Value` + | ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Get>::Value` error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:25:10 | LL | type X = std::ops::Deref::Target; - | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<Type as std::ops::Deref>::Target` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as std::ops::Deref>::Target` error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:21:23 | LL | fn grab(&self) -> Grab::Value; - | ^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<Type as Grab>::Value` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Grab>::Value` error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index 33792d4f5b3..5de9f5866ff 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -44,33 +44,25 @@ error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:11:10 | LL | type A = [u8; 4]::AssocTy; - | ^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<[u8; _] as Trait>::AssocTy` + | ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8; _] as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:15:10 | LL | type B = [u8]::AssocTy; - | ^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<[u8] as Trait>::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8] as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:19:10 | LL | type C = (u8)::AssocTy; - | ^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<u8 as Trait>::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:23:10 | LL | type D = (u8, u8)::AssocTy; - | ^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<(u8, u8) as Trait>::AssocTy` + | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(u8, u8) as Trait>::AssocTy` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/bad-assoc-ty.rs:27:10 @@ -82,25 +74,19 @@ error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:31:19 | LL | type F = &'static (u8)::AssocTy; - | ^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<u8 as Trait>::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<u8 as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:37:10 | LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:43:10 | LL | type H = Fn(u8) -> (u8)::Output; - | ^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output` + | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output` error: aborting due to 15 previous errors diff --git a/src/test/ui/error-codes/E0223.stderr b/src/test/ui/error-codes/E0223.stderr index f65e744c625..87736c10774 100644 --- a/src/test/ui/error-codes/E0223.stderr +++ b/src/test/ui/error-codes/E0223.stderr @@ -2,9 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/E0223.rs:14:14 | LL | let foo: MyTrait::X; - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<Type as MyTrait>::X` + | ^^^^^^^^^^ help: use fully-qualified syntax: `<Type as MyTrait>::X` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/impl_trait_projections.stderr b/src/test/ui/impl-trait/impl_trait_projections.stderr index f6d58984ece..a6daf898e30 100644 --- a/src/test/ui/impl-trait/impl_trait_projections.stderr +++ b/src/test/ui/impl-trait/impl_trait_projections.stderr @@ -26,9 +26,7 @@ error[E0223]: ambiguous associated type --> $DIR/impl_trait_projections.rs:21:50 | LL | fn projection_is_disallowed(x: impl Iterator) -> <impl Iterator>::Item { - | ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<impl std::iter::Iterator as Trait>::Item` + | ^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<impl std::iter::Iterator as Trait>::Item` error: aborting due to 5 previous errors diff --git a/src/test/ui/issues/issue-23073.stderr b/src/test/ui/issues/issue-23073.stderr index 44b2128af0a..ef2430561ec 100644 --- a/src/test/ui/issues/issue-23073.stderr +++ b/src/test/ui/issues/issue-23073.stderr @@ -2,9 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/issue-23073.rs:16:17 | LL | type FooT = <<Self as Bar>::Foo>::T; //~ ERROR ambiguous associated type - | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<<Self as Bar>::Foo as Trait>::T` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<Self as Bar>::Foo as Trait>::T` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-34209.stderr b/src/test/ui/issues/issue-34209.stderr index 5c31acea5b6..0dfdd8b5886 100644 --- a/src/test/ui/issues/issue-34209.stderr +++ b/src/test/ui/issues/issue-34209.stderr @@ -2,9 +2,7 @@ error[E0223]: ambiguous associated type --> $DIR/issue-34209.rs:17:9 | LL | S::B{ } => { }, - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::B` + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::B` error: aborting due to previous error diff --git a/src/test/ui/qualified/qualified-path-params-2.stderr b/src/test/ui/qualified/qualified-path-params-2.stderr index 8b618cbf7ba..70aac779103 100644 --- a/src/test/ui/qualified/qualified-path-params-2.stderr +++ b/src/test/ui/qualified/qualified-path-params-2.stderr @@ -8,9 +8,7 @@ error[E0223]: ambiguous associated type --> $DIR/qualified-path-params-2.rs:28:10 | LL | type A = <S as Tr>::A::f<u8>; - | ^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<<S as Tr>::A as Trait>::f` + | ^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<S as Tr>::A as Trait>::f` error: aborting due to 2 previous errors diff --git a/src/test/ui/self/self-impl.stderr b/src/test/ui/self/self-impl.stderr index a5a5135faad..b951b119436 100644 --- a/src/test/ui/self/self-impl.stderr +++ b/src/test/ui/self/self-impl.stderr @@ -2,17 +2,13 @@ error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:33:16 | LL | let _: <Self>::Baz = true; - | ^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<Bar as Trait>::Baz` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Trait>::Baz` error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:35:16 | LL | let _: Self::Baz = true; - | ^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<Bar as Trait>::Baz` + | ^^^^^^^^^ help: use fully-qualified syntax: `<Bar as Trait>::Baz` error: aborting due to 2 previous errors diff --git a/src/test/ui/structs/struct-path-associated-type.stderr b/src/test/ui/structs/struct-path-associated-type.stderr index 1364b2a6b0c..873e7bb7b83 100644 --- a/src/test/ui/structs/struct-path-associated-type.stderr +++ b/src/test/ui/structs/struct-path-associated-type.stderr @@ -32,9 +32,7 @@ error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:42:13 | LL | let s = S::A {}; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::A` + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::A` error[E0109]: type parameters are not allowed on this type --> $DIR/struct-path-associated-type.rs:43:20 @@ -46,17 +44,13 @@ error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:43:13 | LL | let z = S::A::<u8> {}; //~ ERROR ambiguous associated type - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::A` + | ^^^^^^^^^^ help: use fully-qualified syntax: `<S as Trait>::A` error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:46:9 | LL | S::A {} => {} //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::A` + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::A` error: aborting due to 9 previous errors diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr index a3747bcee5d..fc14ae91d7b 100644 --- a/src/test/ui/traits/trait-item-privacy.stderr +++ b/src/test/ui/traits/trait-item-privacy.stderr @@ -138,25 +138,19 @@ error[E0223]: ambiguous associated type --> $DIR/trait-item-privacy.rs:127:12 | LL | let _: S::A; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::A` + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::A` error[E0223]: ambiguous associated type --> $DIR/trait-item-privacy.rs:128:12 | LL | let _: S::B; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::B` + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::B` error[E0223]: ambiguous associated type --> $DIR/trait-item-privacy.rs:129:12 | LL | let _: S::C; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<S as Trait>::C` + | ^^^^ help: use fully-qualified syntax: `<S as Trait>::C` error: associated type `A` is private --> $DIR/trait-item-privacy.rs:131:12 diff --git a/src/test/ui/ufcs/ufcs-partially-resolved.stderr b/src/test/ui/ufcs/ufcs-partially-resolved.stderr index 5de8fb158b7..77d887f1d68 100644 --- a/src/test/ui/ufcs/ufcs-partially-resolved.stderr +++ b/src/test/ui/ufcs/ufcs-partially-resolved.stderr @@ -184,9 +184,7 @@ error[E0223]: ambiguous associated type --> $DIR/ufcs-partially-resolved.rs:46:12 | LL | let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type - | ^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<<u8 as Tr>::Y as Trait>::NN` + | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<u8 as Tr>::Y as Trait>::NN` error[E0599]: no associated item named `NN` found for type `<u8 as Tr>::Y` in the current scope --> $DIR/ufcs-partially-resolved.rs:48:5 |
