Skip to content

Commit b8f453f

Browse files
authored
Rollup merge of #73098 - jyn514:rustdoc-is-fake, r=GuillaumeGomez
Add Item::is_fake for rustdoc I wasn't aware items _could_ be fake, so I think having a function mentioning it could be helpful. Also, I'd need to make this change for cross-crate intra-doc links anyway, so I figured it's better to make the refactor separate.
2 parents eb31879 + 1f11331 commit b8f453f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustdoc/clean/types.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ pub struct Item {
8585

8686
impl fmt::Debug for Item {
8787
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
88-
let fake = MAX_DEF_ID.with(|m| {
89-
m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false)
90-
});
88+
let fake = self.is_fake();
9189
let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
9290

9391
fmt.debug_struct("Item")
@@ -238,6 +236,13 @@ impl Item {
238236
_ => false,
239237
}
240238
}
239+
240+
/// See comments on next_def_id
241+
pub fn is_fake(&self) -> bool {
242+
MAX_DEF_ID.with(|m| {
243+
m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false)
244+
})
245+
}
241246
}
242247

243248
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)