Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 10c8903

Browse files
Create new Item::is_fake_item method as equivalent to check for is_primitive, is_keyword and is_attribute methods
1 parent 477cdc9 commit 10c8903

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
@@ -611,6 +611,17 @@ impl Item {
611611
pub(crate) fn is_attribute(&self) -> bool {
612612
self.type_() == ItemType::Attribute
613613
}
614+
/// Returns `true` if the item kind is one of the following:
615+
///
616+
/// * `ItemType::Primitive`
617+
/// * `ItemType::Keyword`
618+
/// * `ItemType::Attribute`
619+
///
620+
/// They are considered fake because they only exist thanks to their
621+
/// `#[doc(primitive|keyword|attribute)]` attribute.
622+
pub(crate) fn is_fake_item(&self) -> bool {
623+
matches!(self.type_(), ItemType::Primitive | ItemType::Keyword | ItemType::Attribute)
624+
}
614625
pub(crate) fn is_stripped(&self) -> bool {
615626
match self.kind {
616627
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)

AltStyle によって変換されたページ (->オリジナル) /