We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
expect_local
#[track_caller]
1 parent 9a25164 commit 7b773e8Copy full SHA for 7b773e8
compiler/rustc_span/src/def_id.rs
@@ -281,7 +281,12 @@ impl DefId {
281
#[inline]
282
283
pub fn expect_local(self) -> LocalDefId {
284
- self.as_local().unwrap_or_else(|| panic!("DefId::expect_local: `{:?}` isn't local", self))
+ // 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
+ }
290
}
291
292
0 commit comments