Skip to content

Commit a18ee9a

Browse files
committed
RFC 2027: Add revisions to some existing object safety tests
1 parent d05ba47 commit a18ee9a

25 files changed

+221
-48
lines changed

src/test/ui/arbitrary-self-types-not-object-safe.stderr renamed to src/test/ui/arbitrary-self-types-not-object-safe.curr.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0038]: the trait `Foo` cannot be made into an object
2-
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:32
2+
--> $DIR/arbitrary-self-types-not-object-safe.rs:34:32
33
|
44
LL | let x = Rc::new(5usize) as Rc<Foo>;
55
| ^^^^^^^ the trait `Foo` cannot be made into an object
66
|
77
= note: method `foo`'s receiver cannot be dispatched on
88

99
error[E0038]: the trait `Foo` cannot be made into an object
10-
--> $DIR/arbitrary-self-types-not-object-safe.rs:31:13
10+
--> $DIR/arbitrary-self-types-not-object-safe.rs:34:13
1111
|
1212
LL | let x = Rc::new(5usize) as Rc<Foo>;
1313
| ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0038]: the trait `Foo` cannot be made into an object
2+
--> $DIR/arbitrary-self-types-not-object-safe.rs:34:32
3+
|
4+
LL | let x = Rc::new(5usize) as Rc<Foo>;
5+
| ^^^^^^^ the trait `Foo` cannot be made into an object
6+
|
7+
= note: method `foo`'s receiver cannot be dispatched on
8+
= note: required by cast to type 'std::rc::Rc<dyn Foo>'
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0038`.

src/test/ui/arbitrary-self-types-not-object-safe.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// revisions: curr object_safe_for_dispatch
2+
3+
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
14
#![feature(arbitrary_self_types)]
25

36
use std::rc::Rc;
@@ -29,8 +32,9 @@ impl Bar for usize {
2932

3033
fn make_foo() {
3134
let x = Rc::new(5usize) as Rc<Foo>;
32-
//~^ ERROR E0038
33-
//~| ERROR E0038
35+
//[curr]~^ ERROR E0038
36+
//[curr]~| ERROR E0038
37+
//[object_safe_for_dispatch]~^^^ ERROR E0038
3438
}
3539

3640
fn make_bar() {

src/test/ui/kindck/kindck-inherited-copy-bound.stderr renamed to src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied
2-
--> $DIR/kindck-inherited-copy-bound.rs:18:5
2+
--> $DIR/kindck-inherited-copy-bound.rs:21:5
33
|
4-
LL | take_param(&x); //~ ERROR E0277
4+
LL | take_param(&x); //[curr]~ ERROR E0277
55
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>`
66
|
77
= note: required because of the requirements on the impl of `Foo` for `std::boxed::Box<{integer}>`
88
note: required by `take_param`
9-
--> $DIR/kindck-inherited-copy-bound.rs:14:1
9+
--> $DIR/kindck-inherited-copy-bound.rs:17:1
1010
|
1111
LL | fn take_param<T:Foo>(foo: &T) { }
1212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1313

1414
error[E0038]: the trait `Foo` cannot be made into an object
15-
--> $DIR/kindck-inherited-copy-bound.rs:24:19
15+
--> $DIR/kindck-inherited-copy-bound.rs:28:19
1616
|
1717
LL | let z = &x as &Foo;
1818
| ^^^^ the trait `Foo` cannot be made into an object
1919
|
2020
= note: the trait cannot require that `Self : Sized`
2121

2222
error[E0038]: the trait `Foo` cannot be made into an object
23-
--> $DIR/kindck-inherited-copy-bound.rs:24:13
23+
--> $DIR/kindck-inherited-copy-bound.rs:28:13
2424
|
2525
LL | let z = &x as &Foo;
2626
| ^^ the trait `Foo` cannot be made into an object
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0277]: the trait bound `std::boxed::Box<{integer}>: std::marker::Copy` is not satisfied
2+
--> $DIR/kindck-inherited-copy-bound.rs:21:5
3+
|
4+
LL | take_param(&x); //[curr]~ ERROR E0277
5+
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>`
6+
|
7+
= note: required because of the requirements on the impl of `Foo` for `std::boxed::Box<{integer}>`
8+
note: required by `take_param`
9+
--> $DIR/kindck-inherited-copy-bound.rs:17:1
10+
|
11+
LL | fn take_param<T:Foo>(foo: &T) { }
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error[E0038]: the trait `Foo` cannot be made into an object
15+
--> $DIR/kindck-inherited-copy-bound.rs:28:19
16+
|
17+
LL | let z = &x as &Foo;
18+
| ^^^^ the trait `Foo` cannot be made into an object
19+
|
20+
= note: the trait cannot require that `Self : Sized`
21+
= note: required by cast to type '&dyn Foo'
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors occurred: E0038, E0277.
26+
For more information about an error, try `rustc --explain E0038`.

src/test/ui/kindck/kindck-inherited-copy-bound.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Test that Copy bounds inherited by trait are checked.
2+
//
3+
// revisions: curr object_safe_for_dispatch
24

5+
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
36
#![feature(box_syntax)]
47

58
use std::any::Any;
@@ -15,15 +18,17 @@ fn take_param<T:Foo>(foo: &T) { }
1518

1619
fn a() {
1720
let x: Box<_> = box 3;
18-
take_param(&x); //~ ERROR E0277
21+
take_param(&x); //[curr]~ ERROR E0277
22+
//[object_safe_for_dispatch]~^ ERROR E0277
1923
}
2024

2125
fn b() {
2226
let x: Box<_> = box 3;
2327
let y = &x;
2428
let z = &x as &Foo;
25-
//~^ ERROR E0038
26-
//~| ERROR E0038
29+
//[curr]~^ ERROR E0038
30+
//[curr]~| ERROR E0038
31+
//[object_safe_for_dispatch]~^^^ ERROR E0038
2732
}
2833

2934
fn main() { }

src/test/ui/object-safety/object-safety-associated-consts.stderr renamed to src/test/ui/object-safety/object-safety-associated-consts.curr.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0038]: the trait `Bar` cannot be made into an object
2-
--> $DIR/object-safety-associated-consts.rs:9:1
2+
--> $DIR/object-safety-associated-consts.rs:12:1
33
|
44
LL | fn make_bar<T:Bar>(t: &T) -> &Bar {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0038]: the trait `Bar` cannot be made into an object
2+
--> $DIR/object-safety-associated-consts.rs:14:5
3+
|
4+
LL | t
5+
| ^ the trait `Bar` cannot be made into an object
6+
|
7+
= note: the trait cannot contain associated consts like `X`
8+
= note: required when trying to coerce from type `&T` to type '&dyn Bar`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0038`.

src/test/ui/object-safety/object-safety-associated-consts.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
// Check that we correctly prevent users from making trait objects
22
// from traits with associated consts.
3+
//
4+
// revisions: curr object_safe_for_dispatch
35

6+
#![cfg_attr(object_safe_for_dispatch, feature(object_safe_for_dispatch))]
47

58
trait Bar {
69
const X: usize;
710
}
811

912
fn make_bar<T:Bar>(t: &T) -> &Bar {
10-
//~^ ERROR E0038
13+
//[curr]~^ ERROR E0038
1114
t
15+
//[object_safe_for_dispatch]~^ ERROR E0038
1216
}
1317

1418
fn main() {

src/test/ui/object-safety/object-safety-generics.stderr renamed to src/test/ui/object-safety/object-safety-generics.curr.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0038]: the trait `Bar` cannot be made into an object
2-
--> $DIR/object-safety-generics.rs:14:1
2+
--> $DIR/object-safety-generics.rs:18:1
33
|
44
LL | fn make_bar<T:Bar>(t: &T) -> &Bar {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object
66
|
77
= note: method `bar` has generic type parameters
88

99
error[E0038]: the trait `Bar` cannot be made into an object
10-
--> $DIR/object-safety-generics.rs:19:1
10+
--> $DIR/object-safety-generics.rs:24:1
1111
|
1212
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &Bar {
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object

0 commit comments

Comments
 (0)