about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-06-02 11:13:21 +0200
committerGitHub <noreply@github.com>2022-06-02 11:13:21 +0200
commitddc5d2c9d2c0d100707666d5f2168ccc0dab40ed (patch)
tree9c98ef8da4bebc5523f390519c4dedb6b4d2af79
parentfb1976011e3df96b5d3eccd6b2f4e51ef7dc8f16 (diff)
parentc7db4b08fff9591adb2c7a66d5f81ce685655622 (diff)
downloadrust-ddc5d2c9d2c0d100707666d5f2168ccc0dab40ed.tar.gz
rust-ddc5d2c9d2c0d100707666d5f2168ccc0dab40ed.zip
Rollup merge of #96894 - JohnTitor:expect-non-local-track-caller, r=petrochenkov
Apply track_caller to closure on `expect_non_local()`

r? `@petrochenkov`

Alternatively we could remove the closure by replicating the same logic of `map_id()`. I'm happy to switch to it if you'd like.
-rw-r--r--compiler/rustc_hir/src/def.rs5
-rw-r--r--compiler/rustc_hir/src/lib.rs1
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs
index 68876e89c4b..414f6272591 100644
--- a/compiler/rustc_hir/src/def.rs
+++ b/compiler/rustc_hir/src/def.rs
@@ -671,7 +671,10 @@ impl<Id> Res<Id> {
 
     #[track_caller]
     pub fn expect_non_local<OtherId>(self) -> Res<OtherId> {
-        self.map_id(|_| panic!("unexpected `Res::Local`"))
+        self.map_id(
+            #[track_caller]
+            |_| panic!("unexpected `Res::Local`"),
+        )
     }
 
     pub fn macro_kind(self) -> Option<MacroKind> {
diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs
index 7833571f88d..d845c433d8c 100644
--- a/compiler/rustc_hir/src/lib.rs
+++ b/compiler/rustc_hir/src/lib.rs
@@ -3,6 +3,7 @@
 //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
 
 #![feature(associated_type_defaults)]
+#![feature(closure_track_caller)]
 #![feature(const_btree_new)]
 #![feature(let_else)]
 #![feature(once_cell)]