Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 09ccc5c

Browse files
committed
Add two ICEs for issue 101696
Tracks rust-lang/rust#101696
1 parent 9e9dc8d commit 09ccc5c

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

ices/101696-1.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use std::marker::PhantomData;
2+
3+
#[derive(Default)]
4+
struct MyType<'a> {
5+
field: usize,
6+
_phantom: PhantomData<&'a ()>,
7+
}
8+
9+
#[derive(Default)]
10+
struct MyTypeVariant<'a> {
11+
field: usize,
12+
_phantom: PhantomData<&'a ()>,
13+
}
14+
15+
trait AsVariantTrait {
16+
type Type;
17+
}
18+
19+
impl<'a> AsVariantTrait for MyType<'a> {
20+
type Type = MyTypeVariant<'a>;
21+
}
22+
23+
type Variant<G> = <G as AsVariantTrait>::Type;
24+
25+
fn foo<T: Default, F: FnOnce(T)>(f: F) {
26+
let input = T::default();
27+
f(input);
28+
}
29+
30+
fn main() {
31+
foo(|a: Variant<MyType>| {
32+
a.field;
33+
});
34+
}

ices/101696-2.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use std::marker::PhantomData;
2+
3+
#[derive(Default)]
4+
struct MyType<'a> {
5+
field: usize,
6+
_phantom: PhantomData<&'a ()>,
7+
}
8+
9+
#[derive(Default)]
10+
struct MyTypeVariant<'a> {
11+
field: usize,
12+
_phantom: PhantomData<&'a ()>,
13+
}
14+
15+
trait AsVariantTrait {
16+
type Type;
17+
}
18+
19+
impl<'a> AsVariantTrait for MyType<'a> {
20+
type Type = MyTypeVariant<'a>;
21+
}
22+
23+
fn foo<T: Default, F: FnOnce(T)>(f: F) {
24+
let input = T::default();
25+
f(input);
26+
}
27+
28+
fn main() {
29+
foo(|a: <MyType as AsVariantTrait>::Type| {
30+
a.field;
31+
});
32+
}

0 commit comments

Comments
 (0)