Skip to content

Commit 21df410

Browse files
authored
Rollup merge of rust-lang#78121 - LeSeulArtichaut:issue-78115, r=tmandry
Do not ICE on pattern that uses a binding multiple times in generator Fixes rust-lang#78115. r? @tmandry
2 parents 3f1c637 + 334c6c5 commit 21df410

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

compiler/rustc_typeck/src/check/generator_interior.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'tcx> {
250250
let mut scope_var_ids =
251251
self.guard_bindings.pop().expect("should have pushed at least one earlier");
252252
for var_id in scope_var_ids.drain(..) {
253-
assert!(
254-
self.guard_bindings_set.remove(&var_id),
255-
"variable should be placed in scope earlier"
256-
);
253+
self.guard_bindings_set.remove(&var_id);
257254
}
258255
}
259256
self.visit_expr(body);

src/test/ui/issues/issue-78115.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Regression test for issue #78115: "ICE: variable should be placed in scope earlier"
2+
3+
// check-pass
4+
// edition:2018
5+
6+
#[allow(dead_code)]
7+
struct Foo {
8+
a: ()
9+
}
10+
11+
async fn _bar() {
12+
let foo = Foo { a: () };
13+
match foo {
14+
Foo { a: _a } | Foo { a: _a } if true => {}
15+
_ => {}
16+
}
17+
}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)