Skip to content

Commit e54bff7

Browse files
committed
add test for #104779 opaque types, patterns and subtyping ICE: IndexMap: key not found
Fixes #104779
1 parent 2f9a240 commit e54bff7

2 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// issue: rust-lang/rust#104779
2+
// ICE region infer, IndexMap: key not found
3+
4+
struct Inv<'a>(&'a mut &'a ());
5+
enum Foo<T> {
6+
Bar,
7+
Var(T),
8+
}
9+
type Subtype = Foo<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>;
10+
type Supertype = Foo<for<'a> fn(Inv<'a>, Inv<'a>)>;
11+
12+
fn foo() -> impl Sized {
13+
//~^ WARN function cannot return without recursing
14+
loop {
15+
match foo() {
16+
//~^ ERROR higher-ranked subtype error
17+
//~^^ ERROR higher-ranked subtype error
18+
Subtype::Bar => (),
19+
//~^ ERROR higher-ranked subtype error
20+
//~^^ ERROR higher-ranked subtype error
21+
Supertype::Var(x) => {}
22+
}
23+
}
24+
}
25+
26+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
warning: function cannot return without recursing
2+
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:12:1
3+
|
4+
LL | fn foo() -> impl Sized {
5+
| ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
6+
...
7+
LL | match foo() {
8+
| ----- recursive call site
9+
|
10+
= help: a `loop` may express intention better if this is on purpose
11+
= note: `#[warn(unconditional_recursion)]` on by default
12+
13+
error: higher-ranked subtype error
14+
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:15:15
15+
|
16+
LL | match foo() {
17+
| ^^^^^
18+
19+
error: higher-ranked subtype error
20+
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:15:15
21+
|
22+
LL | match foo() {
23+
| ^^^^^
24+
|
25+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
26+
27+
error: higher-ranked subtype error
28+
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:18:13
29+
|
30+
LL | Subtype::Bar => (),
31+
| ^^^^^^^^^^^^
32+
33+
error: higher-ranked subtype error
34+
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:18:13
35+
|
36+
LL | Subtype::Bar => (),
37+
| ^^^^^^^^^^^^
38+
|
39+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
40+
41+
error: aborting due to 4 previous errors; 1 warning emitted
42+

0 commit comments

Comments
 (0)