Skip to content

Commit

Permalink
Add #[track_caller] to FakeDefId::expect_real()
Browse files Browse the repository at this point in the history
Now, in the case that the function is not inlined, the panic location
will be the caller's location, which is more helpful since the panic is
not `expect_real()`'s fault.
  • Loading branch information
camelid committed May 8, 2021
1 parent ba13225 commit 4b7c8b0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/librustdoc/clean/types.rs
Expand Up @@ -86,6 +86,7 @@ impl FakeDefId {
}

#[inline]
#[track_caller]
crate fn expect_real(self) -> rustc_hir::def_id::DefId {
self.as_real().unwrap_or_else(|| panic!("FakeDefId::expect_real: `{:?}` isn't real", self))
}
Expand Down

0 comments on commit 4b7c8b0

Please sign in to comment.