diff --git a/src/test/ui/arbitrary-self-types-not-object-safe.stderr b/src/test/ui/arbitrary-self-types-not-object-safe.curr.stderr similarity index 87% rename from src/test/ui/arbitrary-self-types-not-object-safe.stderr rename to src/test/ui/arbitrary-self-types-not-object-safe.curr.stderr index dacab1222aba3..11d430e2483bf 100644 --- a/src/test/ui/arbitrary-self-types-not-object-safe.stderr +++ b/src/test/ui/arbitrary-self-types-not-object-safe.curr.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/arbitrary-self-types-not-object-safe.rs:31:32 + --> $DIR/arbitrary-self-types-not-object-safe.rs:34:32 | LL | let x = Rc::new(5usize) as Rc; | ^^^^^^^ the trait `Foo` cannot be made into an object @@ -7,7 +7,7 @@ LL | let x = Rc::new(5usize) as Rc; = note: method `foo`'s receiver cannot be dispatched on error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/arbitrary-self-types-not-object-safe.rs:31:13 + --> $DIR/arbitrary-self-types-not-object-safe.rs:34:13 | LL | let x = Rc::new(5usize) as Rc; | ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object diff --git a/src/test/ui/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr b/src/test/ui/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..70a17fa35d0bd --- /dev/null +++ b/src/test/ui/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr @@ -0,0 +1,12 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/arbitrary-self-types-not-object-safe.rs:34:32 + | +LL | let x = Rc::new(5usize) as Rc; + | ^^^^^^^ the trait `Foo` cannot be made into an object + | + = note: method `foo`'s receiver cannot be dispatched on + = note: required by cast to type 'std::rc::Rc' + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/arbitrary-self-types-not-object-safe.rs b/src/test/ui/arbitrary-self-types-not-object-safe.rs index 2c1fd937a65ad..89972ff6b076b 100644 --- a/src/test/ui/arbitrary-self-types-not-object-safe.rs +++ b/src/test/ui/arbitrary-self-types-not-object-safe.rs @@ -1,3 +1,6 @@ +// revisions: curr object_safe_for_dispatch + +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] #![feature(arbitrary_self_types)] use std::rc::Rc; @@ -29,8 +32,9 @@ impl Bar for usize { fn make_foo() { let x = Rc::new(5usize) as Rc; - //~^ ERROR E0038 - //~| ERROR E0038 + //[curr]~^ ERROR E0038 + //[curr]~| ERROR E0038 + //[object_safe_for_dispatch]~^^^ ERROR E0038 } fn make_bar() { diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr similarity index 82% rename from src/test/ui/kindck/kindck-inherited-copy-bound.stderr rename to src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr index fe8e02e354776..c0823eba3bb03 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr @@ -1,18 +1,18 @@ error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied - --> $DIR/kindck-inherited-copy-bound.rs:18:5 + --> $DIR/kindck-inherited-copy-bound.rs:21:5 | -LL | take_param(&x); //~ ERROR E0277 +LL | take_param(&x); //[curr]~ ERROR E0277 | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` | = note: required because of the requirements on the impl of `Foo` for `std::boxed::Box<{integer}>` note: required by `take_param` - --> $DIR/kindck-inherited-copy-bound.rs:14:1 + --> $DIR/kindck-inherited-copy-bound.rs:17:1 | LL | fn take_param(foo: &T) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/kindck-inherited-copy-bound.rs:24:19 + --> $DIR/kindck-inherited-copy-bound.rs:28:19 | LL | let z = &x as &Foo; | ^^^^ the trait `Foo` cannot be made into an object @@ -20,7 +20,7 @@ LL | let z = &x as &Foo; = note: the trait cannot require that `Self : Sized` error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/kindck-inherited-copy-bound.rs:24:13 + --> $DIR/kindck-inherited-copy-bound.rs:28:13 | LL | let z = &x as &Foo; | ^^ the trait `Foo` cannot be made into an object diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..7f75e6f974902 --- /dev/null +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr @@ -0,0 +1,26 @@ +error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied + --> $DIR/kindck-inherited-copy-bound.rs:21:5 + | +LL | take_param(&x); //[curr]~ ERROR E0277 + | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` + | + = note: required because of the requirements on the impl of `Foo` for `std::boxed::Box<{integer}>` +note: required by `take_param` + --> $DIR/kindck-inherited-copy-bound.rs:17:1 + | +LL | fn take_param(foo: &T) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/kindck-inherited-copy-bound.rs:28:19 + | +LL | let z = &x as &Foo; + | ^^^^ the trait `Foo` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + = note: required by cast to type '&dyn Foo' + +error: aborting due to 2 previous errors + +Some errors occurred: E0038, E0277. +For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.rs b/src/test/ui/kindck/kindck-inherited-copy-bound.rs index 0134636fa0d3c..2cc510ee69147 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.rs +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.rs @@ -1,5 +1,8 @@ // Test that Copy bounds inherited by trait are checked. +// +// revisions: curr object_safe_for_dispatch +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] #![feature(box_syntax)] use std::any::Any; @@ -15,15 +18,17 @@ fn take_param(foo: &T) { } fn a() { let x: Box<_> = box 3; - take_param(&x); //~ ERROR E0277 + take_param(&x); //[curr]~ ERROR E0277 + //[object_safe_for_dispatch]~^ ERROR E0277 } fn b() { let x: Box<_> = box 3; let y = &x; let z = &x as &Foo; - //~^ ERROR E0038 - //~| ERROR E0038 + //[curr]~^ ERROR E0038 + //[curr]~| ERROR E0038 + //[object_safe_for_dispatch]~^^^ ERROR E0038 } fn main() { } diff --git a/src/test/ui/object-safety/object-safety-associated-consts.stderr b/src/test/ui/object-safety/object-safety-associated-consts.curr.stderr similarity index 87% rename from src/test/ui/object-safety/object-safety-associated-consts.stderr rename to src/test/ui/object-safety/object-safety-associated-consts.curr.stderr index 96962c10720a2..3104e5d5aa0f0 100644 --- a/src/test/ui/object-safety/object-safety-associated-consts.stderr +++ b/src/test/ui/object-safety/object-safety-associated-consts.curr.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/object-safety-associated-consts.rs:9:1 + --> $DIR/object-safety-associated-consts.rs:12:1 | LL | fn make_bar(t: &T) -> &Bar { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object diff --git a/src/test/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr b/src/test/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..9a13b023954eb --- /dev/null +++ b/src/test/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr @@ -0,0 +1,12 @@ +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-associated-consts.rs:14:5 + | +LL | t + | ^ the trait `Bar` cannot be made into an object + | + = note: the trait cannot contain associated consts like `X` + = note: required when trying to coerce from type `&T` to type '&dyn Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-associated-consts.rs b/src/test/ui/object-safety/object-safety-associated-consts.rs index 79b7e541af82a..b03c8b7169d15 100644 --- a/src/test/ui/object-safety/object-safety-associated-consts.rs +++ b/src/test/ui/object-safety/object-safety-associated-consts.rs @@ -1,14 +1,18 @@ // Check that we correctly prevent users from making trait objects // from traits with associated consts. +// +// revisions: curr object_safe_for_dispatch +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] trait Bar { const X: usize; } fn make_bar(t: &T) -> &Bar { - //~^ ERROR E0038 + //[curr]~^ ERROR E0038 t + //[object_safe_for_dispatch]~^ ERROR E0038 } fn main() { diff --git a/src/test/ui/object-safety/object-safety-generics.stderr b/src/test/ui/object-safety/object-safety-generics.curr.stderr similarity index 88% rename from src/test/ui/object-safety/object-safety-generics.stderr rename to src/test/ui/object-safety/object-safety-generics.curr.stderr index 7ae44794ceba9..cfbb0b651783b 100644 --- a/src/test/ui/object-safety/object-safety-generics.stderr +++ b/src/test/ui/object-safety/object-safety-generics.curr.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/object-safety-generics.rs:14:1 + --> $DIR/object-safety-generics.rs:18:1 | LL | fn make_bar(t: &T) -> &Bar { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object @@ -7,7 +7,7 @@ LL | fn make_bar(t: &T) -> &Bar { = note: method `bar` has generic type parameters error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/object-safety-generics.rs:19:1 + --> $DIR/object-safety-generics.rs:24:1 | LL | fn make_bar_explicit(t: &T) -> &Bar { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object diff --git a/src/test/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr b/src/test/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..61ab40d009009 --- /dev/null +++ b/src/test/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr @@ -0,0 +1,21 @@ +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-generics.rs:20:5 + | +LL | t + | ^ the trait `Bar` cannot be made into an object + | + = note: method `bar` has generic type parameters + = note: required when trying to coerce from type `&T` to type '&dyn Bar` + +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-generics.rs:26:10 + | +LL | t as &Bar + | ^^^^ the trait `Bar` cannot be made into an object + | + = note: method `bar` has generic type parameters + = note: required by cast to type '&dyn Bar' + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-generics.rs b/src/test/ui/object-safety/object-safety-generics.rs index 5f4aabf5469cb..6652355f599f8 100644 --- a/src/test/ui/object-safety/object-safety-generics.rs +++ b/src/test/ui/object-safety/object-safety-generics.rs @@ -1,6 +1,10 @@ // Check that we correctly prevent users from making trait objects // from traits with generic methods, unless `where Self : Sized` is // present. +// revisions: curr object_safe_for_dispatch + +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] + trait Bar { fn bar(&self, t: T); @@ -12,13 +16,15 @@ trait Quux { } fn make_bar(t: &T) -> &Bar { - //~^ ERROR E0038 + //[curr]~^ ERROR E0038 t + //[object_safe_for_dispatch]~^ ERROR E0038 } fn make_bar_explicit(t: &T) -> &Bar { - //~^ ERROR E0038 + //[curr]~^ ERROR E0038 t as &Bar + //[object_safe_for_dispatch]~^ ERROR E0038 } fn make_quux(t: &T) -> &Quux { diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-mentions-Self.curr.stderr similarity index 85% rename from src/test/ui/object-safety/object-safety-mentions-Self.stderr rename to src/test/ui/object-safety/object-safety-mentions-Self.curr.stderr index ed3aed983cf7a..557e4f757fb96 100644 --- a/src/test/ui/object-safety/object-safety-mentions-Self.stderr +++ b/src/test/ui/object-safety/object-safety-mentions-Self.curr.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/object-safety-mentions-Self.rs:17:1 + --> $DIR/object-safety-mentions-Self.rs:22:1 | LL | fn make_bar(t: &T) -> &Bar { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object @@ -7,12 +7,12 @@ LL | fn make_bar(t: &T) -> &Bar { = note: method `bar` references the `Self` type in its arguments or return type error[E0038]: the trait `Baz` cannot be made into an object - --> $DIR/object-safety-mentions-Self.rs:22:1 + --> $DIR/object-safety-mentions-Self.rs:28:1 | LL | fn make_baz(t: &T) -> &Baz { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object | - = note: method `bar` references the `Self` type in its arguments or return type + = note: method `baz` references the `Self` type in its arguments or return type error: aborting due to 2 previous errors diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr b/src/test/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..e96a9701e3a19 --- /dev/null +++ b/src/test/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr @@ -0,0 +1,21 @@ +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-mentions-Self.rs:24:5 + | +LL | t + | ^ the trait `Bar` cannot be made into an object + | + = note: method `bar` references the `Self` type in its arguments or return type + = note: required when trying to coerce from type `&T` to type '&dyn Bar` + +error[E0038]: the trait `Baz` cannot be made into an object + --> $DIR/object-safety-mentions-Self.rs:30:5 + | +LL | t + | ^ the trait `Baz` cannot be made into an object + | + = note: method `baz` references the `Self` type in its arguments or return type + = note: required when trying to coerce from type `&T` to type '&dyn Baz` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.rs b/src/test/ui/object-safety/object-safety-mentions-Self.rs index 8e1bd83cec00a..3ca8f0608426e 100644 --- a/src/test/ui/object-safety/object-safety-mentions-Self.rs +++ b/src/test/ui/object-safety/object-safety-mentions-Self.rs @@ -1,27 +1,34 @@ // Check that we correctly prevent users from making trait objects // form traits that make use of `Self` in an argument or return // position, unless `where Self : Sized` is present.. +// +// revisions: curr object_safe_for_dispatch + +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] + trait Bar { fn bar(&self, x: &Self); } trait Baz { - fn bar(&self) -> Self; + fn baz(&self) -> Self; } trait Quux { - fn get(&self, s: &Self) -> Self where Self : Sized; + fn quux(&self, s: &Self) -> Self where Self : Sized; } fn make_bar(t: &T) -> &Bar { - //~^ ERROR E0038 - loop { } + //[curr]~^ ERROR E0038 + t + //[object_safe_for_dispatch]~^ ERROR E0038 } fn make_baz(t: &T) -> &Baz { - //~^ ERROR E0038 + //[curr]~^ ERROR E0038 t + //[object_safe_for_dispatch]~^ ERROR E0038 } fn make_quux(t: &T) -> &Quux { @@ -29,8 +36,7 @@ fn make_quux(t: &T) -> &Quux { } fn make_quux_explicit(t: &T) -> &Quux { - t as &Quux + t as &dyn Quux } -fn main() { -} +fn main() {} diff --git a/src/test/ui/object-safety/object-safety-no-static.curr.stderr b/src/test/ui/object-safety/object-safety-no-static.curr.stderr new file mode 100644 index 0000000000000..1036c122f92bf --- /dev/null +++ b/src/test/ui/object-safety/object-safety-no-static.curr.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety-no-static.rs:12:1 + | +LL | fn diverges() -> Box { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object + | + = note: method `foo` has no receiver + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr b/src/test/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..001e6150a467d --- /dev/null +++ b/src/test/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr @@ -0,0 +1,12 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety-no-static.rs:22:27 + | +LL | let b: Box = Box::new(Bar); + | ^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object + | + = note: method `foo` has no receiver + = note: required when trying to coerce from type `std::boxed::Box` to type 'std::boxed::Box` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-no-static.rs b/src/test/ui/object-safety/object-safety-no-static.rs index 4faf9386f9a8b..03b6221748388 100644 --- a/src/test/ui/object-safety/object-safety-no-static.rs +++ b/src/test/ui/object-safety/object-safety-no-static.rs @@ -1,14 +1,24 @@ // Check that we correctly prevent users from making trait objects // from traits with static methods. +// +// revisions: curr object_safe_for_dispatch + +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] trait Foo { - fn foo(); + fn foo() {} } -fn foo_implicit(b: Box) -> Box { - //~^ ERROR E0038 +fn diverges() -> Box { + //[curr]~^ ERROR E0038 loop { } } +struct Bar; + +impl Foo for Bar {} + fn main() { + let b: Box = Box::new(Bar); + //[object_safe_for_dispatch]~^ ERROR E0038 } diff --git a/src/test/ui/object-safety/object-safety-no-static.stderr b/src/test/ui/object-safety/object-safety-no-static.stderr deleted file mode 100644 index 3b8ccb594c181..0000000000000 --- a/src/test/ui/object-safety/object-safety-no-static.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety-no-static.rs:8:1 - | -LL | fn foo_implicit(b: Box) -> Box { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object - | - = note: method `foo` has no receiver - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-sized-2.stderr b/src/test/ui/object-safety/object-safety-sized-2.curr.stderr similarity index 89% rename from src/test/ui/object-safety/object-safety-sized-2.stderr rename to src/test/ui/object-safety/object-safety-sized-2.curr.stderr index 2b8bfa341d796..f95de842e58ce 100644 --- a/src/test/ui/object-safety/object-safety-sized-2.stderr +++ b/src/test/ui/object-safety/object-safety-sized-2.curr.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/object-safety-sized-2.rs:10:1 + --> $DIR/object-safety-sized-2.rs:14:1 | LL | fn make_bar(t: &T) -> &Bar { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object diff --git a/src/test/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr b/src/test/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..5aae6f7fb92dc --- /dev/null +++ b/src/test/ui/object-safety/object-safety-sized-2.object_safe_for_dispatch.stderr @@ -0,0 +1,12 @@ +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-sized-2.rs:16:5 + | +LL | t + | ^ the trait `Bar` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + = note: required when trying to coerce from type `&T` to type '&dyn Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-sized-2.rs b/src/test/ui/object-safety/object-safety-sized-2.rs index baeb3734677fb..95e80b8c0fac1 100644 --- a/src/test/ui/object-safety/object-safety-sized-2.rs +++ b/src/test/ui/object-safety/object-safety-sized-2.rs @@ -1,5 +1,9 @@ // Check that we correctly prevent users from making trait objects // from traits where `Self : Sized`. +// +// revisions: curr object_safe_for_dispatch + +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] trait Bar where Self : Sized @@ -8,8 +12,9 @@ trait Bar } fn make_bar(t: &T) -> &Bar { - //~^ ERROR E0038 - loop { } + //[curr]~^ ERROR E0038 + t + //[object_safe_for_dispatch]~^ ERROR E0038 } fn main() { diff --git a/src/test/ui/object-safety/object-safety-sized.stderr b/src/test/ui/object-safety/object-safety-sized.curr.stderr similarity index 90% rename from src/test/ui/object-safety/object-safety-sized.stderr rename to src/test/ui/object-safety/object-safety-sized.curr.stderr index ba98e2f1ef655..20e5f3e43b052 100644 --- a/src/test/ui/object-safety/object-safety-sized.stderr +++ b/src/test/ui/object-safety/object-safety-sized.curr.stderr @@ -1,5 +1,5 @@ error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/object-safety-sized.rs:8:1 + --> $DIR/object-safety-sized.rs:12:1 | LL | fn make_bar(t: &T) -> &Bar { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object diff --git a/src/test/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr b/src/test/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr new file mode 100644 index 0000000000000..2530b841919f5 --- /dev/null +++ b/src/test/ui/object-safety/object-safety-sized.object_safe_for_dispatch.stderr @@ -0,0 +1,12 @@ +error[E0038]: the trait `Bar` cannot be made into an object + --> $DIR/object-safety-sized.rs:14:5 + | +LL | t + | ^ the trait `Bar` cannot be made into an object + | + = note: the trait cannot require that `Self : Sized` + = note: required when trying to coerce from type `&T` to type '&dyn Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/object-safety/object-safety-sized.rs b/src/test/ui/object-safety/object-safety-sized.rs index 77dc7390aff01..fdd661118c379 100644 --- a/src/test/ui/object-safety/object-safety-sized.rs +++ b/src/test/ui/object-safety/object-safety-sized.rs @@ -1,13 +1,18 @@ // Check that we correctly prevent users from making trait objects // from traits where `Self : Sized`. +// +// revisions: curr object_safe_for_dispatch + +#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))] trait Bar : Sized { fn bar(&self, t: T); } fn make_bar(t: &T) -> &Bar { - //~^ ERROR E0038 + //[curr]~^ ERROR E0038 t + //[object_safe_for_dispatch]~^ ERROR E0038 } fn main() {