diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-20 18:59:52 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-20 18:59:52 +0000 |
| commit | 1c5b53be1c5ea2f95b1b3e4327c69f14127a923c (patch) | |
| tree | 3f76c224e03ba4cc5948941dfad1842d5a188cdb | |
| parent | f1ef038ae401d8ee7611b2f9fb2aec3af4e9241f (diff) | |
| download | rust-1c5b53be1c5ea2f95b1b3e4327c69f14127a923c.tar.gz rust-1c5b53be1c5ea2f95b1b3e4327c69f14127a923c.zip | |
Avoid going through the happy path in case of non-fn builtin calls
| -rw-r--r-- | compiler/rustc_hir_typeck/src/callee.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 7a5191b77f1..4ec71a78a00 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -4,7 +4,7 @@ use super::{Expectation, FnCtxt, TupleArgumentsFlag}; use crate::type_error_struct; use rustc_ast::util::parser::PREC_POSTFIX; -use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey}; +use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, StashKey}; use rustc_hir as hir; use rustc_hir::def::{self, CtorKind, Namespace, Res}; use rustc_hir::def_id::DefId; @@ -424,21 +424,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs); - - // This is the "default" function signature, used in case of error. - // In that case, we check each argument against "error" in order to - // set up all the node type bindings. - ( - ty::Binder::dummy(self.tcx.mk_fn_sig( - self.err_args(arg_exprs.len()).into_iter(), - self.tcx.ty_error(), - false, - hir::Unsafety::Normal, - abi::Abi::Rust, - )), - None, - ) + let err = self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs); + + return self.tcx.ty_error_with_guaranteed(err); } }; @@ -591,7 +579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { callee_expr: &'tcx hir::Expr<'tcx>, callee_ty: Ty<'tcx>, arg_exprs: &'tcx [hir::Expr<'tcx>], - ) { + ) -> ErrorGuaranteed { let mut unit_variant = None; if let hir::ExprKind::Path(qpath) = &callee_expr.kind && let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _) @@ -720,7 +708,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label(span, label); } } - err.emit(); + err.emit() } fn confirm_deferred_closure_call( |
