Don't ICE in check_must_not_suspend_ty for mismatched tuple arity

This commit is contained in:
Michael Goulet 2022-12-17 19:20:29 +00:00
parent 984eab57f7
commit 4042f55079
3 changed files with 22 additions and 4 deletions

View File

@ -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() {

View File

@ -0,0 +1,9 @@
#![feature(generators)]
fn main() {
let _generator = || {
yield ((), ((), ()));
yield ((), ());
//~^ ERROR mismatched types
};
}

View File

@ -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`.