Files
rust/tests/ui/cast/ptr-to-trait-obj-add-auto.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
707 B
Rust
Raw Normal View History

trait Trait<'a> {}
fn add_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send) {
2024-06-23 19:55:17 +02:00
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() {}