Skip to content

Commit

Permalink
Don't ICE in check_must_not_suspend_ty for mismatched tuple arity
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Dec 17, 2022
1 parent 984eab5 commit 4042f55
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 1 addition & 4 deletions compiler/rustc_hir_typeck/src/generator_interior/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,7 @@ fn check_must_not_suspend_ty<'tcx>(
ty::Tuple(fields) => {
let mut has_emitted = false;
let comps = match data.expr.map(|e| &e.kind) {
Some(hir::ExprKind::Tup(comps)) => {
debug_assert_eq!(comps.len(), fields.len());
Some(comps)
}
Some(hir::ExprKind::Tup(comps)) if comps.len() == fields.len() => Some(comps),
_ => None,
};
for (i, ty) in fields.iter().enumerate() {
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/lint/must_not_suspend/tuple-mismatch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(generators)]

fn main() {
let _generator = || {
yield ((), ((), ()));
yield ((), ());
//~^ ERROR mismatched types
};
}
12 changes: 12 additions & 0 deletions src/test/ui/lint/must_not_suspend/tuple-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/tuple-mismatch.rs:6:20
|
LL | yield ((), ());
| ^^ expected tuple, found `()`
|
= note: expected tuple `((), ())`
found unit type `()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 4042f55

Please sign in to comment.