]> git.lizzy.rs Git - rust.git/commitdiff
Add `#[track_caller]` to `FakeDefId::expect_real()`
authorCamelid <camelidcamel@gmail.com>
Sat, 8 May 2021 22:14:21 +0000 (15:14 -0700)
committerCamelid <camelidcamel@gmail.com>
Sat, 8 May 2021 22:35:44 +0000 (15:35 -0700)
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.

src/librustdoc/clean/types.rs

index 550df203a9fee704c10bd293844aa03b87fa5401..33aa42b137a23bdeaa025502285ca26f3fdebb28 100644 (file)
@@ -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))
     }