Skip to content

Commit 7b773e8

Browse files
committed
Remove closures on expect_local to apply #[track_caller]
1 parent 9a25164 commit 7b773e8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/rustc_span/src/def_id.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ impl DefId {
281281
#[inline]
282282
#[track_caller]
283283
pub fn expect_local(self) -> LocalDefId {
284-
self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self))
284+
// NOTE: `match` below is required to apply `#[track_caller]`,
285+
// i.e. don't use closures.
286+
match self.as_local() {
287+
Some(local_def_id) => local_def_id,
288+
None => panic!("DefId::expect_local: `{:?}` isn't local", self),
289+
}
285290
}
286291

287292
#[inline]

0 commit comments

Comments
 (0)