mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Rollup merge of #79041 - jyn514:inner-to-kind, r=petrochenkov
Rename clean::{ItemEnum -> ItemKind}, clean::Item::{inner -> kind} r? ````@petrochenkov```` cc ````@GuillaumeGomez```` Follow-up to https://github.com/rust-lang/rust/pull/77820#discussion_r502931757.
This commit is contained in:
commit
bc9ef6cf72
@ -125,7 +125,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
def_id: self.cx.next_def_id(param_env_def_id.krate),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: ImplItem(Impl {
|
||||
kind: ImplItem(Impl {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics: new_generics,
|
||||
provided_trait_methods: Default::default(),
|
||||
|
@ -114,7 +114,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||
def_id: self.cx.next_def_id(impl_def_id.krate),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: ImplItem(Impl {
|
||||
kind: ImplItem(Impl {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics: (
|
||||
self.cx.tcx.generics_of(impl_def_id),
|
||||
|
@ -54,7 +54,7 @@ crate fn try_inline(
|
||||
debug!("attrs={:?}", attrs);
|
||||
let attrs_clone = attrs;
|
||||
|
||||
let inner = match res {
|
||||
let kind = match res {
|
||||
Res::Def(DefKind::Trait, did) => {
|
||||
record_extern_fqn(cx, did, clean::TypeKind::Trait);
|
||||
ret.extend(build_impls(cx, Some(parent_module), did, attrs));
|
||||
@ -128,7 +128,7 @@ crate fn try_inline(
|
||||
source: cx.tcx.def_span(did).clean(cx),
|
||||
name: Some(name.clean(cx)),
|
||||
attrs,
|
||||
inner,
|
||||
kind,
|
||||
visibility: clean::Public,
|
||||
stability: cx.tcx.lookup_stability(did).cloned(),
|
||||
deprecation: cx.tcx.lookup_deprecation(did).clean(cx),
|
||||
@ -446,7 +446,7 @@ crate fn build_impl(
|
||||
debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id());
|
||||
|
||||
ret.push(clean::Item {
|
||||
inner: clean::ImplItem(clean::Impl {
|
||||
kind: clean::ImplItem(clean::Impl {
|
||||
unsafety: hir::Unsafety::Normal,
|
||||
generics,
|
||||
provided_trait_methods: provided,
|
||||
@ -498,7 +498,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
|
||||
visibility: clean::Public,
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: clean::ImportItem(clean::Import::new_simple(
|
||||
kind: clean::ImportItem(clean::Import::new_simple(
|
||||
item.ident.to_string(),
|
||||
clean::ImportSource {
|
||||
path: clean::Path {
|
||||
@ -555,7 +555,7 @@ fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static
|
||||
}
|
||||
}
|
||||
|
||||
fn build_macro(cx: &DocContext<'_>, did: DefId, name: Symbol) -> clean::ItemEnum {
|
||||
fn build_macro(cx: &DocContext<'_>, did: DefId, name: Symbol) -> clean::ItemKind {
|
||||
let imported_from = cx.tcx.original_crate_name(did.krate);
|
||||
match cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())) {
|
||||
LoadedMacro::MacroDef(def, _) => {
|
||||
|
@ -42,7 +42,7 @@ use utils::*;
|
||||
pub use utils::{get_auto_trait_and_blanket_impls, krate, register_res};
|
||||
|
||||
pub use self::types::FnRetTy::*;
|
||||
pub use self::types::ItemEnum::*;
|
||||
pub use self::types::ItemKind::*;
|
||||
pub use self::types::SelfTy::*;
|
||||
pub use self::types::Type::*;
|
||||
pub use self::types::Visibility::{Inherited, Public};
|
||||
@ -276,7 +276,7 @@ impl Clean<Item> for doctree::Module<'_> {
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
|
||||
inner: ModuleItem(Module { is_crate: self.is_crate, items }),
|
||||
kind: ModuleItem(Module { is_crate: self.is_crate, items }),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -916,7 +916,7 @@ impl Clean<Item> for doctree::Function<'_> {
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: did.to_def_id(),
|
||||
inner: FunctionItem(Function {
|
||||
kind: FunctionItem(Function {
|
||||
decl,
|
||||
generics,
|
||||
header: hir::FnHeader { constness, ..self.header },
|
||||
@ -1023,7 +1023,7 @@ impl Clean<Item> for doctree::Trait<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: TraitItem(Trait {
|
||||
kind: TraitItem(Trait {
|
||||
auto: self.is_auto.clean(cx),
|
||||
unsafety: self.unsafety,
|
||||
items: self.items.iter().map(|ti| ti.clean(cx)).collect(),
|
||||
@ -1047,7 +1047,7 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: TraitAliasItem(TraitAlias {
|
||||
kind: TraitAliasItem(TraitAlias {
|
||||
generics: self.generics.clean(cx),
|
||||
bounds: self.bounds.clean(cx),
|
||||
}),
|
||||
@ -1102,7 +1102,7 @@ impl Clean<TypeKind> for hir::def::DefKind {
|
||||
impl Clean<Item> for hir::TraitItem<'_> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let local_did = cx.tcx.hir().local_def_id(self.hir_id);
|
||||
let inner = match self.kind {
|
||||
let kind = match self.kind {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
AssocConstItem(ty.clean(cx), default.map(|e| print_const_expr(cx, e)))
|
||||
}
|
||||
@ -1140,7 +1140,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
|
||||
visibility: Visibility::Inherited,
|
||||
stability: get_stability(cx, local_did.to_def_id()),
|
||||
deprecation: get_deprecation(cx, local_did.to_def_id()),
|
||||
inner,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1148,7 +1148,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
|
||||
impl Clean<Item> for hir::ImplItem<'_> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let local_did = cx.tcx.hir().local_def_id(self.hir_id);
|
||||
let inner = match self.kind {
|
||||
let kind = match self.kind {
|
||||
hir::ImplItemKind::Const(ref ty, expr) => {
|
||||
AssocConstItem(ty.clean(cx), Some(print_const_expr(cx, expr)))
|
||||
}
|
||||
@ -1175,14 +1175,14 @@ impl Clean<Item> for hir::ImplItem<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: get_stability(cx, local_did.to_def_id()),
|
||||
deprecation: get_deprecation(cx, local_did.to_def_id()),
|
||||
inner,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Item> for ty::AssocItem {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let inner = match self.kind {
|
||||
let kind = match self.kind {
|
||||
ty::AssocKind::Const => {
|
||||
let ty = cx.tcx.type_of(self.def_id);
|
||||
let default = if self.defaultness.has_value() {
|
||||
@ -1343,7 +1343,7 @@ impl Clean<Item> for ty::AssocItem {
|
||||
def_id: self.def_id,
|
||||
attrs: inline::load_attrs(cx, self.def_id).clean(cx),
|
||||
source: cx.tcx.def_span(self.def_id).clean(cx),
|
||||
inner,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1784,7 +1784,7 @@ impl Clean<Item> for hir::StructField<'_> {
|
||||
stability: get_stability(cx, local_did.to_def_id()),
|
||||
deprecation: get_deprecation(cx, local_did.to_def_id()),
|
||||
def_id: local_did.to_def_id(),
|
||||
inner: StructFieldItem(self.ty.clean(cx)),
|
||||
kind: StructFieldItem(self.ty.clean(cx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1799,7 +1799,7 @@ impl Clean<Item> for ty::FieldDef {
|
||||
stability: get_stability(cx, self.did),
|
||||
deprecation: get_deprecation(cx, self.did),
|
||||
def_id: self.did,
|
||||
inner: StructFieldItem(cx.tcx.type_of(self.did).clean(cx)),
|
||||
kind: StructFieldItem(cx.tcx.type_of(self.did).clean(cx)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1835,7 +1835,7 @@ impl Clean<Item> for doctree::Struct<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: StructItem(Struct {
|
||||
kind: StructItem(Struct {
|
||||
struct_type: self.struct_type,
|
||||
generics: self.generics.clean(cx),
|
||||
fields: self.fields.clean(cx),
|
||||
@ -1855,7 +1855,7 @@ impl Clean<Item> for doctree::Union<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: UnionItem(Union {
|
||||
kind: UnionItem(Union {
|
||||
struct_type: self.struct_type,
|
||||
generics: self.generics.clean(cx),
|
||||
fields: self.fields.clean(cx),
|
||||
@ -1885,7 +1885,7 @@ impl Clean<Item> for doctree::Enum<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: EnumItem(Enum {
|
||||
kind: EnumItem(Enum {
|
||||
variants: self.variants.iter().map(|v| v.clean(cx)).collect(),
|
||||
generics: self.generics.clean(cx),
|
||||
variants_stripped: false,
|
||||
@ -1904,7 +1904,7 @@ impl Clean<Item> for doctree::Variant<'_> {
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
|
||||
inner: VariantItem(Variant { kind: self.def.clean(cx) }),
|
||||
kind: VariantItem(Variant { kind: self.def.clean(cx) }),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1930,7 +1930,7 @@ impl Clean<Item> for ty::VariantDef {
|
||||
def_id: field.did,
|
||||
stability: get_stability(cx, field.did),
|
||||
deprecation: get_deprecation(cx, field.did),
|
||||
inner: StructFieldItem(cx.tcx.type_of(field.did).clean(cx)),
|
||||
kind: StructFieldItem(cx.tcx.type_of(field.did).clean(cx)),
|
||||
})
|
||||
.collect(),
|
||||
}),
|
||||
@ -1941,7 +1941,7 @@ impl Clean<Item> for ty::VariantDef {
|
||||
source: cx.tcx.def_span(self.def_id).clean(cx),
|
||||
visibility: Inherited,
|
||||
def_id: self.def_id,
|
||||
inner: VariantItem(Variant { kind }),
|
||||
kind: VariantItem(Variant { kind }),
|
||||
stability: get_stability(cx, self.def_id),
|
||||
deprecation: get_deprecation(cx, self.def_id),
|
||||
}
|
||||
@ -2057,7 +2057,7 @@ impl Clean<Item> for doctree::Typedef<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: TypedefItem(Typedef { type_, generics: self.gen.clean(cx), item_type }, false),
|
||||
kind: TypedefItem(Typedef { type_, generics: self.gen.clean(cx), item_type }, false),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2072,7 +2072,7 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: OpaqueTyItem(OpaqueTy {
|
||||
kind: OpaqueTyItem(OpaqueTy {
|
||||
bounds: self.opaque_ty.bounds.clean(cx),
|
||||
generics: self.opaque_ty.generics.clean(cx),
|
||||
}),
|
||||
@ -2100,7 +2100,7 @@ impl Clean<Item> for doctree::Static<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: StaticItem(Static {
|
||||
kind: StaticItem(Static {
|
||||
type_: self.type_.clean(cx),
|
||||
mutability: self.mutability,
|
||||
expr: print_const_expr(cx, self.expr),
|
||||
@ -2121,7 +2121,7 @@ impl Clean<Item> for doctree::Constant<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: ConstantItem(Constant {
|
||||
kind: ConstantItem(Constant {
|
||||
type_: self.type_.clean(cx),
|
||||
expr: print_const_expr(cx, self.expr),
|
||||
value: print_evaluated_const(cx, def_id.to_def_id()),
|
||||
@ -2175,7 +2175,7 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner: ImplItem(Impl {
|
||||
kind: ImplItem(Impl {
|
||||
unsafety: self.unsafety,
|
||||
generics: self.generics.clean(cx),
|
||||
provided_trait_methods: provided.clone(),
|
||||
@ -2231,7 +2231,7 @@ impl Clean<Vec<Item>> for doctree::ExternCrate<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: ExternCrateItem(self.name.clean(cx), self.path.clone()),
|
||||
kind: ExternCrateItem(self.name.clean(cx), self.path.clone()),
|
||||
}]
|
||||
}
|
||||
}
|
||||
@ -2302,7 +2302,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: ImportItem(Import::new_simple(
|
||||
kind: ImportItem(Import::new_simple(
|
||||
self.name.clean(cx),
|
||||
resolve_use_source(cx, path),
|
||||
false,
|
||||
@ -2322,14 +2322,14 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: None,
|
||||
deprecation: None,
|
||||
inner: ImportItem(inner),
|
||||
kind: ImportItem(inner),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
impl Clean<Item> for doctree::ForeignItem<'_> {
|
||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||
let inner = match self.kind {
|
||||
let kind = match self.kind {
|
||||
hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
|
||||
let abi = cx.tcx.hir().get_foreign_abi(self.id);
|
||||
let (generics, decl) =
|
||||
@ -2364,7 +2364,7 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
|
||||
visibility: self.vis.clean(cx),
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
inner,
|
||||
kind,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2380,7 +2380,7 @@ impl Clean<Item> for doctree::Macro<'_> {
|
||||
stability: cx.stability(self.hid),
|
||||
deprecation: cx.deprecation(self.hid).clean(cx),
|
||||
def_id: self.def_id,
|
||||
inner: MacroItem(Macro {
|
||||
kind: MacroItem(Macro {
|
||||
source: format!(
|
||||
"macro_rules! {} {{\n{}}}",
|
||||
name,
|
||||
@ -2405,7 +2405,7 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
|
||||
stability: cx.stability(self.id),
|
||||
deprecation: cx.deprecation(self.id).clean(cx),
|
||||
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
|
||||
inner: ProcMacroItem(ProcMacro { kind: self.kind, helpers: self.helpers.clean(cx) }),
|
||||
kind: ProcMacroItem(ProcMacro { kind: self.kind, helpers: self.helpers.clean(cx) }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ use crate::formats::item_type::ItemType;
|
||||
use crate::html::render::cache::ExternalLocation;
|
||||
|
||||
use self::FnRetTy::*;
|
||||
use self::ItemEnum::*;
|
||||
use self::ItemKind::*;
|
||||
use self::SelfTy::*;
|
||||
use self::Type::*;
|
||||
|
||||
@ -81,7 +81,7 @@ pub struct Item {
|
||||
/// Not everything has a name. E.g., impls
|
||||
pub name: Option<String>,
|
||||
pub attrs: Attributes,
|
||||
pub inner: ItemEnum,
|
||||
pub kind: ItemKind,
|
||||
pub visibility: Visibility,
|
||||
pub def_id: DefId,
|
||||
pub stability: Option<Stability>,
|
||||
@ -90,14 +90,13 @@ pub struct Item {
|
||||
|
||||
impl fmt::Debug for Item {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let fake = self.is_fake();
|
||||
let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
|
||||
let def_id: &dyn fmt::Debug = if self.is_fake() { &"**FAKE**" } else { &self.def_id };
|
||||
|
||||
fmt.debug_struct("Item")
|
||||
.field("source", &self.source)
|
||||
.field("name", &self.name)
|
||||
.field("attrs", &self.attrs)
|
||||
.field("inner", &self.inner)
|
||||
.field("kind", &self.kind)
|
||||
.field("visibility", &self.visibility)
|
||||
.field("def_id", def_id)
|
||||
.field("stability", &self.stability)
|
||||
@ -124,7 +123,7 @@ impl Item {
|
||||
}
|
||||
|
||||
pub fn is_crate(&self) -> bool {
|
||||
match self.inner {
|
||||
match self.kind {
|
||||
StrippedItem(box ModuleItem(Module { is_crate: true, .. }))
|
||||
| ModuleItem(Module { is_crate: true, .. }) => true,
|
||||
_ => false,
|
||||
@ -176,14 +175,14 @@ impl Item {
|
||||
self.type_() == ItemType::Keyword
|
||||
}
|
||||
pub fn is_stripped(&self) -> bool {
|
||||
match self.inner {
|
||||
match self.kind {
|
||||
StrippedItem(..) => true,
|
||||
ImportItem(ref i) => !i.should_be_displayed,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
pub fn has_stripped_fields(&self) -> Option<bool> {
|
||||
match self.inner {
|
||||
match self.kind {
|
||||
StructItem(ref _struct) => Some(_struct.fields_stripped),
|
||||
UnionItem(ref union) => Some(union.fields_stripped),
|
||||
VariantItem(Variant { kind: VariantKind::Struct(ref vstruct) }) => {
|
||||
@ -227,8 +226,8 @@ impl Item {
|
||||
}
|
||||
|
||||
pub fn is_default(&self) -> bool {
|
||||
match self.inner {
|
||||
ItemEnum::MethodItem(ref meth) => {
|
||||
match self.kind {
|
||||
ItemKind::MethodItem(ref meth) => {
|
||||
if let Some(defaultness) = meth.defaultness {
|
||||
defaultness.has_value() && !defaultness.is_final()
|
||||
} else {
|
||||
@ -248,7 +247,7 @@ impl Item {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ItemEnum {
|
||||
pub enum ItemKind {
|
||||
ExternCrateItem(String, Option<String>),
|
||||
ImportItem(Import),
|
||||
StructItem(Struct),
|
||||
@ -282,23 +281,23 @@ pub enum ItemEnum {
|
||||
AssocConstItem(Type, Option<String>),
|
||||
AssocTypeItem(Vec<GenericBound>, Option<Type>),
|
||||
/// An item that has been stripped by a rustdoc pass
|
||||
StrippedItem(Box<ItemEnum>),
|
||||
StrippedItem(Box<ItemKind>),
|
||||
KeywordItem(String),
|
||||
}
|
||||
|
||||
impl ItemEnum {
|
||||
impl ItemKind {
|
||||
pub fn is_type_alias(&self) -> bool {
|
||||
match *self {
|
||||
ItemEnum::TypedefItem(_, _) | ItemEnum::AssocTypeItem(_, _) => true,
|
||||
ItemKind::TypedefItem(_, _) | ItemKind::AssocTypeItem(_, _) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_assoc_kind(&self) -> Option<AssocKind> {
|
||||
match *self {
|
||||
ItemEnum::AssocConstItem(..) => Some(AssocKind::Const),
|
||||
ItemEnum::AssocTypeItem(..) => Some(AssocKind::Type),
|
||||
ItemEnum::TyMethodItem(..) | ItemEnum::MethodItem(..) => Some(AssocKind::Fn),
|
||||
ItemKind::AssocConstItem(..) => Some(AssocKind::Const),
|
||||
ItemKind::AssocTypeItem(..) => Some(AssocKind::Type),
|
||||
ItemKind::TyMethodItem(..) | ItemKind::MethodItem(..) => Some(AssocKind::Fn),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use crate::clean::auto_trait::AutoTraitFinder;
|
||||
use crate::clean::blanket_impl::BlanketImplFinder;
|
||||
use crate::clean::{
|
||||
inline, Clean, Crate, Deprecation, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg,
|
||||
GenericArgs, GenericBound, Generics, GetDefId, ImportSource, Item, ItemEnum, Lifetime,
|
||||
GenericArgs, GenericBound, Generics, GetDefId, ImportSource, Item, ItemKind, Lifetime,
|
||||
MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Span, Type, TypeBinding,
|
||||
TypeKind, Visibility, WherePredicate,
|
||||
};
|
||||
@ -44,8 +44,8 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
|
||||
let mut module = module.clean(cx);
|
||||
let mut masked_crates = FxHashSet::default();
|
||||
|
||||
match module.inner {
|
||||
ItemEnum::ModuleItem(ref module) => {
|
||||
match module.kind {
|
||||
ItemKind::ModuleItem(ref module) => {
|
||||
for it in &module.items {
|
||||
// `compiler_builtins` should be masked too, but we can't apply
|
||||
// `#[doc(masked)]` to the injected `extern crate` because it's unstable.
|
||||
@ -62,8 +62,8 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
|
||||
|
||||
let ExternalCrate { name, src, primitives, keywords, .. } = LOCAL_CRATE.clean(cx);
|
||||
{
|
||||
let m = match module.inner {
|
||||
ItemEnum::ModuleItem(ref mut m) => m,
|
||||
let m = match module.kind {
|
||||
ItemKind::ModuleItem(ref mut m) => m,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
m.items.extend(primitives.iter().map(|&(def_id, prim, ref attrs)| Item {
|
||||
@ -74,7 +74,7 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
|
||||
stability: get_stability(cx, def_id),
|
||||
deprecation: get_deprecation(cx, def_id),
|
||||
def_id,
|
||||
inner: ItemEnum::PrimitiveItem(prim),
|
||||
kind: ItemKind::PrimitiveItem(prim),
|
||||
}));
|
||||
m.items.extend(keywords.into_iter().map(|(def_id, kw, attrs)| Item {
|
||||
source: Span::empty(),
|
||||
@ -84,7 +84,7 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
|
||||
stability: get_stability(cx, def_id),
|
||||
deprecation: get_deprecation(cx, def_id),
|
||||
def_id,
|
||||
inner: ItemEnum::KeywordItem(kw),
|
||||
kind: ItemKind::KeywordItem(kw),
|
||||
}));
|
||||
}
|
||||
|
||||
@ -355,8 +355,8 @@ pub fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut V
|
||||
let tcx = cx.tcx;
|
||||
|
||||
for item in items {
|
||||
let target = match item.inner {
|
||||
ItemEnum::TypedefItem(ref t, true) => &t.type_,
|
||||
let target = match item.kind {
|
||||
ItemKind::TypedefItem(ref t, true) => &t.type_,
|
||||
_ => continue,
|
||||
};
|
||||
let primitive = match *target {
|
||||
|
@ -5,9 +5,9 @@ pub struct StripItem(pub Item);
|
||||
impl StripItem {
|
||||
pub fn strip(self) -> Option<Item> {
|
||||
match self.0 {
|
||||
Item { inner: StrippedItem(..), .. } => Some(self.0),
|
||||
Item { kind: StrippedItem(..), .. } => Some(self.0),
|
||||
mut i => {
|
||||
i.inner = StrippedItem(box i.inner);
|
||||
i.kind = StrippedItem(box i.kind);
|
||||
Some(i)
|
||||
}
|
||||
}
|
||||
@ -20,8 +20,8 @@ pub trait DocFolder: Sized {
|
||||
}
|
||||
|
||||
/// don't override!
|
||||
fn fold_inner_recur(&mut self, inner: ItemEnum) -> ItemEnum {
|
||||
match inner {
|
||||
fn fold_inner_recur(&mut self, kind: ItemKind) -> ItemKind {
|
||||
match kind {
|
||||
StrippedItem(..) => unreachable!(),
|
||||
ModuleItem(i) => ModuleItem(self.fold_mod(i)),
|
||||
StructItem(mut i) => {
|
||||
@ -72,14 +72,14 @@ pub trait DocFolder: Sized {
|
||||
|
||||
/// don't override!
|
||||
fn fold_item_recur(&mut self, item: Item) -> Option<Item> {
|
||||
let Item { attrs, name, source, visibility, def_id, inner, stability, deprecation } = item;
|
||||
let Item { attrs, name, source, visibility, def_id, kind, stability, deprecation } = item;
|
||||
|
||||
let inner = match inner {
|
||||
let kind = match kind {
|
||||
StrippedItem(box i) => StrippedItem(box self.fold_inner_recur(i)),
|
||||
_ => self.fold_inner_recur(inner),
|
||||
_ => self.fold_inner_recur(kind),
|
||||
};
|
||||
|
||||
Some(Item { attrs, name, source, inner, visibility, stability, deprecation, def_id })
|
||||
Some(Item { attrs, name, source, kind, visibility, stability, deprecation, def_id })
|
||||
}
|
||||
|
||||
fn fold_mod(&mut self, m: Module) -> Module {
|
||||
|
@ -218,7 +218,7 @@ impl DocFolder for Cache {
|
||||
|
||||
// If this is a stripped module,
|
||||
// we don't want it or its children in the search index.
|
||||
let orig_stripped_mod = match item.inner {
|
||||
let orig_stripped_mod = match item.kind {
|
||||
clean::StrippedItem(box clean::ModuleItem(..)) => {
|
||||
mem::replace(&mut self.stripped_mod, true)
|
||||
}
|
||||
@ -227,7 +227,7 @@ impl DocFolder for Cache {
|
||||
|
||||
// If the impl is from a masked crate or references something from a
|
||||
// masked crate then remove it completely.
|
||||
if let clean::ImplItem(ref i) = item.inner {
|
||||
if let clean::ImplItem(ref i) = item.kind {
|
||||
if self.masked_crates.contains(&item.def_id.krate)
|
||||
|| i.trait_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate))
|
||||
|| i.for_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate))
|
||||
@ -238,12 +238,12 @@ impl DocFolder for Cache {
|
||||
|
||||
// Propagate a trait method's documentation to all implementors of the
|
||||
// trait.
|
||||
if let clean::TraitItem(ref t) = item.inner {
|
||||
if let clean::TraitItem(ref t) = item.kind {
|
||||
self.traits.entry(item.def_id).or_insert_with(|| t.clone());
|
||||
}
|
||||
|
||||
// Collect all the implementors of traits.
|
||||
if let clean::ImplItem(ref i) = item.inner {
|
||||
if let clean::ImplItem(ref i) = item.kind {
|
||||
if let Some(did) = i.trait_.def_id() {
|
||||
if i.blanket_impl.is_none() {
|
||||
self.implementors
|
||||
@ -256,7 +256,7 @@ impl DocFolder for Cache {
|
||||
|
||||
// Index this method for searching later on.
|
||||
if let Some(ref s) = item.name {
|
||||
let (parent, is_inherent_impl_item) = match item.inner {
|
||||
let (parent, is_inherent_impl_item) = match item.kind {
|
||||
clean::StrippedItem(..) => ((None, None), false),
|
||||
clean::AssocConstItem(..) | clean::TypedefItem(_, true)
|
||||
if self.parent_is_trait_impl =>
|
||||
@ -345,7 +345,7 @@ impl DocFolder for Cache {
|
||||
_ => false,
|
||||
};
|
||||
|
||||
match item.inner {
|
||||
match item.kind {
|
||||
clean::StructItem(..)
|
||||
| clean::EnumItem(..)
|
||||
| clean::TypedefItem(..)
|
||||
@ -384,7 +384,7 @@ impl DocFolder for Cache {
|
||||
|
||||
// Maintain the parent stack
|
||||
let orig_parent_is_trait_impl = self.parent_is_trait_impl;
|
||||
let parent_pushed = match item.inner {
|
||||
let parent_pushed = match item.kind {
|
||||
clean::TraitItem(..)
|
||||
| clean::EnumItem(..)
|
||||
| clean::ForeignTypeItem
|
||||
@ -422,12 +422,12 @@ impl DocFolder for Cache {
|
||||
// Once we've recursively found all the generics, hoard off all the
|
||||
// implementations elsewhere.
|
||||
let ret = self.fold_item_recur(item).and_then(|item| {
|
||||
if let clean::Item { inner: clean::ImplItem(_), .. } = item {
|
||||
if let clean::Item { kind: clean::ImplItem(_), .. } = item {
|
||||
// Figure out the id of this impl. This may map to a
|
||||
// primitive rather than always to a struct/enum.
|
||||
// Note: matching twice to restrict the lifetime of the `i` borrow.
|
||||
let mut dids = FxHashSet::default();
|
||||
if let clean::Item { inner: clean::ImplItem(ref i), .. } = item {
|
||||
if let clean::Item { kind: clean::ImplItem(ref i), .. } = item {
|
||||
match i.for_ {
|
||||
clean::ResolvedPath { did, .. }
|
||||
| clean::BorrowedRef {
|
||||
|
@ -60,12 +60,12 @@ impl Serialize for ItemType {
|
||||
|
||||
impl<'a> From<&'a clean::Item> for ItemType {
|
||||
fn from(item: &'a clean::Item) -> ItemType {
|
||||
let inner = match item.inner {
|
||||
let kind = match item.kind {
|
||||
clean::StrippedItem(box ref item) => item,
|
||||
ref inner => inner,
|
||||
ref kind => kind,
|
||||
};
|
||||
|
||||
match *inner {
|
||||
match *kind {
|
||||
clean::ModuleItem(..) => ItemType::Module,
|
||||
clean::ExternCrateItem(..) => ItemType::ExternCrate,
|
||||
clean::ImportItem(..) => ItemType::Import,
|
||||
|
@ -32,7 +32,7 @@ pub struct Impl {
|
||||
|
||||
impl Impl {
|
||||
pub fn inner_impl(&self) -> &clean::Impl {
|
||||
match self.impl_item.inner {
|
||||
match self.impl_item.kind {
|
||||
clean::ImplItem(ref impl_) => impl_,
|
||||
_ => panic!("non-impl item found in impl"),
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ pub fn run_format<T: FormatRenderer>(
|
||||
}
|
||||
|
||||
cx.mod_item_in(&item, &name, &cache)?;
|
||||
let module = match item.inner {
|
||||
let module = match item.kind {
|
||||
clean::StrippedItem(box clean::ModuleItem(m)) | clean::ModuleItem(m) => m,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
@ -165,7 +165,7 @@ pub fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
|
||||
}
|
||||
|
||||
crate fn get_index_search_type(item: &clean::Item) -> Option<IndexItemFunctionType> {
|
||||
let (all_types, ret_types) = match item.inner {
|
||||
let (all_types, ret_types) = match item.kind {
|
||||
clean::FunctionItem(ref f) => (&f.all_types, &f.ret_types),
|
||||
clean::MethodItem(ref m) => (&m.all_types, &m.ret_types),
|
||||
clean::TyMethodItem(ref m) => (&m.all_types, &m.ret_types),
|
||||
|
@ -618,7 +618,7 @@ impl FormatRenderer for Context {
|
||||
|
||||
// Render sidebar-items.js used throughout this module.
|
||||
if !self.render_redirect_pages {
|
||||
let module = match item.inner {
|
||||
let module = match item.kind {
|
||||
clean::StrippedItem(box clean::ModuleItem(ref m)) | clean::ModuleItem(ref m) => m,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
@ -1717,7 +1717,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
|
||||
|
||||
write!(buf, "</span>"); // out-of-band
|
||||
write!(buf, "<span class=\"in-band\">");
|
||||
let name = match item.inner {
|
||||
let name = match item.kind {
|
||||
clean::ModuleItem(ref m) => {
|
||||
if m.is_crate {
|
||||
"Crate "
|
||||
@ -1766,7 +1766,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
|
||||
|
||||
write!(buf, "</span></h1>"); // in-band
|
||||
|
||||
match item.inner {
|
||||
match item.kind {
|
||||
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
|
||||
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) => {
|
||||
item_function(buf, cx, item, f)
|
||||
@ -2133,7 +2133,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
|
||||
);
|
||||
}
|
||||
|
||||
match myitem.inner {
|
||||
match myitem.kind {
|
||||
clean::ExternCrateItem(ref name, ref src) => {
|
||||
use crate::html::format::anchor;
|
||||
|
||||
@ -2169,7 +2169,7 @@ fn item_module(w: &mut Buffer, cx: &Context, item: &clean::Item, items: &[clean:
|
||||
continue;
|
||||
}
|
||||
|
||||
let unsafety_flag = match myitem.inner {
|
||||
let unsafety_flag = match myitem.kind {
|
||||
clean::FunctionItem(ref func) | clean::ForeignFunctionItem(ref func)
|
||||
if func.header.unsafety == hir::Unsafety::Unsafe =>
|
||||
{
|
||||
@ -2582,7 +2582,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
|
||||
}
|
||||
for (pos, m) in provided.iter().enumerate() {
|
||||
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait);
|
||||
match m.inner {
|
||||
match m.kind {
|
||||
clean::MethodItem(ref inner) if !inner.generics.where_predicates.is_empty() => {
|
||||
write!(w, ",\n {{ ... }}\n");
|
||||
}
|
||||
@ -2958,7 +2958,7 @@ fn render_assoc_item(
|
||||
where_clause = WhereClause { gens: g, indent, end_newline }
|
||||
)
|
||||
}
|
||||
match item.inner {
|
||||
match item.kind {
|
||||
clean::StrippedItem(..) => {}
|
||||
clean::TyMethodItem(ref m) => method(w, item, m.header, &m.generics, &m.decl, link, parent),
|
||||
clean::MethodItem(ref m) => method(w, item, m.header, &m.generics, &m.decl, link, parent),
|
||||
@ -2994,7 +2994,7 @@ fn item_struct(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Struct
|
||||
let mut fields = s
|
||||
.fields
|
||||
.iter()
|
||||
.filter_map(|f| match f.inner {
|
||||
.filter_map(|f| match f.kind {
|
||||
clean::StructFieldItem(ref ty) => Some((f, ty)),
|
||||
_ => None,
|
||||
})
|
||||
@ -3044,7 +3044,7 @@ fn item_union(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Union,
|
||||
let mut fields = s
|
||||
.fields
|
||||
.iter()
|
||||
.filter_map(|f| match f.inner {
|
||||
.filter_map(|f| match f.kind {
|
||||
clean::StructFieldItem(ref ty) => Some((f, ty)),
|
||||
_ => None,
|
||||
})
|
||||
@ -3097,7 +3097,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
|
||||
for v in &e.variants {
|
||||
write!(w, " ");
|
||||
let name = v.name.as_ref().unwrap();
|
||||
match v.inner {
|
||||
match v.kind {
|
||||
clean::VariantItem(ref var) => match var.kind {
|
||||
clean::VariantKind::CLike => write!(w, "{}", name),
|
||||
clean::VariantKind::Tuple(ref tys) => {
|
||||
@ -3147,7 +3147,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
|
||||
id = id,
|
||||
name = variant.name.as_ref().unwrap()
|
||||
);
|
||||
if let clean::VariantItem(ref var) = variant.inner {
|
||||
if let clean::VariantItem(ref var) = variant.kind {
|
||||
if let clean::VariantKind::Tuple(ref tys) = var.kind {
|
||||
write!(w, "(");
|
||||
for (i, ty) in tys.iter().enumerate() {
|
||||
@ -3164,8 +3164,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
|
||||
document_non_exhaustive(w, variant);
|
||||
|
||||
use crate::clean::{Variant, VariantKind};
|
||||
if let clean::VariantItem(Variant { kind: VariantKind::Struct(ref s) }) = variant.inner
|
||||
{
|
||||
if let clean::VariantItem(Variant { kind: VariantKind::Struct(ref s) }) = variant.kind {
|
||||
let variant_id = cx.derive_id(format!(
|
||||
"{}.{}.fields",
|
||||
ItemType::Variant,
|
||||
@ -3179,7 +3178,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
|
||||
);
|
||||
for field in &s.fields {
|
||||
use crate::clean::StructFieldItem;
|
||||
if let StructFieldItem(ref ty) = field.inner {
|
||||
if let StructFieldItem(ref ty) = field.kind {
|
||||
let id = cx.derive_id(format!(
|
||||
"variant.{}.field.{}",
|
||||
variant.name.as_ref().unwrap(),
|
||||
@ -3275,7 +3274,7 @@ fn render_struct(
|
||||
let mut has_visible_fields = false;
|
||||
write!(w, " {{");
|
||||
for field in fields {
|
||||
if let clean::StructFieldItem(ref ty) = field.inner {
|
||||
if let clean::StructFieldItem(ref ty) = field.kind {
|
||||
write!(
|
||||
w,
|
||||
"\n{} {}{}: {},",
|
||||
@ -3306,7 +3305,7 @@ fn render_struct(
|
||||
if i > 0 {
|
||||
write!(w, ", ");
|
||||
}
|
||||
match field.inner {
|
||||
match field.kind {
|
||||
clean::StrippedItem(box clean::StructFieldItem(..)) => write!(w, "_"),
|
||||
clean::StructFieldItem(ref ty) => {
|
||||
write!(w, "{}{}", field.visibility.print_with_space(), ty.print())
|
||||
@ -3352,7 +3351,7 @@ fn render_union(
|
||||
|
||||
write!(w, " {{\n{}", tab);
|
||||
for field in fields {
|
||||
if let clean::StructFieldItem(ref ty) = field.inner {
|
||||
if let clean::StructFieldItem(ref ty) = field.kind {
|
||||
write!(
|
||||
w,
|
||||
" {}{}: {},\n{}",
|
||||
@ -3516,7 +3515,7 @@ fn render_deref_methods(
|
||||
.inner_impl()
|
||||
.items
|
||||
.iter()
|
||||
.find_map(|item| match item.inner {
|
||||
.find_map(|item| match item.kind {
|
||||
clean::TypedefItem(ref t, true) => Some(match *t {
|
||||
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
|
||||
_ => (&t.type_, &t.type_),
|
||||
@ -3538,7 +3537,7 @@ fn render_deref_methods(
|
||||
}
|
||||
|
||||
fn should_render_item(item: &clean::Item, deref_mut_: bool) -> bool {
|
||||
let self_type_opt = match item.inner {
|
||||
let self_type_opt = match item.kind {
|
||||
clean::MethodItem(ref method) => method.decl.self_type(),
|
||||
clean::TyMethodItem(ref method) => method.decl.self_type(),
|
||||
_ => None,
|
||||
@ -3589,7 +3588,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
|
||||
));
|
||||
let t_did = impl_.trait_.def_id().unwrap();
|
||||
for it in &impl_.items {
|
||||
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
||||
if let clean::TypedefItem(ref tydef, _) = it.kind {
|
||||
out.push_str("<span class=\"where fmt-newline\"> ");
|
||||
assoc_type(
|
||||
&mut out,
|
||||
@ -3657,7 +3656,7 @@ fn render_impl(
|
||||
fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute);
|
||||
if show_def_docs {
|
||||
for it in &i.inner_impl().items {
|
||||
if let clean::TypedefItem(ref tydef, _) = it.inner {
|
||||
if let clean::TypedefItem(ref tydef, _) = it.kind {
|
||||
write!(w, "<span class=\"where fmt-newline\"> ");
|
||||
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None), "");
|
||||
write!(w, ";</span>");
|
||||
@ -3728,14 +3727,14 @@ fn render_impl(
|
||||
};
|
||||
|
||||
let (is_hidden, extra_class) =
|
||||
if (trait_.is_none() || item.doc_value().is_some() || item.inner.is_type_alias())
|
||||
if (trait_.is_none() || item.doc_value().is_some() || item.kind.is_type_alias())
|
||||
&& !is_default_item
|
||||
{
|
||||
(false, "")
|
||||
} else {
|
||||
(true, " hidden")
|
||||
};
|
||||
match item.inner {
|
||||
match item.kind {
|
||||
clean::MethodItem(clean::Method { .. })
|
||||
| clean::TyMethodItem(clean::TyMethod { .. }) => {
|
||||
// Only render when the method is not static or we allow static methods
|
||||
@ -4000,7 +3999,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer, cache: &Ca
|
||||
write!(
|
||||
buffer,
|
||||
"<p class=\"location\">{}{}</p>",
|
||||
match it.inner {
|
||||
match it.kind {
|
||||
clean::StructItem(..) => "Struct ",
|
||||
clean::TraitItem(..) => "Trait ",
|
||||
clean::PrimitiveItem(..) => "Primitive Type ",
|
||||
@ -4040,7 +4039,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer, cache: &Ca
|
||||
it.name.as_ref().expect("crates always have a name")
|
||||
);
|
||||
}
|
||||
match it.inner {
|
||||
match it.kind {
|
||||
clean::StructItem(ref s) => sidebar_struct(buffer, it, s),
|
||||
clean::TraitItem(ref t) => sidebar_trait(buffer, it, t),
|
||||
clean::PrimitiveItem(_) => sidebar_primitive(buffer, it),
|
||||
@ -4180,7 +4179,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
|
||||
.find(|i| i.inner_impl().trait_.def_id() == c.deref_trait_did)
|
||||
{
|
||||
if let Some((target, real_target)) =
|
||||
impl_.inner_impl().items.iter().find_map(|item| match item.inner {
|
||||
impl_.inner_impl().items.iter().find_map(|item| match item.kind {
|
||||
clean::TypedefItem(ref t, true) => Some(match *t {
|
||||
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
|
||||
_ => (&t.type_, &t.type_),
|
||||
@ -4319,8 +4318,8 @@ fn get_id_for_impl_on_foreign_type(for_: &clean::Type, trait_: &clean::Type) ->
|
||||
}
|
||||
|
||||
fn extract_for_impl_name(item: &clean::Item) -> Option<(String, String)> {
|
||||
match item.inner {
|
||||
clean::ItemEnum::ImplItem(ref i) => {
|
||||
match item.kind {
|
||||
clean::ItemKind::ImplItem(ref i) => {
|
||||
if let Some(ref trait_) = i.trait_ {
|
||||
Some((
|
||||
format!("{:#}", i.for_.print()),
|
||||
@ -4470,7 +4469,7 @@ fn sidebar_typedef(buf: &mut Buffer, it: &clean::Item) {
|
||||
fn get_struct_fields_name(fields: &[clean::Item]) -> String {
|
||||
let mut fields = fields
|
||||
.iter()
|
||||
.filter(|f| if let clean::StructFieldItem(..) = f.inner { true } else { false })
|
||||
.filter(|f| if let clean::StructFieldItem(..) = f.kind { true } else { false })
|
||||
.filter_map(|f| match f.name {
|
||||
Some(ref name) => {
|
||||
Some(format!("<a href=\"#structfield.{name}\">{name}</a>", name = name))
|
||||
|
@ -187,7 +187,7 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> {
|
||||
|
||||
impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
|
||||
fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
|
||||
match i.inner {
|
||||
match i.kind {
|
||||
_ if !i.def_id.is_local() => {
|
||||
// non-local items are skipped because they can be out of the users control,
|
||||
// especially in the case of trait impls, which rustdoc eagerly inlines
|
||||
|
@ -671,7 +671,7 @@ fn resolve_associated_trait_item(
|
||||
let implicit_impls = crate::clean::get_auto_trait_and_blanket_impls(cx, ty, did);
|
||||
let mut candidates: Vec<_> = implicit_impls
|
||||
.flat_map(|impl_outer| {
|
||||
match impl_outer.inner {
|
||||
match impl_outer.kind {
|
||||
clean::ImplItem(impl_) => {
|
||||
debug!("considering auto or blanket impl for trait {:?}", impl_.trait_);
|
||||
// Give precedence to methods that were overridden
|
||||
@ -681,14 +681,14 @@ fn resolve_associated_trait_item(
|
||||
return None;
|
||||
}
|
||||
let kind = assoc
|
||||
.inner
|
||||
.kind
|
||||
.as_assoc_kind()
|
||||
.expect("inner items for a trait should be associated items");
|
||||
if kind.namespace() != ns {
|
||||
return None;
|
||||
}
|
||||
|
||||
trace!("considering associated item {:?}", assoc.inner);
|
||||
trace!("considering associated item {:?}", assoc.kind);
|
||||
// We have a slight issue: normal methods come from `clean` types,
|
||||
// but provided methods come directly from `tcx`.
|
||||
// Fortunately, we don't need the whole method, we just need to know
|
||||
@ -832,7 +832,7 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
|
||||
trace!("got parent node for {:?} {:?}, id {:?}", item.type_(), item.name, item.def_id);
|
||||
}
|
||||
|
||||
let current_item = match item.inner {
|
||||
let current_item = match item.kind {
|
||||
clean::ModuleItem(..) => {
|
||||
if item.attrs.inner_docs {
|
||||
if item.def_id.is_top_level_module() { item.name.clone() } else { None }
|
||||
|
@ -55,11 +55,11 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
|
||||
// scan through included items ahead of time to splice in Deref targets to the "valid" sets
|
||||
for it in &new_items {
|
||||
if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = it.inner {
|
||||
if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = it.kind {
|
||||
if cleaner.keep_item(for_) && trait_.def_id() == cx.tcx.lang_items().deref_trait() {
|
||||
let target = items
|
||||
.iter()
|
||||
.find_map(|item| match item.inner {
|
||||
.find_map(|item| match item.kind {
|
||||
TypedefItem(ref t, true) => Some(&t.type_),
|
||||
_ => None,
|
||||
})
|
||||
@ -75,7 +75,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
}
|
||||
|
||||
new_items.retain(|it| {
|
||||
if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = it.inner {
|
||||
if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = it.kind {
|
||||
cleaner.keep_item(for_)
|
||||
|| trait_.as_ref().map_or(false, |t| cleaner.keep_item(t))
|
||||
|| blanket_impl.is_some()
|
||||
@ -96,7 +96,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
|
||||
}
|
||||
|
||||
if let Some(ref mut it) = krate.module {
|
||||
if let ModuleItem(Module { ref mut items, .. }) = it.inner {
|
||||
if let ModuleItem(Module { ref mut items, .. }) = it.kind {
|
||||
items.extend(synth.impls);
|
||||
items.extend(new_items);
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ impl crate::doctest::Tester for Tests {
|
||||
}
|
||||
|
||||
pub fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
|
||||
if matches!(item.inner,
|
||||
if matches!(item.kind,
|
||||
clean::StructFieldItem(_)
|
||||
| clean::VariantItem(_)
|
||||
| clean::AssocConstItem(_, _)
|
||||
|
@ -41,7 +41,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||
if i.attrs.lists(sym::doc).has_word(sym::hidden) {
|
||||
debug!("strip_hidden: stripping {:?} {:?}", i.type_(), i.name);
|
||||
// use a dedicated hidden item for given item type if any
|
||||
match i.inner {
|
||||
match i.kind {
|
||||
clean::StructFieldItem(..) | clean::ModuleItem(..) => {
|
||||
// We need to recurse into stripped modules to
|
||||
// strip things like impl methods but when doing so
|
||||
|
@ -13,7 +13,7 @@ pub struct Stripper<'a> {
|
||||
|
||||
impl<'a> DocFolder for Stripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
match i.kind {
|
||||
clean::StrippedItem(..) => {
|
||||
// We need to recurse into stripped modules to strip things
|
||||
// like impl methods but when doing so we must not add any
|
||||
@ -86,7 +86,7 @@ impl<'a> DocFolder for Stripper<'a> {
|
||||
clean::KeywordItem(..) => {}
|
||||
}
|
||||
|
||||
let fastreturn = match i.inner {
|
||||
let fastreturn = match i.kind {
|
||||
// nothing left to do for traits (don't want to filter their
|
||||
// methods out, visibility controlled by the trait)
|
||||
clean::TraitItem(..) => true,
|
||||
@ -123,7 +123,7 @@ pub struct ImplStripper<'a> {
|
||||
|
||||
impl<'a> DocFolder for ImplStripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
if let clean::ImplItem(ref imp) = i.inner {
|
||||
if let clean::ImplItem(ref imp) = i.kind {
|
||||
// emptied none trait impls can be stripped
|
||||
if imp.trait_.is_none() && imp.items.is_empty() {
|
||||
return None;
|
||||
@ -162,7 +162,7 @@ pub struct ImportStripper;
|
||||
|
||||
impl DocFolder for ImportStripper {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
match i.inner {
|
||||
match i.kind {
|
||||
clean::ExternCrateItem(..) | clean::ImportItem(..) if i.visibility != clean::Public => {
|
||||
None
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user