// Tests TyTrait
pub trait FooTrait {
fn foo_method(&self) -> usize;
- fn foo_static_method() -> usize;
}
// Tests TyStruct
// except according to those terms.
fn main() {
- &1 as Copy;
+ &1 as Send;
//~^ ERROR cast to unsized type
//~| HELP try casting to a reference instead:
- //~| SUGGESTION &1 as &Copy;
- Box::new(1) as Copy;
+ //~| SUGGESTION &1 as &Send;
+ Box::new(1) as Send;
//~^ ERROR cast to unsized type
//~| HELP try casting to a `Box` instead:
- //~| SUGGESTION Box::new(1) as Box<Copy>;
+ //~| SUGGESTION Box::new(1) as Box<Send>;
}
// so for now just live with it.
// This test case was originally for issue #2258.
-trait ToOpt {
+trait ToOpt: Sized {
fn to_option(&self) -> Option<Self>;
}
fn foo(b: &Bar) {
b.foo(&0)
//~^ ERROR the trait `Foo` is not implemented for the type `Bar`
+ //~| ERROR E0038
}
fn main() {
let mut thing = Thing;
- let test: &Bar = &mut thing; //~ ERROR cannot convert to a trait object
+ let test: &Bar = &mut thing; //~ ERROR E0038
foo(test);
}
}
struct Bar {
+//~^ ERROR E0038
foos: &'static [&'static (Qiz + 'static)]
}
const FOO : Foo = Foo;
const BAR : Bar = Bar { foos: &[&FOO]};
-//~^ ERROR: cannot convert to a trait object because trait `Qiz` is not object-safe [E0038]
fn main() { }
fn main() {
let mut thing = Thing;
let test: &mut Bar = &mut thing;
- //~^ ERROR cannot convert to a trait object because trait `Bar` is not object-safe
+ //~^ ERROR E0038
+ //~| ERROR E0038
}
fn make_bar<T:Bar>(t: &T) -> &Bar {
t
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE method `bar` has generic type parameters
}
fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
t as &Bar
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE method `bar` has generic type parameters
+ //~| ERROR E0038
}
fn make_quux<T:Quux>(t: &T) -> &Quux {
//#[derive(PartialEq)]
#[derive(Debug)]
-struct SExpr<'x> {
+struct SExpr<'x> { //~ ERROR E0038
elements: Vec<Box<Expr+ 'x>>,
}
}
fn main() {
- let a: Box<Expr> = Box::new(SExpr::new()); //~ ERROR trait `Expr` is not object-safe
- let b: Box<Expr> = Box::new(SExpr::new()); //~ ERROR trait `Expr` is not object-safe
+ let a: Box<Expr> = Box::new(SExpr::new());
+ let b: Box<Expr> = Box::new(SExpr::new());
assert_eq!(a , b);
}
fn make_bar<T:Bar>(t: &T) -> &Bar {
t
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE method `bar` references the `Self` type in its arguments or return type
}
fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
t as &Bar
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE method `bar` references the `Self` type in its arguments or return type
+ //~| ERROR E0038
}
fn make_baz<T:Baz>(t: &T) -> &Baz {
t
- //~^ ERROR `Baz` is not object-safe
+ //~^ ERROR E0038
//~| NOTE method `bar` references the `Self` type in its arguments or return type
}
fn make_baz_explicit<T:Baz>(t: &T) -> &Baz {
t as &Baz
- //~^ ERROR `Baz` is not object-safe
+ //~^ ERROR E0038
//~| NOTE method `bar` references the `Self` type in its arguments or return type
+ //~| ERROR E0038
}
fn make_quux<T:Quux>(t: &T) -> &Quux {
fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> {
b
- //~^ ERROR cannot convert to a trait object
+ //~^ ERROR E0038
//~| NOTE method `foo` has no receiver
}
fn foo_explicit<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> {
b as Box<Foo>
- //~^ ERROR cannot convert to a trait object
+ //~^ ERROR E0038
//~| NOTE method `foo` has no receiver
+ //~| ERROR E0038
}
fn main() {
fn make_bar<T:Bar>(t: &T) -> &Bar {
t
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE the trait cannot require that `Self : Sized`
}
fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
t as &Bar
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE the trait cannot require that `Self : Sized`
+ //~| ERROR E0038
}
fn main() {
fn make_bar<T:Bar>(t: &T) -> &Bar {
t
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE the trait cannot require that `Self : Sized`
}
fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
t as &Bar
- //~^ ERROR `Bar` is not object-safe
+ //~^ ERROR E0038
//~| NOTE the trait cannot require that `Self : Sized`
+ //~| ERROR E0038
}
fn main() {
fn make_baz<T:Baz>(t: &T) -> &Baz {
t
- //~^ ERROR `Baz` is not object-safe
+ //~^ ERROR E0038
//~| NOTE the trait cannot use `Self` as a type parameter in the supertrait listing
}
// str
std::intrinsics::type_name::<str>(),
// Trait
- std::intrinsics::type_name::<Copy>(),
+ std::intrinsics::type_name::<Send>(),
// Newtype
std::intrinsics::type_name::<NT>(),
// DST
std::intrinsics::type_name::<DST>()
- )}, ("[u8]", "str", "core::marker::Copy + 'static", "NT", "DST"));
+ )}, ("[u8]", "str", "core::marker::Send + 'static", "NT", "DST"));
}