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.

19 lines
786 B
Rust
Raw Normal View History

2024-06-23 12:55:17 -05:00
//@ check-pass
trait Trait<'a> {}
fn add_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send) {
2024-06-23 12:55:17 -05:00
x as _
//~^ warning: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
//~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
// (to test diagnostic list formatting)
fn add_multiple_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send + Sync + Unpin) {
x as _
2024-07-04 11:38:18 -05:00
//~^ warning: adding auto traits `Send`, `Sync`, and `Unpin` to a trait object in a pointer cast may cause UB later on
//~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
}
fn main() {}