about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-07-19 22:38:57 +0200
committerRalf Jung <post@ralfj.de>2025-07-23 08:32:55 +0200
commitefcae7d31d30ba8d8c806fbb8dea634e78d7b969 (patch)
tree052ed743cf47cc08f82146d840b3b61854a252e4
parenta7a1618e6c835f1f00940ad72203d05808209a0d (diff)
downloadrust-efcae7d31d30ba8d8c806fbb8dea634e78d7b969.tar.gz
rust-efcae7d31d30ba8d8c806fbb8dea634e78d7b969.zip
properly use caller-side panic location for some GenericArgs methods
-rw-r--r--compiler/rustc_middle/src/ty/generic_args.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs
index 7d34d8df3f3..a5fd4d7a262 100644
--- a/compiler/rustc_middle/src/ty/generic_args.rs
+++ b/compiler/rustc_middle/src/ty/generic_args.rs
@@ -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]