]> git.lizzy.rs Git - rust.git/commitdiff
Fallout in tests -- we now report an error if you even reference a type
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 7 Aug 2015 14:58:00 +0000 (10:58 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 12 Aug 2015 21:58:56 +0000 (17:58 -0400)
`&Foo` where `Foo` is a trait that is not object-safe

14 files changed:
src/test/auxiliary/issue13507.rs
src/test/compile-fail/cast-to-unsized-trait-object-suggestion.rs
src/test/compile-fail/infinite-instantiation.rs
src/test/compile-fail/issue-18959.rs
src/test/compile-fail/issue-19380.rs
src/test/compile-fail/issue-19538.rs
src/test/compile-fail/object-safety-generics.rs
src/test/compile-fail/object-safety-issue-22040.rs
src/test/compile-fail/object-safety-mentions-Self.rs
src/test/compile-fail/object-safety-no-static.rs
src/test/compile-fail/object-safety-sized-2.rs
src/test/compile-fail/object-safety-sized.rs
src/test/compile-fail/object-safety-supertrait-mentions-Self.rs
src/test/run-pass/issue-21058.rs

index 7d82e79f949110d03efc1396b2845685c8b4393c..78d0394a6e5ad31dbff6090aaab5409e67b2d0bd 100644 (file)
@@ -72,7 +72,6 @@ pub enum FooEnum {
     // Tests TyTrait
     pub trait FooTrait {
         fn foo_method(&self) -> usize;
-        fn foo_static_method() -> usize;
     }
 
     // Tests TyStruct
index 4e6ae96e3fc751c600d08160e7cb29dea2c608ff..d18746cdf0ba5726cab195da4d15ed12bb637e14 100644 (file)
@@ -9,12 +9,12 @@
 // 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>;
 }
index 559e0e9a292a6dda32676241228923421dcede21..9b02bf4cb85a8744dddd64a452bca81da8ae022b 100644 (file)
@@ -15,7 +15,7 @@
 // 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>;
 }
 
index ebda2481803a7cef57f87661218d5831fa63fdef..95176da9020d566c9dfdcc8bf3703ad85b1ee5fe 100644 (file)
@@ -21,10 +21,11 @@ fn foo<T>(&self, _: &T) {}
 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);
 }
index dbc0e410cf95c552e7123f00818975093ce05a62..e24e6bbeb7bbac40954121f8b4d7a1a18258d118 100644 (file)
@@ -18,11 +18,11 @@ fn qiz() {}
 }
 
 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() { }
index b9c90755b2c73845447870b3d783d5d7c5013e28..a6190500582620af5659fa756a9550f6c4af8c8f 100644 (file)
@@ -25,5 +25,6 @@ impl Bar for Thing { }
 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
 }
index fd20accfa1e6b562bd319e86b3a987a86baefcaf..63e5718537cf9166881efafaa66be30ff683b1a0 100644 (file)
@@ -23,14 +23,15 @@ fn bar<T>(&self, t: T)
 
 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 {
index edf32131b6875772f68ea6d46ef90b57622dfc17..f49ed42fe44d0022bc132a65b4b75a7094b14933 100644 (file)
@@ -18,7 +18,7 @@ trait Expr: Debug + PartialEq {
 
 //#[derive(PartialEq)]
 #[derive(Debug)]
-struct SExpr<'x> {
+struct SExpr<'x> { //~ ERROR E0038
     elements: Vec<Box<Expr+ 'x>>,
 }
 
@@ -43,8 +43,8 @@ fn print_element_count(&self) {
 }
 
 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);
 }
index b546774ccbd8cae8deb49bb638bf3e8fa886fac1..55b780906355a8f8b1a21f12679ab1f132938cb5 100644 (file)
@@ -26,26 +26,28 @@ trait Quux {
 
 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 {
index 6a010d49692d26450a4d95225eb3695c4509b0cd..2dc7983d1b561d3f522177862a62ed295ef757d4 100644 (file)
@@ -17,14 +17,15 @@ trait Foo {
 
 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() {
index 3a02461bbb223c177d43599f8d74abf380e1cb01..401602bd681a38b5a536e98fd533c8e8c2492c5f 100644 (file)
@@ -19,14 +19,15 @@ trait Bar
 
 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() {
index bc214f6f3d9623ca30c1fcc8257b5cb68143c810..29b4e4db65c36d11a70a7b04bbceb1e1dc988c11 100644 (file)
@@ -17,14 +17,15 @@ trait Bar : Sized {
 
 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() {
index d3f9dc73020fb3eafe0e2483d00e273dc2b43c19..ba82635a4016e16a0b57c59ac7bec7e33017ab5d 100644 (file)
@@ -24,7 +24,7 @@ fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
 
 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
 }
 
index 5fe3434e499e12a7f14fda13296795dda0fb433a..0ca936878148b6c54f2d477f9d43128beaf838b9 100644 (file)
@@ -21,10 +21,10 @@ fn main() {
         // 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"));
 }