diff options
| author | Michael Goulet <michael@errs.io> | 2022-12-17 19:20:29 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-12-17 19:20:29 +0000 |
| commit | 4042f550795c042aee3087b0e0dcb7083e7a9e00 (patch) | |
| tree | 2b68ec108ef4d12f9c45e76f4ff902115f58b165 | |
| parent | 984eab57f708e62c09b3d708033fe620130b5f39 (diff) | |
| download | rust-4042f550795c042aee3087b0e0dcb7083e7a9e00.tar.gz rust-4042f550795c042aee3087b0e0dcb7083e7a9e00.zip | |
Don't ICE in check_must_not_suspend_ty for mismatched tuple arity
| -rw-r--r-- | compiler/rustc_hir_typeck/src/generator_interior/mod.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/lint/must_not_suspend/tuple-mismatch.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/lint/must_not_suspend/tuple-mismatch.stderr | 12 |
3 files changed, 22 insertions, 4 deletions
diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index 93f2ceed777..e4ac91befac 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -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() { diff --git a/src/test/ui/lint/must_not_suspend/tuple-mismatch.rs b/src/test/ui/lint/must_not_suspend/tuple-mismatch.rs new file mode 100644 index 00000000000..c7e14e42561 --- /dev/null +++ b/src/test/ui/lint/must_not_suspend/tuple-mismatch.rs @@ -0,0 +1,9 @@ +#![feature(generators)] + +fn main() { + let _generator = || { + yield ((), ((), ())); + yield ((), ()); + //~^ ERROR mismatched types + }; +} diff --git a/src/test/ui/lint/must_not_suspend/tuple-mismatch.stderr b/src/test/ui/lint/must_not_suspend/tuple-mismatch.stderr new file mode 100644 index 00000000000..cca8cd9bd89 --- /dev/null +++ b/src/test/ui/lint/must_not_suspend/tuple-mismatch.stderr @@ -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`. |
