Skip to content

Commit 3eccc29

Browse files
authored
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
2 parents b569c9d + 4042f55 commit 3eccc29

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

compiler/rustc_hir_typeck/src/generator_interior/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,7 @@ fn check_must_not_suspend_ty<'tcx>(
607607
ty::Tuple(fields) => {
608608
let mut has_emitted = false;
609609
let comps = match data.expr.map(|e| &e.kind) {
610-
Some(hir::ExprKind::Tup(comps)) => {
611-
debug_assert_eq!(comps.len(), fields.len());
612-
Some(comps)
613-
}
610+
Some(hir::ExprKind::Tup(comps)) if comps.len() == fields.len() => Some(comps),
614611
_ => None,
615612
};
616613
for (i, ty) in fields.iter().enumerate() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(generators)]
2+
3+
fn main() {
4+
let _generator = || {
5+
yield ((), ((), ()));
6+
yield ((), ());
7+
//~^ ERROR mismatched types
8+
};
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/tuple-mismatch.rs:6:20
3+
|
4+
LL | yield ((), ());
5+
| ^^ expected tuple, found `()`
6+
|
7+
= note: expected tuple `((), ())`
8+
found unit type `()`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)