Skip to content

Commit

Permalink
Remove closures on expect_local to apply #[track_caller]
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed May 6, 2022
1 parent 9a25164 commit 7b773e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_span/src/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,12 @@ impl DefId {
#[inline]
#[track_caller]
pub fn expect_local(self) -> LocalDefId {
self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self))
// NOTE: `match` below is required to apply `#[track_caller]`,
// i.e. don't use closures.
match self.as_local() {
Some(local_def_id) => local_def_id,
None => panic!("DefId::expect_local: `{:?}` isn't local", self),
}
}

#[inline]
Expand Down

0 comments on commit 7b773e8

Please sign in to comment.