Skip to content

Commit 18d1cf4

Browse files
committed
track caller
Add `#[track_caller]` to some functions which can panic b/c of the caller's wrong index (this helped me debug some mistakes I did while refactoring `ty::Alias`)
1 parent 791e28f commit 18d1cf4

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

compiler/rustc_middle/src/ty/generic_args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ impl<'tcx> rustc_type_ir::inherent::GenericArgs<TyCtxt<'tcx>> for ty::GenericArg
5050
self.rebase_onto(tcx, source_ancestor, target_args)
5151
}
5252

53+
#[track_caller]
5354
fn type_at(self, i: usize) -> Ty<'tcx> {
5455
self.type_at(i)
5556
}
5657

58+
#[track_caller]
5759
fn region_at(self, i: usize) -> ty::Region<'tcx> {
5860
self.region_at(i)
5961
}
6062

63+
#[track_caller]
6164
fn const_at(self, i: usize) -> ty::Const<'tcx> {
6265
self.const_at(i)
6366
}

compiler/rustc_type_ir/src/ty_kind.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ impl<I: Interner> AliasTy<I> {
489489

490490
/// The following methods work only with (trait) associated type projections.
491491
impl<I: Interner> AliasTy<I> {
492+
#[track_caller]
492493
pub fn self_ty(self) -> I::Ty {
493494
self.args.type_at(0)
494495
}

0 commit comments

Comments
 (0)