Skip to content

Commit

Permalink
Rollup merge of rust-lang#35411 - KiChjang:e0223-new-format, r=jonath…
Browse files Browse the repository at this point in the history
…andturner

Update E0223 to the new format

Part of rust-lang#35233.
Fixes rust-lang#35387.

r? @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 7, 2016
2 parents b5261aa + 065c685 commit f40b2ff
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0223.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<Type as MyTrait>::X`
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ trait Get {

fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<Type as Get>::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 `<Type as Grab>::Value`
}

type X = std::ops::Deref::Target;
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<Type as std::ops::Deref>::Target`

fn main() {
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-34209.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ enum S {
fn bug(l: S) {
match l {
S::B{ } => { },
//~^ ERROR ambiguous associated type; specify the type using the syntax `<S as Trait>::B`
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<S as Trait>::B`
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/test/compile-fail/qualified-path-params-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ impl S {
fn f<T>() {}
}

type A = <S as Tr>::A::f<u8>; //~ ERROR type parameters are not allowed on this type
//~^ ERROR ambiguous associated type; specify the type using the syntax `<<S as Tr>::A as Trait>::f`
type A = <S as Tr>::A::f<u8>;
//~^ 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 `<<S as Tr>::A as Trait>::f`

fn main() {}
8 changes: 6 additions & 2 deletions src/test/compile-fail/self-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ impl SuperFoo for Bar {
impl Bar {
fn f() {
let _: <Self>::Baz = true;
//~^ERROR: ambiguous associated type; specify the type using the syntax `<Bar as Trait>::Baz`
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<Bar as Trait>::Baz`
let _: Self::Baz = true;
//~^ERROR: ambiguous associated type; specify the type using the syntax `<Bar as Trait>::Baz`
//~^ ERROR ambiguous associated type
//~| NOTE ambiguous associated type
//~| NOTE specify the type using the syntax `<Bar as Trait>::Baz`
}
}

Expand Down

0 comments on commit f40b2ff

Please sign in to comment.