Skip to content

Commit 1c5b53b

Browse files
committedDec 20, 2022
Avoid going through the happy path in case of non-fn builtin calls
1 parent f1ef038 commit 1c5b53b

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed
 

‎compiler/rustc_hir_typeck/src/callee.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{Expectation, FnCtxt, TupleArgumentsFlag};
44

55
use crate::type_error_struct;
66
use rustc_ast::util::parser::PREC_POSTFIX;
7-
use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey};
7+
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, StashKey};
88
use rustc_hir as hir;
99
use rustc_hir::def::{self, CtorKind, Namespace, Res};
1010
use rustc_hir::def_id::DefId;
@@ -424,21 +424,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424424
}
425425
}
426426

427-
self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
428-
429-
// This is the "default" function signature, used in case of error.
430-
// In that case, we check each argument against "error" in order to
431-
// set up all the node type bindings.
432-
(
433-
ty::Binder::dummy(self.tcx.mk_fn_sig(
434-
self.err_args(arg_exprs.len()).into_iter(),
435-
self.tcx.ty_error(),
436-
false,
437-
hir::Unsafety::Normal,
438-
abi::Abi::Rust,
439-
)),
440-
None,
441-
)
427+
let err = self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
428+
429+
return self.tcx.ty_error_with_guaranteed(err);
442430
}
443431
};
444432

@@ -591,7 +579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
591579
callee_expr: &'tcx hir::Expr<'tcx>,
592580
callee_ty: Ty<'tcx>,
593581
arg_exprs: &'tcx [hir::Expr<'tcx>],
594-
) {
582+
) -> ErrorGuaranteed {
595583
let mut unit_variant = None;
596584
if let hir::ExprKind::Path(qpath) = &callee_expr.kind
597585
&& let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
@@ -720,7 +708,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
720708
err.span_label(span, label);
721709
}
722710
}
723-
err.emit();
711+
err.emit()
724712
}
725713

726714
fn confirm_deferred_closure_call(

0 commit comments

Comments
 (0)
Please sign in to comment.