Skip to content

Commit 3f52f5a

Browse files
Create new Item::is_fake_item method as equivalent to check for is_primitive, is_keyword and is_attribute methods
1 parent a364c16 commit 3f52f5a

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/librustdoc/clean/types.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,17 @@ impl Item {
595595
pub(crate) fn is_attribute(&self) -> bool {
596596
self.type_() == ItemType::Attribute
597597
}
598+
/// Returns `true` if the item kind is one of the following:
599+
///
600+
/// * `ItemType::Primitive`
601+
/// * `ItemType::Keyword`
602+
/// * `ItemType::Attribute`
603+
///
604+
/// They are considered fake because they only exist thanks to their
605+
/// `#[doc(primitive|keyword|attribute)]` attribute.
606+
pub(crate) fn is_fake_item(&self) -> bool {
607+
matches!(self.type_(), ItemType::Primitive | ItemType::Keyword | ItemType::Attribute)
608+
}
598609
pub(crate) fn is_stripped(&self) -> bool {
599610
match self.kind {
600611
StrippedItem(..) => true,

src/librustdoc/html/render/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'tcx> Context<'tcx> {
206206
if !is_module {
207207
title.push_str(it.name.unwrap().as_str());
208208
}
209-
if !it.is_primitive() && !it.is_keyword() && !it.is_attribute() {
209+
if !it.is_fake_item() {
210210
if !is_module {
211211
title.push_str(" in ");
212212
}

src/librustdoc/html/render/print_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item) -> impl fmt::Disp
199199
let src_href =
200200
if cx.info.include_sources && !item.is_primitive() { cx.src_href(item) } else { None };
201201

202-
let path_components = if item.is_primitive() || item.is_keyword() || item.is_attribute() {
202+
let path_components = if item.is_fake_item() {
203203
vec![]
204204
} else {
205205
let cur = &cx.current;

0 commit comments

Comments
 (0)