Skip to content

Commit

Permalink
Rollup merge of rust-lang#73098 - jyn514:rustdoc-is-fake, r=Guillaume…
Browse files Browse the repository at this point in the history
…Gomez

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.
  • Loading branch information
Dylan-DPC authored Jun 9, 2020
2 parents fc44861 + 1f11331 commit a57e823
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ pub struct Item {

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

fmt.debug_struct("Item")
Expand Down Expand Up @@ -238,6 +236,13 @@ impl Item {
_ => false,
}
}

/// See comments on next_def_id
pub fn is_fake(&self) -> bool {
MAX_DEF_ID.with(|m| {
m.borrow().get(&self.def_id.krate).map(|id| self.def_id >= *id).unwrap_or(false)
})
}
}

#[derive(Clone, Debug)]
Expand Down

0 comments on commit a57e823

Please sign in to comment.