about summary refs log tree commit diff
path: root/tests/ui/cast/ptr-to-trait-obj-add-auto.rs
blob: 3a1e667d03a4f11e9d74f4d94d69cdb7c1fbec5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
trait Trait<'a> {}

fn add_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send) {
    x as _
    //~^ ERROR cannot add auto trait `Send` to dyn bound via pointer cast
    //~| NOTE unsupported cast
    //~| NOTE this could allow UB elsewhere
    //~| HELP use `transmute` if you're sure this is sound
}

// (to test diagnostic list formatting)
fn add_multiple_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send + Sync + Unpin) {
    x as _
    //~^ ERROR cannot add auto traits `Send`, `Sync`, and `Unpin` to dyn bound via pointer cast
    //~| NOTE unsupported cast
    //~| NOTE this could allow UB elsewhere
    //~| HELP use `transmute` if you're sure this is sound
}

fn main() {}