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 93fbd25

Browse files
Create new Item::is_fake_item method as equivalent to check for is_primitive, is_keyword and is_attribute methods
1 parent bb3f6dd commit 93fbd25

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

‎src/librustdoc/html/render/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'tcx> Context<'tcx> {
218218
} else {
219219
it.name.as_ref().unwrap().as_str()
220220
};
221-
if !it.is_primitive() && !it.is_keyword() && !it.is_attribute() {
221+
if !it.is_fake_item() {
222222
if !is_module {
223223
title.push_str(" in ");
224224
}

‎src/librustdoc/html/render/print_item.rs

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

197-
let path_components = if item.is_primitive() || item.is_keyword() || item.is_attribute() {
197+
let path_components = if item.is_fake_item() {
198198
vec![]
199199
} else {
200200
let cur = &cx.current;

0 commit comments

Comments
(0)

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