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)
}
};
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();
}
//~^ 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() {}
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
}
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
}
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
}
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
}
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
}