diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index e4ad02595d107..32889ef869833 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 c45873ffd5308..755e83daf4784 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(x: T, y: U) -> Get::Value {} - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Value` + | ^^^^^^^^^^ help: use fully-qualified syntax: `::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 `::Target` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::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 `::Value` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `::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 33792d4f5b3fa..5de9f5866ff83 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 `::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::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 `::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::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 f65e744c62594..87736c10774ff 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 `::X` + | ^^^^^^^^^^ help: use fully-qualified syntax: `::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 f6d58984ecef7..a6daf898e30b5 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) -> ::Item { - | ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Item` + | ^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::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 44b2128af0aa1..ef2430561ec11 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 = <::Foo>::T; //~ ERROR ambiguous associated type - | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<::Foo as Trait>::T` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<::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 5c31acea5b600..0dfdd8b588634 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 `::B` + | ^^^^ help: use fully-qualified syntax: `::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 8b618cbf7ba9e..70aac7791035b 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 = ::A::f; - | ^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<::A as Trait>::f` + | ^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<::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 a5a5135faad72..b951b1194367f 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 _: ::Baz = true; - | ^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Baz` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `::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 `::Baz` + | ^^^^^^^^^ help: use fully-qualified syntax: `::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 1364b2a6b0c86..873e7bb7b835d 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 `::A` + | ^^^^ help: use fully-qualified syntax: `::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:: {}; //~ ERROR ambiguous associated type - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::A` + | ^^^^^^^^^^ help: use fully-qualified syntax: `::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 `::A` + | ^^^^ help: use fully-qualified syntax: `::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 a3747bcee5d5c..fc14ae91d7b36 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 `::A` + | ^^^^ help: use fully-qualified syntax: `::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 `::B` + | ^^^^ help: use fully-qualified syntax: `::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 `::C` + | ^^^^ help: use fully-qualified syntax: `::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 5de8fb158b770..77d887f1d68d8 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 _: ::Y::NN; //~ ERROR ambiguous associated type - | ^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<::Y as Trait>::NN` + | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<::Y as Trait>::NN` error[E0599]: no associated item named `NN` found for type `::Y` in the current scope --> $DIR/ufcs-partially-resolved.rs:48:5