-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RFC 2027: Add revisions to some existing object safety tests
- Loading branch information
1 parent
d05ba47
commit a18ee9a
Showing
25 changed files
with
221 additions
and
48 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...bitrary-self-types-not-object-safe.stderr → ...ry-self-types-not-object-safe.curr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/test/ui/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Foo>; | ||
| ^^^^^^^ 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<dyn Foo>' | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0038`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...kindck/kindck-inherited-copy-bound.stderr → ...k/kindck-inherited-copy-bound.curr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T:Foo>(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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ty/object-safety-associated-consts.stderr → ...ject-safety-associated-consts.curr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/test/ui/object-safety/object-safety-associated-consts.object_safe_for_dispatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ject-safety/object-safety-generics.stderr → ...safety/object-safety-generics.curr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/ui/object-safety/object-safety-generics.object_safe_for_dispatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...safety/object-safety-mentions-Self.stderr → ...y/object-safety-mentions-Self.curr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/ui/object-safety/object-safety-mentions-Self.object_safe_for_dispatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
// 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:Bar>(t: &T) -> &Bar { | ||
//~^ ERROR E0038 | ||
loop { } | ||
//[curr]~^ ERROR E0038 | ||
t | ||
//[object_safe_for_dispatch]~^ ERROR E0038 | ||
} | ||
|
||
fn make_baz<T:Baz>(t: &T) -> &Baz { | ||
//~^ ERROR E0038 | ||
//[curr]~^ ERROR E0038 | ||
t | ||
//[object_safe_for_dispatch]~^ ERROR E0038 | ||
} | ||
|
||
fn make_quux<T:Quux>(t: &T) -> &Quux { | ||
t | ||
} | ||
|
||
fn make_quux_explicit<T:Quux>(t: &T) -> &Quux { | ||
t as &Quux | ||
t as &dyn Quux | ||
} | ||
|
||
fn main() { | ||
} | ||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/object-safety/object-safety-no-static.curr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<dyn Foo> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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`. |
12 changes: 12 additions & 0 deletions
12
src/test/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<dyn Foo> = 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<Bar>` to type 'std::boxed::Box<dyn Foo>` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0038`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> { | ||
//~^ ERROR E0038 | ||
fn diverges() -> Box<dyn Foo> { | ||
//[curr]~^ ERROR E0038 | ||
loop { } | ||
} | ||
|
||
struct Bar; | ||
|
||
impl Foo for Bar {} | ||
|
||
fn main() { | ||
let b: Box<dyn Foo> = Box::new(Bar); | ||
//[object_safe_for_dispatch]~^ ERROR E0038 | ||
} |
Oops, something went wrong.