properly use caller-side panic location for some GenericArgs methods

This commit is contained in:
Ralf Jung 2025-07-19 22:38:57 +02:00
parent a7a1618e6c
commit efcae7d31d

View file

@ -536,21 +536,28 @@ impl<'tcx> GenericArgs<'tcx> {
#[inline]
#[track_caller]
pub fn type_at(&self, i: usize) -> Ty<'tcx> {
self[i].as_type().unwrap_or_else(|| bug!("expected type for param #{} in {:?}", i, self))
self[i].as_type().unwrap_or_else(
#[track_caller]
|| bug!("expected type for param #{} in {:?}", i, self),
)
}
#[inline]
#[track_caller]
pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
self[i]
.as_region()
.unwrap_or_else(|| bug!("expected region for param #{} in {:?}", i, self))
self[i].as_region().unwrap_or_else(
#[track_caller]
|| bug!("expected region for param #{} in {:?}", i, self),
)
}
#[inline]
#[track_caller]
pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
self[i].as_const().unwrap_or_else(|| bug!("expected const for param #{} in {:?}", i, self))
self[i].as_const().unwrap_or_else(
#[track_caller]
|| bug!("expected const for param #{} in {:?}", i, self),
)
}
#[inline]