Rollup merge of #96747 - JohnTitor:expect-local-track-caller, r=compiler-errors

Add `track_caller` to `DefId::expect_local()`

Suggested in https://github.com/rust-lang/rust/issues/96738#issuecomment-1118961888.
`DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.
This commit is contained in:
Michael Goulet 2022-05-05 19:34:27 -07:00 committed by GitHub
commit b8c829b64f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,6 +279,7 @@ 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))
}