Rollup merge of #105973 - oli-obk:simplify_callee_checks, r=jackh726
Avoid going through the happy path in case of non-fn builtin calls No functional change, just doing an early return. The removed comment is not applicable anymore, not every node needs type bindings in the error case. At best this would have been needed to avoid ICEs, but afaict this can't happen anymore today, as we do fallible checks.
This commit is contained in:
commit
b68e994503
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use crate::type_error_struct;
|
use crate::type_error_struct;
|
||||||
use rustc_ast::util::parser::PREC_POSTFIX;
|
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 as hir;
|
||||||
use rustc_hir::def::{self, CtorKind, Namespace, Res};
|
use rustc_hir::def::{self, CtorKind, Namespace, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
@ -424,21 +424,9 @@ fn confirm_builtin_call(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
|
let err = self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
|
||||||
|
|
||||||
// This is the "default" function signature, used in case of error.
|
return self.tcx.ty_error_with_guaranteed(err);
|
||||||
// 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,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -591,7 +579,7 @@ fn report_invalid_callee(
|
|||||||
callee_expr: &'tcx hir::Expr<'tcx>,
|
callee_expr: &'tcx hir::Expr<'tcx>,
|
||||||
callee_ty: Ty<'tcx>,
|
callee_ty: Ty<'tcx>,
|
||||||
arg_exprs: &'tcx [hir::Expr<'tcx>],
|
arg_exprs: &'tcx [hir::Expr<'tcx>],
|
||||||
) {
|
) -> ErrorGuaranteed {
|
||||||
let mut unit_variant = None;
|
let mut unit_variant = None;
|
||||||
if let hir::ExprKind::Path(qpath) = &callee_expr.kind
|
if let hir::ExprKind::Path(qpath) = &callee_expr.kind
|
||||||
&& let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
|
&& let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
|
||||||
@ -720,7 +708,7 @@ fn report_invalid_callee(
|
|||||||
err.span_label(span, label);
|
err.span_label(span, label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err.emit();
|
err.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn confirm_deferred_closure_call(
|
fn confirm_deferred_closure_call(
|
||||||
|
@ -400,6 +400,7 @@ pub fn non_erasable_generics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[track_caller]
|
||||||
pub fn type_at(&self, i: usize) -> Ty<'tcx> {
|
pub fn type_at(&self, i: usize) -> Ty<'tcx> {
|
||||||
if let GenericArgKind::Type(ty) = self[i].unpack() {
|
if let GenericArgKind::Type(ty) = self[i].unpack() {
|
||||||
ty
|
ty
|
||||||
@ -409,6 +410,7 @@ pub fn type_at(&self, i: usize) -> Ty<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[track_caller]
|
||||||
pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
|
pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
|
||||||
if let GenericArgKind::Lifetime(lt) = self[i].unpack() {
|
if let GenericArgKind::Lifetime(lt) = self[i].unpack() {
|
||||||
lt
|
lt
|
||||||
@ -418,6 +420,7 @@ pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[track_caller]
|
||||||
pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
|
pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
|
||||||
if let GenericArgKind::Const(ct) = self[i].unpack() {
|
if let GenericArgKind::Const(ct) = self[i].unpack() {
|
||||||
ct
|
ct
|
||||||
@ -427,6 +430,7 @@ pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[track_caller]
|
||||||
pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> {
|
pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> {
|
||||||
self.type_at(def.index as usize).into()
|
self.type_at(def.index as usize).into()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user