1
Fork 0

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:
Matthias Krüger 2022-12-20 23:35:17 +01:00 committed by GitHub
commit b68e994503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 17 deletions

View file

@ -400,6 +400,7 @@ impl<'tcx> InternalSubsts<'tcx> {
}
#[inline]
#[track_caller]
pub fn type_at(&self, i: usize) -> Ty<'tcx> {
if let GenericArgKind::Type(ty) = self[i].unpack() {
ty
@ -409,6 +410,7 @@ impl<'tcx> InternalSubsts<'tcx> {
}
#[inline]
#[track_caller]
pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
if let GenericArgKind::Lifetime(lt) = self[i].unpack() {
lt
@ -418,6 +420,7 @@ impl<'tcx> InternalSubsts<'tcx> {
}
#[inline]
#[track_caller]
pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
if let GenericArgKind::Const(ct) = self[i].unpack() {
ct
@ -427,6 +430,7 @@ impl<'tcx> InternalSubsts<'tcx> {
}
#[inline]
#[track_caller]
pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> {
self.type_at(def.index as usize).into()
}