diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-12-22 01:01:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-22 01:01:12 +0100 |
| commit | 3eccc297d42b09eaecbf05a6846f1d5c9abc0b95 (patch) | |
| tree | 3793cc858cc709090d5ae3b775bb65753316e95b | |
| parent | b569c9dc57ee22b6ff94563af856909763dfa24b (diff) | |
| parent | 4042f550795c042aee3087b0e0dcb7083e7a9e00 (diff) | |
| download | rust-3eccc297d42b09eaecbf05a6846f1d5c9abc0b95.tar.gz rust-3eccc297d42b09eaecbf05a6846f1d5c9abc0b95.zip | |
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
| -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`. |
