diff options
| author | Michael Goulet <michael@errs.io> | 2025-04-14 16:49:56 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-04-14 16:51:00 +0000 |
| commit | 3df7882272c96a19bcff6269e4f9f0aba34b6c6f (patch) | |
| tree | b18f66e85133ba697af93d53ab8b073bf3f88c14 /tests/ui/coercion/codegen-smart-pointer-with-alias.rs | |
| parent | c580c498a1fe144d7c5b2dfc7faab1a229aa288b (diff) | |
| download | rust-3df7882272c96a19bcff6269e4f9f0aba34b6c6f.tar.gz rust-3df7882272c96a19bcff6269e4f9f0aba34b6c6f.zip | |
Normalize ADT fields in find_tails_for_unsizing
Diffstat (limited to 'tests/ui/coercion/codegen-smart-pointer-with-alias.rs')
| -rw-r--r-- | tests/ui/coercion/codegen-smart-pointer-with-alias.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/coercion/codegen-smart-pointer-with-alias.rs b/tests/ui/coercion/codegen-smart-pointer-with-alias.rs new file mode 100644 index 00000000000..a68952bb70a --- /dev/null +++ b/tests/ui/coercion/codegen-smart-pointer-with-alias.rs @@ -0,0 +1,32 @@ +//@ build-pass + +// Regression test for <https://github.com/rust-lang/rust/issues/139812>. + +// Make sure that the unsize coercion we collect in mono for `Signal<i32> -> Signal<dyn Any>` +// doesn't choke on the fact that the inner unsized field of `Signal<T>` is a (trivial) alias. +// This exercises a normalize call that is necessary since we're getting a type from the type +// system, which isn't guaranteed to be normalized after substitution. + +#![feature(coerce_unsized)] + +use std::ops::CoerceUnsized; + +trait Mirror { + type Assoc: ?Sized; +} +impl<T: ?Sized> Mirror for T { + type Assoc = T; +} + +trait Any {} +impl<T> Any for T {} + +struct Signal<'a, T: ?Sized>(<&'a T as Mirror>::Assoc); + +// This `CoerceUnsized` impl isn't special; it's a bit more restricted than we'd see in the wild, +// but this ICE also reproduces if we were to make it general over `Signal<T> -> Signal<U>`. +impl<'a> CoerceUnsized<Signal<'a, dyn Any>> for Signal<'a, i32> {} + +fn main() { + Signal(&1i32) as Signal<dyn Any>; +} |
