diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 50ffa52e88b..2444259d406 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1215,10 +1215,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { type_str: &str, trait_str: &str, name: &str) { - span_err!(self.tcx().sess, span, E0223, - "ambiguous associated type; specify the type using the syntax \ - `<{} as {}>::{}`", - type_str, trait_str, name); + struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type") + .span_label(span, &format!("ambiguous associated type")) + .note(&format!("specify the type using the syntax `<{} as {}>::{}`", + type_str, trait_str, name)) + .emit(); + } // Search for a bound on a type parameter which includes the associated item diff --git a/src/test/compile-fail/E0223.rs b/src/test/compile-fail/E0223.rs index bbf7d762ef0..56057b37259 100644 --- a/src/test/compile-fail/E0223.rs +++ b/src/test/compile-fail/E0223.rs @@ -11,5 +11,8 @@ trait MyTrait { type X; } fn main() { - let foo: MyTrait::X; //~ ERROR E0223 + let foo: MyTrait::X; + //~^ ERROR ambiguous associated type + //~| NOTE ambiguous associated type + //~| NOTE specify the type using the syntax `::X` } diff --git a/src/test/compile-fail/associated-types-in-ambiguous-context.rs b/src/test/compile-fail/associated-types-in-ambiguous-context.rs index becbc27138b..ff886e63dc5 100644 --- a/src/test/compile-fail/associated-types-in-ambiguous-context.rs +++ b/src/test/compile-fail/associated-types-in-ambiguous-context.rs @@ -15,15 +15,21 @@ trait Get { fn get(x: T, y: U) -> Get::Value {} //~^ ERROR ambiguous associated type +//~| NOTE ambiguous associated type +//~| NOTE specify the type using the syntax `::Value` trait Grab { type Value; fn grab(&self) -> Grab::Value; //~^ ERROR ambiguous associated type + //~| NOTE ambiguous associated type + //~| NOTE specify the type using the syntax `::Value` } type X = std::ops::Deref::Target; //~^ ERROR ambiguous associated type +//~| NOTE ambiguous associated type +//~| NOTE specify the type using the syntax `::Target` fn main() { } diff --git a/src/test/compile-fail/issue-34209.rs b/src/test/compile-fail/issue-34209.rs index 6fae18dec10..5e3b777cc0b 100644 --- a/src/test/compile-fail/issue-34209.rs +++ b/src/test/compile-fail/issue-34209.rs @@ -15,7 +15,9 @@ enum S { fn bug(l: S) { match l { S::B{ } => { }, - //~^ ERROR ambiguous associated type; specify the type using the syntax `::B` + //~^ ERROR ambiguous associated type + //~| NOTE ambiguous associated type + //~| NOTE specify the type using the syntax `::B` } } diff --git a/src/test/compile-fail/qualified-path-params-2.rs b/src/test/compile-fail/qualified-path-params-2.rs index 5c661bfcdc0..e685ebc2720 100644 --- a/src/test/compile-fail/qualified-path-params-2.rs +++ b/src/test/compile-fail/qualified-path-params-2.rs @@ -25,7 +25,11 @@ impl S { fn f() {} } -type A = ::A::f; //~ ERROR type parameters are not allowed on this type -//~^ ERROR ambiguous associated type; specify the type using the syntax `<::A as Trait>::f` +type A = ::A::f; +//~^ ERROR type parameters are not allowed on this type +//~| NOTE type parameter not allowed +//~| ERROR ambiguous associated type +//~| NOTE ambiguous associated type +//~| NOTE specify the type using the syntax `<::A as Trait>::f` fn main() {} diff --git a/src/test/compile-fail/self-impl.rs b/src/test/compile-fail/self-impl.rs index d058c6a5a3b..860e69fcaec 100644 --- a/src/test/compile-fail/self-impl.rs +++ b/src/test/compile-fail/self-impl.rs @@ -31,9 +31,13 @@ impl SuperFoo for Bar { impl Bar { fn f() { let _: ::Baz = true; -//~^ERROR: ambiguous associated type; specify the type using the syntax `::Baz` + //~^ ERROR ambiguous associated type + //~| NOTE ambiguous associated type + //~| NOTE specify the type using the syntax `::Baz` let _: Self::Baz = true; -//~^ERROR: ambiguous associated type; specify the type using the syntax `::Baz` + //~^ ERROR ambiguous associated type + //~| NOTE ambiguous associated type + //~| NOTE specify the type using the syntax `::Baz` } }