mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00

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.
33 lines
628 B
Rust
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() {}
|