1
Fork 0

Remove closures on expect_local to apply #[track_caller]

This commit is contained in:
Yuki Okushi 2022-05-07 01:11:32 +09:00
parent 9a251644fa
commit 7b773e890e
No known key found for this signature in database
GPG key ID: 379CEEFDD63E5DD7

View file

@ -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]