Box ItemKind to reduce the size of Item
This brings the size of `Item` from ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 680 ``` to ``` [src/librustdoc/lib.rs:103] std::mem::size_of::<Item>() = 280 ```
This commit is contained in:
parent
3ffea60dd5
commit
4a4426377e
20 changed files with 90 additions and 94 deletions
|
@ -123,7 +123,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||||
attrs: Default::default(),
|
attrs: Default::default(),
|
||||||
visibility: Inherited,
|
visibility: Inherited,
|
||||||
def_id: self.cx.next_def_id(param_env_def_id.krate),
|
def_id: self.cx.next_def_id(param_env_def_id.krate),
|
||||||
kind: ImplItem(Impl {
|
kind: box 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(),
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
|
||||||
attrs: Default::default(),
|
attrs: Default::default(),
|
||||||
visibility: Inherited,
|
visibility: Inherited,
|
||||||
def_id: self.cx.next_def_id(impl_def_id.krate),
|
def_id: self.cx.next_def_id(impl_def_id.krate),
|
||||||
kind: ImplItem(Impl {
|
kind: box 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),
|
||||||
|
|
|
@ -482,7 +482,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
|
||||||
source: clean::Span::dummy(),
|
source: clean::Span::dummy(),
|
||||||
def_id: DefId::local(CRATE_DEF_INDEX),
|
def_id: DefId::local(CRATE_DEF_INDEX),
|
||||||
visibility: clean::Public,
|
visibility: clean::Public,
|
||||||
kind: clean::ImportItem(clean::Import::new_simple(
|
kind: box clean::ImportItem(clean::Import::new_simple(
|
||||||
item.ident.name,
|
item.ident.name,
|
||||||
clean::ImportSource {
|
clean::ImportSource {
|
||||||
path: clean::Path {
|
path: clean::Path {
|
||||||
|
|
|
@ -2144,7 +2144,7 @@ fn clean_extern_crate(
|
||||||
source: krate.span.clean(cx),
|
source: krate.span.clean(cx),
|
||||||
def_id: crate_def_id,
|
def_id: crate_def_id,
|
||||||
visibility: krate.vis.clean(cx),
|
visibility: krate.vis.clean(cx),
|
||||||
kind: ExternCrateItem(name, orig_name),
|
kind: box ExternCrateItem(name, orig_name),
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2212,7 +2212,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
|
||||||
source: self.span.clean(cx),
|
source: self.span.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(),
|
||||||
visibility: self.vis.clean(cx),
|
visibility: self.vis.clean(cx),
|
||||||
kind: ImportItem(Import::new_simple(
|
kind: box ImportItem(Import::new_simple(
|
||||||
self.name,
|
self.name,
|
||||||
resolve_use_source(cx, path),
|
resolve_use_source(cx, path),
|
||||||
false,
|
false,
|
||||||
|
@ -2230,7 +2230,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
|
||||||
source: self.span.clean(cx),
|
source: self.span.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(),
|
||||||
visibility: self.vis.clean(cx),
|
visibility: self.vis.clean(cx),
|
||||||
kind: ImportItem(inner),
|
kind: box ImportItem(inner),
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ crate struct Item {
|
||||||
crate name: Option<Symbol>,
|
crate name: Option<Symbol>,
|
||||||
crate attrs: Attributes,
|
crate attrs: Attributes,
|
||||||
crate visibility: Visibility,
|
crate visibility: Visibility,
|
||||||
crate kind: ItemKind,
|
crate kind: Box<ItemKind>,
|
||||||
crate def_id: DefId,
|
crate def_id: DefId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ impl Item {
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
def_id,
|
def_id,
|
||||||
kind,
|
kind: box kind,
|
||||||
name,
|
name,
|
||||||
source: source.clean(cx),
|
source: source.clean(cx),
|
||||||
attrs: cx.tcx.get_attrs(def_id).clean(cx),
|
attrs: cx.tcx.get_attrs(def_id).clean(cx),
|
||||||
|
@ -171,7 +171,7 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn is_crate(&self) -> bool {
|
crate fn is_crate(&self) -> bool {
|
||||||
match self.kind {
|
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,
|
||||||
|
@ -223,14 +223,14 @@ impl Item {
|
||||||
self.type_() == ItemType::Keyword
|
self.type_() == ItemType::Keyword
|
||||||
}
|
}
|
||||||
crate fn is_stripped(&self) -> bool {
|
crate fn is_stripped(&self) -> bool {
|
||||||
match self.kind {
|
match *self.kind {
|
||||||
StrippedItem(..) => true,
|
StrippedItem(..) => true,
|
||||||
ImportItem(ref i) => !i.should_be_displayed,
|
ImportItem(ref i) => !i.should_be_displayed,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
crate fn has_stripped_fields(&self) -> Option<bool> {
|
crate fn has_stripped_fields(&self) -> Option<bool> {
|
||||||
match self.kind {
|
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) }) => {
|
||||||
|
@ -281,7 +281,7 @@ impl Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn is_default(&self) -> bool {
|
crate fn is_default(&self) -> bool {
|
||||||
match self.kind {
|
match *self.kind {
|
||||||
ItemKind::MethodItem(_, Some(defaultness)) => {
|
ItemKind::MethodItem(_, Some(defaultness)) => {
|
||||||
defaultness.has_value() && !defaultness.is_final()
|
defaultness.has_value() && !defaultness.is_final()
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ crate 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.kind {
|
match *module.kind {
|
||||||
ItemKind::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
|
||||||
|
@ -61,7 +61,7 @@ crate 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.kind {
|
let m = match *module.kind {
|
||||||
ItemKind::ModuleItem(ref mut m) => m,
|
ItemKind::ModuleItem(ref mut m) => m,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
@ -338,7 +338,7 @@ crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut
|
||||||
let tcx = cx.tcx;
|
let tcx = cx.tcx;
|
||||||
|
|
||||||
for item in items {
|
for item in items {
|
||||||
let target = match item.kind {
|
let target = match *item.kind {
|
||||||
ItemKind::TypedefItem(ref t, true) => &t.type_,
|
ItemKind::TypedefItem(ref t, true) => &t.type_,
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,9 +5,9 @@ crate struct StripItem(pub Item);
|
||||||
impl StripItem {
|
impl StripItem {
|
||||||
crate fn strip(self) -> Option<Item> {
|
crate fn strip(self) -> Option<Item> {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
Item { kind: StrippedItem(..), .. } => Some(self.0),
|
Item { kind: box StrippedItem(..), .. } => Some(self.0),
|
||||||
mut i => {
|
mut i => {
|
||||||
i.kind = StrippedItem(box i.kind);
|
i.kind = box StrippedItem(i.kind);
|
||||||
Some(i)
|
Some(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ crate trait DocFolder: Sized {
|
||||||
|
|
||||||
/// don't override!
|
/// don't override!
|
||||||
fn fold_item_recur(&mut self, mut item: Item) -> Item {
|
fn fold_item_recur(&mut self, mut item: Item) -> Item {
|
||||||
item.kind = match item.kind {
|
item.kind = box match *item.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(item.kind),
|
_ => self.fold_inner_recur(*item.kind),
|
||||||
};
|
};
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,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.kind {
|
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)
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,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.kind {
|
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))
|
||||||
|
@ -239,12 +239,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.kind {
|
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.kind {
|
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
|
||||||
|
@ -257,7 +257,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.kind {
|
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 =>
|
||||||
|
@ -348,7 +348,7 @@ impl DocFolder for Cache {
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
match item.kind {
|
match *item.kind {
|
||||||
clean::StructItem(..)
|
clean::StructItem(..)
|
||||||
| clean::EnumItem(..)
|
| clean::EnumItem(..)
|
||||||
| clean::TypedefItem(..)
|
| clean::TypedefItem(..)
|
||||||
|
@ -387,7 +387,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.kind {
|
let parent_pushed = match *item.kind {
|
||||||
clean::TraitItem(..)
|
clean::TraitItem(..)
|
||||||
| clean::EnumItem(..)
|
| clean::EnumItem(..)
|
||||||
| clean::ForeignTypeItem
|
| clean::ForeignTypeItem
|
||||||
|
@ -425,21 +425,19 @@ 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 item = self.fold_item_recur(item);
|
let item = self.fold_item_recur(item);
|
||||||
let ret = if let clean::Item { kind: clean::ImplItem(_), .. } = item {
|
let ret = if let clean::Item { kind: box clean::ImplItem(ref i), .. } = 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 { kind: clean::ImplItem(ref i), .. } = item {
|
|
||||||
match i.for_ {
|
match i.for_ {
|
||||||
clean::ResolvedPath { did, .. }
|
clean::ResolvedPath { did, .. }
|
||||||
| clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
|
| clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
|
||||||
dids.insert(did);
|
dids.insert(did);
|
||||||
}
|
}
|
||||||
ref t => {
|
ref t => {
|
||||||
let did = t
|
let did =
|
||||||
.primitive_type()
|
t.primitive_type().and_then(|t| self.primitive_locations.get(&t).cloned());
|
||||||
.and_then(|t| self.primitive_locations.get(&t).cloned());
|
|
||||||
|
|
||||||
if let Some(did) = did {
|
if let Some(did) = did {
|
||||||
dids.insert(did);
|
dids.insert(did);
|
||||||
|
@ -454,9 +452,6 @@ impl DocFolder for Cache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
};
|
|
||||||
let impl_item = Impl { impl_item: item };
|
let impl_item = Impl { impl_item: item };
|
||||||
if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) {
|
if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) {
|
||||||
for did in dids {
|
for did in dids {
|
||||||
|
|
|
@ -60,7 +60,7 @@ 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 kind = match item.kind {
|
let kind = match *item.kind {
|
||||||
clean::StrippedItem(box ref item) => item,
|
clean::StrippedItem(box ref item) => item,
|
||||||
ref kind => kind,
|
ref kind => kind,
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ crate struct Impl {
|
||||||
|
|
||||||
impl Impl {
|
impl Impl {
|
||||||
crate fn inner_impl(&self) -> &clean::Impl {
|
crate fn inner_impl(&self) -> &clean::Impl {
|
||||||
match self.impl_item.kind {
|
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"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.mod_item_in(&item, &name, &cache)?;
|
cx.mod_item_in(&item, &name, &cache)?;
|
||||||
let module = match item.kind {
|
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 @@ crate 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.kind {
|
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),
|
||||||
|
|
|
@ -633,7 +633,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
|
||||||
|
|
||||||
// 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.kind {
|
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!(),
|
||||||
};
|
};
|
||||||
|
@ -1739,7 +1739,7 @@ fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, cache: &Ca
|
||||||
|
|
||||||
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.kind {
|
let name = match *item.kind {
|
||||||
clean::ModuleItem(ref m) => {
|
clean::ModuleItem(ref m) => {
|
||||||
if m.is_crate {
|
if m.is_crate {
|
||||||
"Crate "
|
"Crate "
|
||||||
|
@ -1788,7 +1788,7 @@ fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, cache: &Ca
|
||||||
|
|
||||||
write!(buf, "</span></h1>"); // in-band
|
write!(buf, "</span></h1>"); // in-band
|
||||||
|
|
||||||
match item.kind {
|
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)
|
||||||
|
@ -2149,7 +2149,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
match myitem.kind {
|
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;
|
||||||
|
|
||||||
|
@ -2185,7 +2185,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let unsafety_flag = match myitem.kind {
|
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 =>
|
||||||
{
|
{
|
||||||
|
@ -2624,7 +2624,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
|
||||||
}
|
}
|
||||||
for (pos, m) in provided.iter().enumerate() {
|
for (pos, m) in provided.iter().enumerate() {
|
||||||
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait, cx);
|
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait, cx);
|
||||||
match m.kind {
|
match *m.kind {
|
||||||
clean::MethodItem(ref inner, _)
|
clean::MethodItem(ref inner, _)
|
||||||
if !inner.generics.where_predicates.is_empty() =>
|
if !inner.generics.where_predicates.is_empty() =>
|
||||||
{
|
{
|
||||||
|
@ -3051,7 +3051,7 @@ fn render_assoc_item(
|
||||||
where_clause = WhereClause { gens: g, indent, end_newline }
|
where_clause = WhereClause { gens: g, indent, end_newline }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
match item.kind {
|
match *item.kind {
|
||||||
clean::StrippedItem(..) => {}
|
clean::StrippedItem(..) => {}
|
||||||
clean::TyMethodItem(ref m) => {
|
clean::TyMethodItem(ref m) => {
|
||||||
method(w, item, m.header, &m.generics, &m.decl, link, parent, cx)
|
method(w, item, m.header, &m.generics, &m.decl, link, parent, cx)
|
||||||
|
@ -3098,7 +3098,7 @@ fn item_struct(
|
||||||
let mut fields = s
|
let mut fields = s
|
||||||
.fields
|
.fields
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|f| match f.kind {
|
.filter_map(|f| match *f.kind {
|
||||||
clean::StructFieldItem(ref ty) => Some((f, ty)),
|
clean::StructFieldItem(ref ty) => Some((f, ty)),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
@ -3148,7 +3148,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
|
||||||
let mut fields = s
|
let mut fields = s
|
||||||
.fields
|
.fields
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|f| match f.kind {
|
.filter_map(|f| match *f.kind {
|
||||||
clean::StructFieldItem(ref ty) => Some((f, ty)),
|
clean::StructFieldItem(ref ty) => Some((f, ty)),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
@ -3201,7 +3201,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
|
||||||
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.kind {
|
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) => {
|
||||||
|
@ -3251,7 +3251,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
|
||||||
id = id,
|
id = id,
|
||||||
name = variant.name.as_ref().unwrap()
|
name = variant.name.as_ref().unwrap()
|
||||||
);
|
);
|
||||||
if let clean::VariantItem(ref var) = variant.kind {
|
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() {
|
||||||
|
@ -3268,7 +3268,8 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
|
||||||
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.kind {
|
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,
|
||||||
|
@ -3282,7 +3283,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
|
||||||
);
|
);
|
||||||
for field in &s.fields {
|
for field in &s.fields {
|
||||||
use crate::clean::StructFieldItem;
|
use crate::clean::StructFieldItem;
|
||||||
if let StructFieldItem(ref ty) = field.kind {
|
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(),
|
||||||
|
@ -3379,7 +3380,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.kind {
|
if let clean::StructFieldItem(ref ty) = *field.kind {
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
"\n{} {}{}: {},",
|
"\n{} {}{}: {},",
|
||||||
|
@ -3410,7 +3411,7 @@ fn render_struct(
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
write!(w, ", ");
|
write!(w, ", ");
|
||||||
}
|
}
|
||||||
match field.kind {
|
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(cx.tcx()), ty.print())
|
write!(w, "{}{}", field.visibility.print_with_space(cx.tcx()), ty.print())
|
||||||
|
@ -3457,7 +3458,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.kind {
|
if let clean::StructFieldItem(ref ty) = *field.kind {
|
||||||
write!(
|
write!(
|
||||||
w,
|
w,
|
||||||
" {}{}: {},\n{}",
|
" {}{}: {},\n{}",
|
||||||
|
@ -3619,7 +3620,7 @@ fn render_deref_methods(
|
||||||
.inner_impl()
|
.inner_impl()
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|item| match item.kind {
|
.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_),
|
||||||
|
@ -3641,7 +3642,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.kind {
|
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,
|
||||||
|
@ -3692,7 +3693,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.kind {
|
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,
|
||||||
|
@ -3764,7 +3765,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.kind {
|
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>");
|
||||||
|
@ -3846,7 +3847,7 @@ fn render_impl(
|
||||||
} else {
|
} else {
|
||||||
(true, " hidden")
|
(true, " hidden")
|
||||||
};
|
};
|
||||||
match item.kind {
|
match *item.kind {
|
||||||
clean::MethodItem(..) | clean::TyMethodItem(_) => {
|
clean::MethodItem(..) | clean::TyMethodItem(_) => {
|
||||||
// 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
|
||||||
if render_method_item {
|
if render_method_item {
|
||||||
|
@ -4123,7 +4124,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache:
|
||||||
write!(
|
write!(
|
||||||
buffer,
|
buffer,
|
||||||
"<p class=\"location\">{}{}</p>",
|
"<p class=\"location\">{}{}</p>",
|
||||||
match it.kind {
|
match *it.kind {
|
||||||
clean::StructItem(..) => "Struct ",
|
clean::StructItem(..) => "Struct ",
|
||||||
clean::TraitItem(..) => "Trait ",
|
clean::TraitItem(..) => "Trait ",
|
||||||
clean::PrimitiveItem(..) => "Primitive Type ",
|
clean::PrimitiveItem(..) => "Primitive Type ",
|
||||||
|
@ -4163,7 +4164,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache:
|
||||||
it.name.as_ref().expect("crates always have a name")
|
it.name.as_ref().expect("crates always have a name")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
match it.kind {
|
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),
|
||||||
|
@ -4303,7 +4304,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.kind {
|
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_),
|
||||||
|
@ -4442,7 +4443,7 @@ 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.kind {
|
match *item.kind {
|
||||||
clean::ItemKind::ImplItem(ref i) => {
|
clean::ItemKind::ImplItem(ref i) => {
|
||||||
if let Some(ref trait_) = i.trait_ {
|
if let Some(ref trait_) = i.trait_ {
|
||||||
Some((
|
Some((
|
||||||
|
@ -4593,7 +4594,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.kind { true } else { false })
|
.filter(|f| matches!(*f.kind, clean::StructFieldItem(..)))
|
||||||
.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))
|
||||||
|
|
|
@ -19,9 +19,9 @@ impl JsonRenderer<'_> {
|
||||||
let item_type = ItemType::from(&item);
|
let item_type = ItemType::from(&item);
|
||||||
let deprecation = item.deprecation(self.tcx);
|
let deprecation = item.deprecation(self.tcx);
|
||||||
let clean::Item { source, name, attrs, kind, visibility, def_id } = item;
|
let clean::Item { source, name, attrs, kind, visibility, def_id } = item;
|
||||||
match kind {
|
match *kind {
|
||||||
clean::StrippedItem(_) => None,
|
clean::StrippedItem(_) => None,
|
||||||
_ => Some(Item {
|
kind => Some(Item {
|
||||||
id: def_id.into(),
|
id: def_id.into(),
|
||||||
crate_id: def_id.krate.as_u32(),
|
crate_id: def_id.krate.as_u32(),
|
||||||
name: name.map(|sym| sym.to_string()),
|
name: name.map(|sym| sym.to_string()),
|
||||||
|
|
|
@ -178,9 +178,9 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
|
||||||
cache: &Cache,
|
cache: &Cache,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
use clean::types::ItemKind::*;
|
use clean::types::ItemKind::*;
|
||||||
if let ModuleItem(m) = &item.kind {
|
if let ModuleItem(m) = &*item.kind {
|
||||||
for item in &m.items {
|
for item in &m.items {
|
||||||
match &item.kind {
|
match &*item.kind {
|
||||||
// These don't have names so they don't get added to the output by default
|
// These don't have names so they don't get added to the output by default
|
||||||
ImportItem(_) => self.item(item.clone(), cache).unwrap(),
|
ImportItem(_) => self.item(item.clone(), cache).unwrap(),
|
||||||
ExternCrateItem(_, _) => self.item(item.clone(), cache).unwrap(),
|
ExternCrateItem(_, _) => self.item(item.clone(), cache).unwrap(),
|
||||||
|
|
|
@ -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.kind {
|
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
|
||||||
|
|
|
@ -58,11 +58,11 @@ crate 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.kind {
|
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.kind {
|
.find_map(|item| match *item.kind {
|
||||||
TypedefItem(ref t, true) => Some(&t.type_),
|
TypedefItem(ref t, true) => Some(&t.type_),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
@ -78,7 +78,7 @@ crate 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.kind {
|
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()
|
||||||
|
@ -124,7 +124,7 @@ crate 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.kind {
|
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 {
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl crate::doctest::Tester for Tests {
|
||||||
|
|
||||||
crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
|
crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
|
||||||
if matches!(
|
if matches!(
|
||||||
item.kind,
|
*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.kind {
|
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 @@ crate 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.kind {
|
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.kind {
|
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,
|
||||||
|
@ -121,7 +121,7 @@ crate 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.kind {
|
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;
|
||||||
|
@ -160,7 +160,7 @@ crate 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.kind {
|
match *i.kind {
|
||||||
clean::ExternCrateItem(..) | clean::ImportItem(..) if !i.visibility.is_public() => None,
|
clean::ExternCrateItem(..) | clean::ImportItem(..) if !i.visibility.is_public() => None,
|
||||||
_ => Some(self.fold_item_recur(i)),
|
_ => Some(self.fold_item_recur(i)),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue