Skip to content

Commit ace4ac0

Browse files
committed
properly use caller-side panic location for some GenericArgs methods
1 parent f63685d commit ace4ac0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

compiler/rustc_middle/src/ty/generic_args.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,21 +536,28 @@ impl<'tcx> GenericArgs<'tcx> {
536536
#[inline]
537537
#[track_caller]
538538
pub fn type_at(&self, i: usize) -> Ty<'tcx> {
539-
self[i].as_type().unwrap_or_else(|| bug!("expected type for param #{} in {:?}", i, self))
539+
self[i].as_type().unwrap_or_else(
540+
#[track_caller]
541+
|| bug!("expected type for param #{} in {:?}", i, self),
542+
)
540543
}
541544

542545
#[inline]
543546
#[track_caller]
544547
pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
545-
self[i]
546-
.as_region()
547-
.unwrap_or_else(|| bug!("expected region for param #{} in {:?}", i, self))
548+
self[i].as_region().unwrap_or_else(
549+
#[track_caller]
550+
|| bug!("expected region for param #{} in {:?}", i, self),
551+
)
548552
}
549553

550554
#[inline]
551555
#[track_caller]
552556
pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
553-
self[i].as_const().unwrap_or_else(|| bug!("expected const for param #{} in {:?}", i, self))
557+
self[i].as_const().unwrap_or_else(
558+
#[track_caller]
559+
|| bug!("expected const for param #{} in {:?}", i, self),
560+
)
554561
}
555562

556563
#[inline]

0 commit comments

Comments
 (0)