Skip to content

Commit

Permalink
add test for rust-lang#104779 opaque types, patterns and subtyping IC…
Browse files Browse the repository at this point in the history
…E: IndexMap: key not found

Fixes rust-lang#104779
  • Loading branch information
matthiaskrgr authored and RenjiSann committed Mar 25, 2024
1 parent 6c71e59 commit 2b4ca91
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/ui/borrowck/opaque-types-patterns-subtyping-ice-104779.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// issue: rust-lang/rust#104779
// ICE region infer, IndexMap: key not found

struct Inv<'a>(&'a mut &'a ());
enum Foo<T> {
Bar,
Var(T),
}
type Subtype = Foo<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>;
type Supertype = Foo<for<'a> fn(Inv<'a>, Inv<'a>)>;

fn foo() -> impl Sized {
//~^ WARN function cannot return without recursing
loop {
match foo() {
//~^ ERROR higher-ranked subtype error
//~^^ ERROR higher-ranked subtype error
Subtype::Bar => (),
//~^ ERROR higher-ranked subtype error
//~^^ ERROR higher-ranked subtype error
Supertype::Var(x) => {}
}
}
}

pub fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
warning: function cannot return without recursing
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:12:1
|
LL | fn foo() -> impl Sized {
| ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
...
LL | match foo() {
| ----- recursive call site
|
= help: a `loop` may express intention better if this is on purpose
= note: `#[warn(unconditional_recursion)]` on by default

error: higher-ranked subtype error
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:15:15
|
LL | match foo() {
| ^^^^^

error: higher-ranked subtype error
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:15:15
|
LL | match foo() {
| ^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: higher-ranked subtype error
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:18:13
|
LL | Subtype::Bar => (),
| ^^^^^^^^^^^^

error: higher-ranked subtype error
--> $DIR/opaque-types-patterns-subtyping-ice-104779.rs:18:13
|
LL | Subtype::Bar => (),
| ^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 4 previous errors; 1 warning emitted

0 comments on commit 2b4ca91

Please sign in to comment.