Skip to content

Commit

Permalink
Update E0393 to new error format
Browse files Browse the repository at this point in the history
  • Loading branch information
swr1bm86 committed Aug 31, 2016
1 parent 86dde9b commit 189dee6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
// defaults. This will lead to an ICE if we are not
// careful!
if default_needs_object_self(def) {
span_err!(tcx.sess, span, E0393,
"the type parameter `{}` must be explicitly specified \
in an object type because its default value `{}` references \
the type `Self`",
def.name,
default);
struct_span_err!(tcx.sess, span, E0393,
"the type parameter `{}` must be explicitly specified",
def.name)
.span_label(span, &format!("missing reference to `{}`", def.name))
.note(&format!("because of the default `Self` reference, \
type parameters must be specified on object types"))
.emit();
tcx.types.err
} else {
// This is a default type parameter.
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0393.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

trait A<T=Self> {}

fn together_we_will_rule_the_galaxy(son: &A) {} //~ ERROR E0393
fn together_we_will_rule_the_galaxy(son: &A) {}
//~^ ERROR E0393
//~| NOTE missing reference to `T`
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types

fn main() {
}
7 changes: 5 additions & 2 deletions src/test/compile-fail/issue-21950.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ use std::ops::Add;
fn main() {
let x = &10 as
&Add;
//~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self`
//~| ERROR the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified
//~^ ERROR E0393
//~| NOTE missing reference to `RHS`
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
//~| ERROR E0191
//~| NOTE missing associated type `Output` value
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/issue-22370.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
trait A<T=Self> {}

fn f(a: &A) {}
//~^ ERROR the type parameter `T` must be explicitly specified in an object type because its default value `Self` references the type `Self`
//~^ ERROR E0393
//~| NOTE missing reference to `T`
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types

fn main() {}
10 changes: 7 additions & 3 deletions src/test/compile-fail/issue-22560.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
use std::ops::{Add, Sub};

type Test = Add +
//~^ ERROR the type parameter `RHS` must be explicitly specified in an object type because its default value `Self` references the type `Self`
//~^^ ERROR the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified [E0191]
//~^ ERROR E0393
//~| NOTE missing reference to `RHS`
//~| NOTE because of the default `Self` reference, type parameters must be specified on object types
//~| ERROR E0191
//~| NOTE missing associated type `Output` value
Sub;
//~^ ERROR only the builtin traits can be used as closure or object bounds
//~^ ERROR E0225
//~| NOTE non-builtin trait used as bounds

fn main() { }

0 comments on commit 189dee6

Please sign in to comment.