rust/tests/ui/cast/ptr-to-trait-obj-wrap.rs
Waffle Lapkin 2c76bf7431
Remove an outdated line from a test comment
They *used* to not work, however this was fixed in the PR that added the
test. I forgot to remove this line or possibly lost its removal while
rebasing.
2025-03-13 17:59:42 +01:00

33 lines
628 B
Rust

// Checks that various casts of pointers to trait objects wrapped in structures
// work. Note that the metadata doesn't change when a DST is wrapped in a
// structure, so these casts *are* fine.
//
//@ check-pass
trait A {}
struct W<T: ?Sized>(T);
struct X<T: ?Sized>(T);
fn unwrap(a: *const W<dyn A>) -> *const dyn A {
a as _
}
fn unwrap_nested(a: *const W<W<dyn A>>) -> *const W<dyn A> {
a as _
}
fn rewrap(a: *const W<dyn A>) -> *const X<dyn A> {
a as _
}
fn rewrap_nested(a: *const W<W<dyn A>>) -> *const W<X<dyn A>> {
a as _
}
fn wrap(a: *const dyn A) -> *const W<dyn A> {
a as _
}
fn main() {}