Skip to content

Commit

Permalink
add known-bug test for unsoundness issue rust-lang#105787
Browse files Browse the repository at this point in the history
Part of the resolution to rust-lang#105107
  • Loading branch information
gburgessiv authored and GrigorenkoPV committed Jun 26, 2024
1 parent 97fa7f0 commit 8c0236e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/ui/specialization/issue-105787.rs
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);
}

0 comments on commit 8c0236e

Please sign in to comment.