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