diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-06-10 01:06:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-10 01:06:25 +0200 |
| commit | cbfdff7a6b3f39632b72934d3e3bdaf6fbf70578 (patch) | |
| tree | 6dcd467b03e5a035addfe6746bd8f4a79794d392 | |
| parent | 860e6bdd2fffbc98e67851eaaec87fb430bdd16b (diff) | |
| parent | 1f11331894cb7543211660f4a9282755ac7c4ac7 (diff) | |
| download | rust-cbfdff7a6b3f39632b72934d3e3bdaf6fbf70578.tar.gz rust-cbfdff7a6b3f39632b72934d3e3bdaf6fbf70578.zip | |
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.
| -rw-r--r-- | src/librustdoc/clean/types.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 38123816527..5c76c840b1d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -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") @@ -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)] |
