1
Fork 0

Remove unused field in ItemKind::KeywordItem

This commit is contained in:
Guillaume Gomez 2022-07-21 16:05:17 +02:00
parent d60d88fe5c
commit 8e150816c2
10 changed files with 14 additions and 15 deletions

View file

@ -496,8 +496,7 @@ impl Item {
// Primitives and Keywords are written in the source code as private modules. // Primitives and Keywords are written in the source code as private modules.
// The modules need to be private so that nobody actually uses them, but the // The modules need to be private so that nobody actually uses them, but the
// keywords and primitives that they are documenting are public. // keywords and primitives that they are documenting are public.
let visibility = if matches!(&kind, ItemKind::KeywordItem(..) | ItemKind::PrimitiveItem(..)) let visibility = if matches!(&kind, ItemKind::KeywordItem | ItemKind::PrimitiveItem(..)) {
{
Visibility::Public Visibility::Public
} else { } else {
cx.tcx.visibility(def_id).clean(cx) cx.tcx.visibility(def_id).clean(cx)
@ -769,7 +768,7 @@ pub(crate) enum ItemKind {
AssocTypeItem(Typedef, Vec<GenericBound>), AssocTypeItem(Typedef, Vec<GenericBound>),
/// An item that has been stripped by a rustdoc pass /// An item that has been stripped by a rustdoc pass
StrippedItem(Box<ItemKind>), StrippedItem(Box<ItemKind>),
KeywordItem(Symbol), KeywordItem,
} }
impl ItemKind { impl ItemKind {
@ -808,7 +807,7 @@ impl ItemKind {
| TyAssocTypeItem(..) | TyAssocTypeItem(..)
| AssocTypeItem(..) | AssocTypeItem(..)
| StrippedItem(_) | StrippedItem(_)
| KeywordItem(_) => [].iter(), | KeywordItem => [].iter(),
} }
} }
} }

View file

@ -69,7 +69,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
) )
})); }));
m.items.extend(keywords.into_iter().map(|(def_id, kw)| { m.items.extend(keywords.into_iter().map(|(def_id, kw)| {
Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem(kw), cx) Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem, cx)
})); }));
} }

View file

@ -69,7 +69,7 @@ pub(crate) trait DocFolder: Sized {
| AssocConstItem(..) | AssocConstItem(..)
| TyAssocTypeItem(..) | TyAssocTypeItem(..)
| AssocTypeItem(..) | AssocTypeItem(..)
| KeywordItem(_) => kind, | KeywordItem => kind,
} }
} }

View file

@ -413,7 +413,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
| clean::TyAssocTypeItem(..) | clean::TyAssocTypeItem(..)
| clean::AssocTypeItem(..) | clean::AssocTypeItem(..)
| clean::StrippedItem(..) | clean::StrippedItem(..)
| clean::KeywordItem(..) => { | clean::KeywordItem => {
// FIXME: Do these need handling? // FIXME: Do these need handling?
// The person writing this comment doesn't know. // The person writing this comment doesn't know.
// So would rather leave them to an expert, // So would rather leave them to an expert,

View file

@ -91,7 +91,7 @@ impl<'a> From<&'a clean::Item> for ItemType {
clean::TyAssocConstItem(..) | clean::AssocConstItem(..) => ItemType::AssocConst, clean::TyAssocConstItem(..) | clean::AssocConstItem(..) => ItemType::AssocConst,
clean::TyAssocTypeItem(..) | clean::AssocTypeItem(..) => ItemType::AssocType, clean::TyAssocTypeItem(..) | clean::AssocTypeItem(..) => ItemType::AssocType,
clean::ForeignTypeItem => ItemType::ForeignType, clean::ForeignTypeItem => ItemType::ForeignType,
clean::KeywordItem(..) => ItemType::Keyword, clean::KeywordItem => ItemType::Keyword,
clean::TraitAliasItem(..) => ItemType::TraitAlias, clean::TraitAliasItem(..) => ItemType::TraitAlias,
clean::ProcMacroItem(ref mac) => match mac.kind { clean::ProcMacroItem(ref mac) => match mac.kind {
MacroKind::Bang => ItemType::Macro, MacroKind::Bang => ItemType::Macro,

View file

@ -104,7 +104,7 @@ pub(super) fn print_item(
clean::StaticItem(..) | clean::ForeignStaticItem(..) => "Static ", clean::StaticItem(..) | clean::ForeignStaticItem(..) => "Static ",
clean::ConstantItem(..) => "Constant ", clean::ConstantItem(..) => "Constant ",
clean::ForeignTypeItem => "Foreign Type ", clean::ForeignTypeItem => "Foreign Type ",
clean::KeywordItem(..) => "Keyword ", clean::KeywordItem => "Keyword ",
clean::OpaqueTyItem(..) => "Opaque Type ", clean::OpaqueTyItem(..) => "Opaque Type ",
clean::TraitAliasItem(..) => "Trait Alias ", clean::TraitAliasItem(..) => "Trait Alias ",
_ => { _ => {
@ -175,7 +175,7 @@ pub(super) fn print_item(
clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) => item_static(buf, cx, item, i), clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) => item_static(buf, cx, item, i),
clean::ConstantItem(ref c) => item_constant(buf, cx, item, c), clean::ConstantItem(ref c) => item_constant(buf, cx, item, c),
clean::ForeignTypeItem => item_foreign_type(buf, cx, item), clean::ForeignTypeItem => item_foreign_type(buf, cx, item),
clean::KeywordItem(_) => item_keyword(buf, cx, item), clean::KeywordItem => item_keyword(buf, cx, item),
clean::OpaqueTyItem(ref e) => item_opaque_ty(buf, cx, item, e), clean::OpaqueTyItem(ref e) => item_opaque_ty(buf, cx, item, e),
clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta), clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta),
_ => { _ => {

View file

@ -43,7 +43,7 @@ impl JsonRenderer<'_> {
let span = item.span(self.tcx); let span = item.span(self.tcx);
let clean::Item { name, attrs: _, kind: _, visibility, item_id, cfg: _ } = item; let clean::Item { name, attrs: _, kind: _, visibility, item_id, cfg: _ } = item;
let inner = match *item.kind { let inner = match *item.kind {
clean::KeywordItem(_) => return None, clean::KeywordItem => return None,
clean::StrippedItem(ref inner) => { clean::StrippedItem(ref inner) => {
match &**inner { match &**inner {
// We document non-empty stripped modules as with `Module::is_stripped` set to // We document non-empty stripped modules as with `Module::is_stripped` set to
@ -269,7 +269,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
default: Some(t.item_type.unwrap_or(t.type_).into_tcx(tcx)), default: Some(t.item_type.unwrap_or(t.type_).into_tcx(tcx)),
}, },
// `convert_item` early returns `None` for stripped items and keywords. // `convert_item` early returns `None` for stripped items and keywords.
KeywordItem(_) => unreachable!(), KeywordItem => unreachable!(),
StrippedItem(inner) => { StrippedItem(inner) => {
match *inner { match *inner {
ModuleItem(m) => ItemEnum::Module(Module { ModuleItem(m) => ItemEnum::Module(Module {

View file

@ -69,7 +69,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
| clean::ExternCrateItem { .. } | clean::ExternCrateItem { .. }
| clean::ImportItem(_) | clean::ImportItem(_)
| clean::PrimitiveItem(_) | clean::PrimitiveItem(_)
| clean::KeywordItem(_) | clean::KeywordItem
// check for trait impl // check for trait impl
| clean::ImplItem(clean::Impl { trait_: Some(_), .. }) | clean::ImplItem(clean::Impl { trait_: Some(_), .. })
) )

View file

@ -98,7 +98,7 @@ impl<'a> DocFolder for Stripper<'a> {
clean::PrimitiveItem(..) => {} clean::PrimitiveItem(..) => {}
// Keywords are never stripped // Keywords are never stripped
clean::KeywordItem(..) => {} clean::KeywordItem => {}
} }
let fastreturn = match *i.kind { let fastreturn = match *i.kind {

View file

@ -43,7 +43,7 @@ pub(crate) trait DocVisitor: Sized {
| AssocConstItem(..) | AssocConstItem(..)
| TyAssocTypeItem(..) | TyAssocTypeItem(..)
| AssocTypeItem(..) | AssocTypeItem(..)
| KeywordItem(_) => {} | KeywordItem => {}
} }
} }