Skip to content

Commit

Permalink
Rollup merge of rust-lang#96747 - JohnTitor:expect-local-track-caller…
Browse files Browse the repository at this point in the history
…, r=compiler-errors

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

Suggested in rust-lang#96738 (comment).
`DefId::expect_local()` often causes ICEs (panics) and should be a good candidate to add `track_caller`.
  • Loading branch information
compiler-errors committed May 5, 2022
2 parents 49ab2cf + 2ed38cd commit 176493c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_span/src/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 176493c

Please sign in to comment.