Rollup merge of #105837 - compiler-errors:issue-105728, r=estebank

Don't ICE in `check_must_not_suspend_ty` for mismatched tuple arity

These expressions are just used for their spans, so make it best-effort here.

Fixes #105728
This commit is contained in:
Matthias Krüger 2022-12-22 01:01:12 +01:00 committed by GitHub
commit 3eccc297d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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`.