diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-05-25 14:01:06 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-05-25 14:01:06 +0000 |
| commit | 6ba8da6aae5c0422b022b248799eb42244fae468 (patch) | |
| tree | 7dbbab8c9a3387bf6e81c54e796131c0aa72ae2a | |
| parent | 46a23420b6c2134b9f023898e22b9868d3bc664e (diff) | |
| download | rust-6ba8da6aae5c0422b022b248799eb42244fae468.tar.gz rust-6ba8da6aae5c0422b022b248799eb42244fae468.zip | |
Fall through to check other arguments instead of bailing out on the first error
| -rw-r--r-- | compiler/rustc_typeck/src/check/expr.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/intrinsicck.rs | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index da8eb390b8f..ea81f1ef90c 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -296,6 +296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } ExprKind::Path(ref qpath) => self.check_expr_path(qpath, expr, &[]), ExprKind::InlineAsm(asm) => { + // We defer some asm checks as we may not have resolved the input and output types yet (they may still be infer vars). self.deferred_asm_checks.borrow_mut().push((asm, expr.hir_id)); self.check_expr_asm(asm) } @@ -539,6 +540,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if tcx.fn_sig(did).abi() == RustIntrinsic && tcx.item_name(did) == sym::transmute { let from = fn_sig.inputs().skip_binder()[0]; let to = fn_sig.output().skip_binder(); + // We defer the transmute to the end of typeck, once all inference vars have + // been resolved or we errored. This is important as we can only check transmute + // on concrete types, but the output type may not be known yet (it would only + // be known if explicitly specified via turbofish). self.deferred_transmute_checks.borrow_mut().push((from, to, expr.span)); } if !tcx.features().unsized_fn_params { diff --git a/compiler/rustc_typeck/src/check/intrinsicck.rs b/compiler/rustc_typeck/src/check/intrinsicck.rs index 9845e8d1f00..027868be8bb 100644 --- a/compiler/rustc_typeck/src/check/intrinsicck.rs +++ b/compiler/rustc_typeck/src/check/intrinsicck.rs @@ -361,7 +361,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // target. Reject those here. if let InlineAsmRegOrRegClass::Reg(reg) = reg { if let InlineAsmReg::Err = reg { - return; + // `validate` will panic on `Err`, as an error must + // already have been reported. + continue; } if let Err(msg) = reg.validate( asm_arch, @@ -380,7 +382,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut missing_required_features = vec![]; let reg_class = reg.reg_class(); if let InlineAsmRegClass::Err = reg_class { - return; + continue; } for &(_, feature) in reg_class.supported_types(asm_arch) { match feature { |
