about summary refs log tree commit diff
path: root/tests/ui/self
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-01-08 00:46:03 +0000
committerMichael Goulet <michael@errs.io>2025-01-14 18:47:23 +0000
commit3cd75812c818c5e7855f1be8f6a754c9f7a9f0f8 (patch)
treed6b249747e31a25e7041aa2e74d0519d9483ff0e /tests/ui/self
parent11bc805369b7e2aa641e885c137b2c86ce701e2c (diff)
downloadrust-3cd75812c818c5e7855f1be8f6a754c9f7a9f0f8.tar.gz
rust-3cd75812c818c5e7855f1be8f6a754c9f7a9f0f8.zip
Normalize field before checking PhantomData in coerce/dispatch impl validation
Diffstat (limited to 'tests/ui/self')
-rw-r--r--tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs b/tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs
new file mode 100644
index 00000000000..9c7e33830f5
--- /dev/null
+++ b/tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs
@@ -0,0 +1,25 @@
+//@ check-pass
+
+#![feature(coerce_unsized, dispatch_from_dyn, unsize)]
+
+use std::marker::Unsize;
+use std::ops::{CoerceUnsized, DispatchFromDyn};
+use std::marker::PhantomData;
+
+trait Mirror {
+    type Assoc;
+}
+impl<T> Mirror for T {
+    type Assoc = T;
+}
+
+struct W<T: 'static> {
+    t: &'static T,
+    f: <PhantomData<T> as Mirror>::Assoc,
+}
+
+impl<T, U> CoerceUnsized<W<U>> for W<T> where T: Unsize<U> {}
+
+impl<T, U> DispatchFromDyn<W<U>> for W<T> where T: Unsize<U> {}
+
+fn main() {}