Skip to content

Commit 20ea8cb

Browse files
committed
Update E0038 to the new error format
1 parent b42a384 commit 20ea8cb

8 files changed

+24
-7
lines changed

src/librustc/traits/error_reporting.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
670670
let mut err = match warning_node_id {
671671
Some(_) => None,
672672
None => {
673-
Some(struct_span_err!(
674-
self.sess, span, E0038,
675-
"the trait `{}` cannot be made into an object",
676-
self.item_path_str(trait_def_id)))
673+
let trait_str = self.item_path_str(trait_def_id);
674+
let mut db = struct_span_err!(
675+
self.sess, span, E0038,
676+
"the trait `{}` cannot be made into an object",
677+
trait_str);
678+
db.span_label(span,
679+
&format!("the trait `{}` cannot be made \
680+
into an object", trait_str));
681+
Some(db)
677682
}
678683
};
679684

src/test/compile-fail/E0038.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ trait Trait {
1212
fn foo(&self) -> Self;
1313
}
1414

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

src/test/compile-fail/issue-20692.rs

+2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ fn f<T: Array>(x: &T) {
1515
//~^ ERROR `Array` cannot be made into an object
1616
//~| NOTE the trait cannot require that `Self : Sized`
1717
//~| NOTE requirements on the impl of `std::ops::CoerceUnsized<&Array>`
18+
//~| NOTE the trait `Array` cannot be made into an object
1819
as
1920
&Array;
2021
//~^ ERROR `Array` cannot be made into an object
2122
//~| NOTE the trait cannot require that `Self : Sized`
23+
//~| NOTE the trait `Array` cannot be made into an object
2224
}
2325

2426
fn main() {}

src/test/compile-fail/issue-26056.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl<K> Map for K {
2828
fn main() {
2929
let _ = &()
3030
as &Map<Key=u32,MapValue=u32>;
31-
//~^ ERROR the trait `Map` cannot be made into an object
31+
//~^ ERROR E0038
3232
//~| NOTE the trait cannot use `Self` as a type parameter
33+
//~| NOTE the trait `Map` cannot be made into an object
3334
}

src/test/compile-fail/object-safety-generics.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ trait Quux {
2424
fn make_bar<T:Bar>(t: &T) -> &Bar {
2525
//~^ ERROR E0038
2626
//~| NOTE method `bar` has generic type parameters
27+
//~| NOTE the trait `Bar` cannot be made into an object
2728
t
2829
}
2930

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

src/test/compile-fail/object-safety-mentions-Self.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ trait Quux {
2727
fn make_bar<T:Bar>(t: &T) -> &Bar {
2828
//~^ ERROR E0038
2929
//~| NOTE method `bar` references the `Self` type in its arguments or return type
30+
//~| NOTE the trait `Bar` cannot be made into an object
3031
loop { }
3132
}
3233

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

src/test/compile-fail/object-safety-sized.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ trait Bar : Sized {
1818
fn make_bar<T:Bar>(t: &T) -> &Bar {
1919
//~^ ERROR E0038
2020
//~| NOTE the trait cannot require that `Self : Sized`
21+
//~| NOTE the trait `Bar` cannot be made into an object
2122
t
2223
}
2324

src/test/compile-fail/object-safety-supertrait-mentions-Self.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
2525
fn make_baz<T:Baz>(t: &T) -> &Baz {
2626
//~^ ERROR E0038
2727
//~| NOTE the trait cannot use `Self` as a type parameter in the supertrait listing
28+
//~| NOTE the trait `Baz` cannot be made into an object
2829
t
2930
}
3031

0 commit comments

Comments
 (0)