8 files changed +27
-20
lines changed Original file line number Diff line number Diff line change 4
4
5
5
#![ feature( unsized_tuple_coercion) ]
6
6
7
- trait Foo < T > {
8
- fn foo ( & self , _: T ) -> u32 { 42 }
9
- }
10
-
11
7
trait Bar { //~ WARN trait `Bar` is never used
12
8
fn bar ( & self ) { println ! ( "Bar!" ) ; }
13
9
}
14
10
15
- impl < T > Foo < T > for ( ) { }
16
- impl Foo < u32 > for u32 { fn foo ( & self , _: u32 ) -> u32 { self +43 } }
17
11
impl Bar for ( ) { }
18
12
19
13
#[ repr( C ) ]
Original file line number Diff line number Diff line change 1
1
warning: trait `Bar` is never used
2
- --> $DIR/cast-rfc0401-vtable-kinds.rs:11 :7
2
+ --> $DIR/cast-rfc0401-vtable-kinds.rs:7 :7
3
3
|
4
4
LL | trait Bar {
5
5
| ^^^
Original file line number Diff line number Diff line change @@ -35,4 +35,4 @@ trait Assocked {
35
35
36
36
fn change_assoc ( x : * mut dyn Assocked < Assoc = u8 > ) -> * mut dyn Assocked < Assoc = u32 > {
37
37
x as _ //~ error: the trait bound `dyn Assocked<Assoc = u8>: Unsize<dyn Assocked<Assoc = u32>>` is not satisfied
38
- }
38
+ }
Original file line number Diff line number Diff line change 3
3
4
4
trait Trait {}
5
5
6
- fn assert_send(ptr: *mut dyn Trait ) -> *mut (dyn Trait + Send) {
6
+ fn assert_send() -> *mut (dyn Trait + Send) {
7
7
//~^ ERROR incorrect parentheses around trait bounds
8
- ptr as _
8
+ loop {}
9
9
}
10
10
11
11
fn foo2(_: &(dyn Trait + Send)) {}
Original file line number Diff line number Diff line change 3
3
4
4
trait Trait { }
5
5
6
- fn assert_send ( ptr : * mut dyn Trait ) -> * mut dyn ( Trait + Send ) {
6
+ fn assert_send ( ) -> * mut dyn ( Trait + Send ) {
7
7
//~^ ERROR incorrect parentheses around trait bounds
8
- ptr as _
8
+ loop { }
9
9
}
10
10
11
11
fn foo2 ( _: & dyn ( Trait + Send ) ) { }
Original file line number Diff line number Diff line change 1
1
error: incorrect parentheses around trait bounds
2
- --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:49
2
+ --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:30
3
3
|
4
- LL | fn assert_send(ptr: *mut dyn Trait ) -> *mut dyn (Trait + Send) {
5
- | ^ ^
4
+ LL | fn assert_send() -> *mut dyn (Trait + Send) {
5
+ | ^ ^
6
6
|
7
7
help: fix the parentheses
8
8
|
9
- LL - fn assert_send(ptr: *mut dyn Trait ) -> *mut dyn (Trait + Send) {
10
- LL + fn assert_send(ptr: *mut dyn Trait ) -> *mut (dyn Trait + Send) {
9
+ LL - fn assert_send() -> *mut dyn (Trait + Send) {
10
+ LL + fn assert_send() -> *mut (dyn Trait + Send) {
11
11
|
12
12
13
13
error: incorrect parentheses around trait bounds
Original file line number Diff line number Diff line change 1
1
#![ feature( trait_upcasting) ]
2
- // known-bug: #120222
3
- // check-pass
4
- //! This will segfault at runtime.
2
+ // check-fail
3
+ //
4
+ // issue: <https://github.com/rust-lang/rust/pull/120222>
5
+ //! This would segfault at runtime.
5
6
6
7
pub trait SupSupA {
7
8
fn method ( & self ) { }
@@ -56,6 +57,7 @@ pub fn user2() -> &'static dyn Trait<u8, u16> {
56
57
fn main ( ) {
57
58
let p: * const dyn Trait < u8 , u8 > = & ( ) ;
58
59
let p = p as * const dyn Trait < u8 , u16 > ; // <- this is bad!
60
+ //~^ error: the trait bound `dyn Trait<u8, u8>: Unsize<dyn Trait<u8, u16>>` is not satisfied
59
61
let p = p as * const dyn Super < u16 > ; // <- this upcast accesses improper vtable entry
60
62
// accessing from L__unnamed_2 the position for the 'Super<u16> vtable (pointer)',
61
63
// thus reading 'null pointer for missing_method'
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `dyn Trait<u8, u8>: Unsize<dyn Trait<u8, u16>>` is not satisfied
2
+ --> $DIR/upcast_soundness_bug.rs:59:13
3
+ |
4
+ LL | let p = p as *const dyn Trait<u8, u16>; // <- this is bad!
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unsize<dyn Trait<u8, u16>>` is not implemented for `dyn Trait<u8, u8>`
6
+ |
7
+ = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information
8
+
9
+ error: aborting due to 1 previous error
10
+
11
+ For more information about this error, try `rustc --explain E0277`.
0 commit comments