From 6adc76dff254534ad2712cd1dbf80ce6300c8c0c Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Fri, 24 Feb 2023 23:24:10 -0700 Subject: [PATCH] add `known-bug` test for unsoundness issue #105787 Part of the resolution to #105107 --- tests/ui/specialization/issue-105787.rs | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/ui/specialization/issue-105787.rs diff --git a/tests/ui/specialization/issue-105787.rs b/tests/ui/specialization/issue-105787.rs new file mode 100644 index 0000000000000..3cf655de2e5e1 --- /dev/null +++ b/tests/ui/specialization/issue-105787.rs @@ -0,0 +1,39 @@ +// check-pass +// known-bug: #105787 +trait ToUnit<'a> { + type Unit; +} + +struct LocalTy; +impl<'a> ToUnit<'a> for *const LocalTy { + type Unit = (); +} + +impl<'a, T: Copy + ?Sized> ToUnit<'a> for *const T { + type Unit = (); +} + +trait Overlap { + type Assoc; +} + +type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; + +impl Overlap for T { + type Assoc = usize; +} + +impl Overlap fn(&'a (), Assoc<'a, T>)> for T +where + for<'a> *const T: ToUnit<'a>, +{ + type Assoc = Box; +} + +fn foo, U>(x: T::Assoc) -> T::Assoc { + x +} + +fn main() { + foo:: fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize); +}