Skip to content

Update E0038 to the new error format #35537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
let mut err = match warning_node_id {
Some(_) => None,
None => {
Some(struct_span_err!(
self.sess, span, E0038,
"the trait `{}` cannot be made into an object",
self.item_path_str(trait_def_id)))
let trait_str = self.item_path_str(trait_def_id);
let mut db = struct_span_err!(
self.sess, span, E0038,
"the trait `{}` cannot be made into an object",
trait_str);
db.span_label(span,
&format!("the trait `{}` cannot be made \
into an object", trait_str));
Some(db)
}
};

Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0038.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ trait Trait {
fn foo(&self) -> Self;
}

fn call_foo(x: Box<Trait>) { //~ ERROR E0038
fn call_foo(x: Box<Trait>) {
//~^ ERROR E0038
//~| NOTE the trait `Trait` cannot be made into an object
//~| NOTE method `foo` references the `Self` type in its arguments or return type
let y = x.foo();
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-20692.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ fn f<T: Array>(x: &T) {
//~^ ERROR `Array` cannot be made into an object
//~| NOTE the trait cannot require that `Self : Sized`
//~| NOTE requirements on the impl of `std::ops::CoerceUnsized<&Array>`
//~| NOTE the trait `Array` cannot be made into an object
as
&Array;
//~^ ERROR `Array` cannot be made into an object
//~| NOTE the trait cannot require that `Self : Sized`
//~| NOTE the trait `Array` cannot be made into an object
}

fn main() {}
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-26056.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl<K> Map for K {
fn main() {
let _ = &()
as &Map<Key=u32,MapValue=u32>;
//~^ ERROR the trait `Map` cannot be made into an object
//~^ ERROR E0038
//~| NOTE the trait cannot use `Self` as a type parameter
//~| NOTE the trait `Map` cannot be made into an object
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/object-safety-generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ trait Quux {
fn make_bar<T:Bar>(t: &T) -> &Bar {
//~^ ERROR E0038
//~| NOTE method `bar` has generic type parameters
//~| NOTE the trait `Bar` cannot be made into an object
t
}

fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
//~^ ERROR E0038
//~^^ NOTE method `bar` has generic type parameters
//~| NOTE method `bar` has generic type parameters
//~| NOTE the trait `Bar` cannot be made into an object
t as &Bar
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/object-safety-mentions-Self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ trait Quux {
fn make_bar<T:Bar>(t: &T) -> &Bar {
//~^ ERROR E0038
//~| NOTE method `bar` references the `Self` type in its arguments or return type
//~| NOTE the trait `Bar` cannot be made into an object
loop { }
}

fn make_baz<T:Baz>(t: &T) -> &Baz {
//~^ ERROR E0038
//~| NOTE method `bar` references the `Self` type in its arguments or return type
//~| NOTE the trait `Baz` cannot be made into an object
t
}

Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/object-safety-sized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ trait Bar : Sized {
fn make_bar<T:Bar>(t: &T) -> &Bar {
//~^ ERROR E0038
//~| NOTE the trait cannot require that `Self : Sized`
//~| NOTE the trait `Bar` cannot be made into an object
t
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
fn make_baz<T:Baz>(t: &T) -> &Baz {
//~^ ERROR E0038
//~| NOTE the trait cannot use `Self` as a type parameter in the supertrait listing
//~| NOTE the trait `Baz` cannot be made into an object
t
}

Expand Down