use track_caller to show where the panic is actually from

This commit is contained in:
Oli Scherer 2022-11-30 11:09:22 +00:00
parent 8a746f4ac3
commit f1ef038ae4

View File

@ -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()
} }