Skip to content

Commit 6adc76d

Browse files
committed
add known-bug test for unsoundness issue rust-lang#105787
Part of the resolution to rust-lang#105107
1 parent 7d83d69 commit 6adc76d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
// known-bug: #105787
3+
trait ToUnit<'a> {
4+
type Unit;
5+
}
6+
7+
struct LocalTy;
8+
impl<'a> ToUnit<'a> for *const LocalTy {
9+
type Unit = ();
10+
}
11+
12+
impl<'a, T: Copy + ?Sized> ToUnit<'a> for *const T {
13+
type Unit = ();
14+
}
15+
16+
trait Overlap<T> {
17+
type Assoc;
18+
}
19+
20+
type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit;
21+
22+
impl<T> Overlap<T> for T {
23+
type Assoc = usize;
24+
}
25+
26+
impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T
27+
where
28+
for<'a> *const T: ToUnit<'a>,
29+
{
30+
type Assoc = Box<usize>;
31+
}
32+
33+
fn foo<T: Overlap<U>, U>(x: T::Assoc) -> T::Assoc {
34+
x
35+
}
36+
37+
fn main() {
38+
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
39+
}

0 commit comments

Comments
 (0)