forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
known-bug
test for unsoundness issue rust-lang#105787
Part of the resolution to rust-lang#105107
- Loading branch information
1 parent
7d83d69
commit 6adc76d
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T> { | ||
type Assoc; | ||
} | ||
|
||
type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; | ||
|
||
impl<T> Overlap<T> for T { | ||
type Assoc = usize; | ||
} | ||
|
||
impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T | ||
where | ||
for<'a> *const T: ToUnit<'a>, | ||
{ | ||
type Assoc = Box<usize>; | ||
} | ||
|
||
fn foo<T: Overlap<U>, U>(x: T::Assoc) -> T::Assoc { | ||
x | ||
} | ||
|
||
fn main() { | ||
foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize); | ||
} |