Skip to content

Commit

Permalink
Add two ICEs for issue 101696
Browse files Browse the repository at this point in the history
  • Loading branch information
BGR360 committed Sep 12, 2022
1 parent 9e9dc8d commit 09ccc5c
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ices/101696-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::marker::PhantomData;

#[derive(Default)]
struct MyType<'a> {
field: usize,
_phantom: PhantomData<&'a ()>,
}

#[derive(Default)]
struct MyTypeVariant<'a> {
field: usize,
_phantom: PhantomData<&'a ()>,
}

trait AsVariantTrait {
type Type;
}

impl<'a> AsVariantTrait for MyType<'a> {
type Type = MyTypeVariant<'a>;
}

type Variant<G> = <G as AsVariantTrait>::Type;

fn foo<T: Default, F: FnOnce(T)>(f: F) {
let input = T::default();
f(input);
}

fn main() {
foo(|a: Variant<MyType>| {
a.field;
});
}
32 changes: 32 additions & 0 deletions ices/101696-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::marker::PhantomData;

#[derive(Default)]
struct MyType<'a> {
field: usize,
_phantom: PhantomData<&'a ()>,
}

#[derive(Default)]
struct MyTypeVariant<'a> {
field: usize,
_phantom: PhantomData<&'a ()>,
}

trait AsVariantTrait {
type Type;
}

impl<'a> AsVariantTrait for MyType<'a> {
type Type = MyTypeVariant<'a>;
}

fn foo<T: Default, F: FnOnce(T)>(f: F) {
let input = T::default();
f(input);
}

fn main() {
foo(|a: <MyType as AsVariantTrait>::Type| {
a.field;
});
}

0 comments on commit 09ccc5c

Please sign in to comment.