Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
attrs: Default::default(),
visibility: Inherited,
def_id: self.cx.next_def_id(param_env_def_id.krate),
kind: ImplItem(Impl {
kind: box ImplItem(Impl {
unsafety: hir::Unsafety::Normal,
generics: new_generics,
provided_trait_methods: Default::default(),
2 changes: 1 addition & 1 deletion src/librustdoc/clean/blanket_impl.rs
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
attrs: Default::default(),
visibility: Inherited,
def_id: self.cx.next_def_id(impl_def_id.krate),
kind: ImplItem(Impl {
kind: box ImplItem(Impl {
unsafety: hir::Unsafety::Normal,
generics: (
self.cx.tcx.generics_of(impl_def_id),
2 changes: 1 addition & 1 deletion src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
@@ -482,7 +482,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
source: clean::Span::dummy(),
def_id: DefId::local(CRATE_DEF_INDEX),
visibility: clean::Public,
kind: clean::ImportItem(clean::Import::new_simple(
kind: box clean::ImportItem(clean::Import::new_simple(
item.ident.name,
clean::ImportSource {
path: clean::Path {
6 changes: 3 additions & 3 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
@@ -2144,7 +2144,7 @@ fn clean_extern_crate(
source: krate.span.clean(cx),
def_id: crate_def_id,
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),
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
visibility: self.vis.clean(cx),
kind: ImportItem(Import::new_simple(
kind: box ImportItem(Import::new_simple(
self.name,
resolve_use_source(cx, path),
false,
@@ -2230,7 +2230,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
source: self.span.clean(cx),
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
visibility: self.vis.clean(cx),
kind: ImportItem(inner),
kind: box ImportItem(inner),
}]
}
}
16 changes: 10 additions & 6 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
@@ -84,10 +84,14 @@ crate struct Item {
crate name: Option<Symbol>,
crate attrs: Attributes,
crate visibility: Visibility,
crate kind: ItemKind,
crate kind: Box<ItemKind>,
crate def_id: DefId,
}

// `Item` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(target_arch = "x86_64")]
rustc_data_structures::static_assert_size!(Item, 136);

impl fmt::Debug for Item {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let def_id: &dyn fmt::Debug = if self.is_fake() { &"**FAKE**" } else { &self.def_id };
@@ -152,7 +156,7 @@ impl Item {

Item {
def_id,
kind,
kind: box kind,
name,
source: source.clean(cx),
attrs: cx.tcx.get_attrs(def_id).clean(cx),
@@ -171,7 +175,7 @@ impl Item {
}

crate fn is_crate(&self) -> bool {
match self.kind {
match *self.kind {
StrippedItem(box ModuleItem(Module { is_crate: true, .. }))
| ModuleItem(Module { is_crate: true, .. }) => true,
_ => false,
@@ -223,14 +227,14 @@ impl Item {
self.type_() == ItemType::Keyword
}
crate fn is_stripped(&self) -> bool {
match self.kind {
match *self.kind {
StrippedItem(..) => true,
ImportItem(ref i) => !i.should_be_displayed,
_ => false,
}
}
crate fn has_stripped_fields(&self) -> Option<bool> {
match self.kind {
match *self.kind {
StructItem(ref _struct) => Some(_struct.fields_stripped),
UnionItem(ref union) => Some(union.fields_stripped),
VariantItem(Variant { kind: VariantKind::Struct(ref vstruct) }) => {
@@ -281,7 +285,7 @@ impl Item {
}

crate fn is_default(&self) -> bool {
match self.kind {
match *self.kind {
ItemKind::MethodItem(_, Some(defaultness)) => {
defaultness.has_value() && !defaultness.is_final()
}
6 changes: 3 additions & 3 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate {
let mut module = module.clean(cx);
let mut masked_crates = FxHashSet::default();

match module.kind {
match *module.kind {
ItemKind::ModuleItem(ref module) => {
for it in &module.items {
// `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 m = match module.kind {
let m = match *module.kind {
ItemKind::ModuleItem(ref mut m) => m,
_ => unreachable!(),
};
@@ -338,7 +338,7 @@ crate fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut
let tcx = cx.tcx;

for item in items {
let target = match item.kind {
let target = match *item.kind {
ItemKind::TypedefItem(ref t, true) => &t.type_,
_ => continue,
};
8 changes: 4 additions & 4 deletions src/librustdoc/fold.rs
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ crate struct StripItem(pub Item);
impl StripItem {
crate fn strip(self) -> Option<Item> {
match self.0 {
Item { kind: StrippedItem(..), .. } => Some(self.0),
Item { kind: box StrippedItem(..), .. } => Some(self.0),
mut i => {
i.kind = StrippedItem(box i.kind);
i.kind = box StrippedItem(i.kind);
Some(i)
}
}
@@ -72,9 +72,9 @@ crate trait DocFolder: Sized {

/// don't override!
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)),
_ => self.fold_inner_recur(item.kind),
_ => self.fold_inner_recur(*item.kind),
};
item
}
53 changes: 24 additions & 29 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ impl DocFolder for Cache {

// If this is a stripped module,
// we don't want it or its children in the search index.
let orig_stripped_mod = match item.kind {
let orig_stripped_mod = match *item.kind {
clean::StrippedItem(box clean::ModuleItem(..)) => {
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
// 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)
|| 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))
@@ -239,12 +239,12 @@ impl DocFolder for Cache {

// Propagate a trait method's documentation to all implementors of the
// 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());
}

// 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 i.blanket_impl.is_none() {
self.implementors
@@ -257,7 +257,7 @@ impl DocFolder for Cache {

// Index this method for searching later on.
if let Some(ref s) = item.name {
let (parent, is_inherent_impl_item) = match item.kind {
let (parent, is_inherent_impl_item) = match *item.kind {
clean::StrippedItem(..) => ((None, None), false),
clean::AssocConstItem(..) | clean::TypedefItem(_, true)
if self.parent_is_trait_impl =>
@@ -348,7 +348,7 @@ impl DocFolder for Cache {
_ => false,
};

match item.kind {
match *item.kind {
clean::StructItem(..)
| clean::EnumItem(..)
| clean::TypedefItem(..)
@@ -387,7 +387,7 @@ impl DocFolder for Cache {

// Maintain the parent stack
let orig_parent_is_trait_impl = self.parent_is_trait_impl;
let parent_pushed = match item.kind {
let parent_pushed = match *item.kind {
clean::TraitItem(..)
| clean::EnumItem(..)
| clean::ForeignTypeItem
@@ -425,38 +425,33 @@ impl DocFolder for Cache {
// Once we've recursively found all the generics, hoard off all the
// implementations elsewhere.
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
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
let mut dids = FxHashSet::default();
if let clean::Item { kind: clean::ImplItem(ref i), .. } = item {
match i.for_ {
clean::ResolvedPath { did, .. }
| clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
dids.insert(did);
}
ref t => {
let did = t
.primitive_type()
.and_then(|t| self.primitive_locations.get(&t).cloned());
match i.for_ {
clean::ResolvedPath { did, .. }
| clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
dids.insert(did);
}
ref t => {
let did =
t.primitive_type().and_then(|t| self.primitive_locations.get(&t).cloned());

if let Some(did) = did {
dids.insert(did);
}
if let Some(did) = did {
dids.insert(did);
}
}
}

if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
for bound in generics {
if let Some(did) = bound.def_id() {
dids.insert(did);
}
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
for bound in generics {
if let Some(did) = bound.def_id() {
dids.insert(did);
}
}
} else {
unreachable!()
};
}
let impl_item = Impl { impl_item: item };
if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) {
for did in dids {
2 changes: 1 addition & 1 deletion src/librustdoc/formats/item_type.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ impl Serialize for ItemType {

impl<'a> From<&'a clean::Item> for ItemType {
fn from(item: &'a clean::Item) -> ItemType {
let kind = match item.kind {
let kind = match *item.kind {
clean::StrippedItem(box ref item) => item,
ref kind => kind,
};
2 changes: 1 addition & 1 deletion src/librustdoc/formats/mod.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ crate struct Impl {

impl Impl {
crate fn inner_impl(&self) -> &clean::Impl {
match self.impl_item.kind {
match *self.impl_item.kind {
clean::ImplItem(ref impl_) => impl_,
_ => panic!("non-impl item found in impl"),
}
2 changes: 1 addition & 1 deletion src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>(
}

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,
_ => unreachable!(),
};
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/cache.rs
Original file line number Diff line number Diff line change
@@ -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> {
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::MethodItem(ref m, _) => (&m.all_types, &m.ret_types),
clean::TyMethodItem(ref m) => (&m.all_types, &m.ret_types),
53 changes: 27 additions & 26 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
@@ -633,7 +633,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {

// Render sidebar-items.js used throughout this module.
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,
_ => 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 class=\"in-band\">");
let name = match item.kind {
let name = match *item.kind {
clean::ModuleItem(ref m) => {
if m.is_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

match item.kind {
match *item.kind {
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) => {
item_function(buf, cx, item, f)
@@ -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) => {
use crate::html::format::anchor;

@@ -2185,7 +2185,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
continue;
}

let unsafety_flag = match myitem.kind {
let unsafety_flag = match *myitem.kind {
clean::FunctionItem(ref func) | clean::ForeignFunctionItem(ref func)
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() {
render_assoc_item(w, m, AssocItemLink::Anchor(None), ItemType::Trait, cx);
match m.kind {
match *m.kind {
clean::MethodItem(ref inner, _)
if !inner.generics.where_predicates.is_empty() =>
{
@@ -3051,7 +3051,7 @@ fn render_assoc_item(
where_clause = WhereClause { gens: g, indent, end_newline }
)
}
match item.kind {
match *item.kind {
clean::StrippedItem(..) => {}
clean::TyMethodItem(ref m) => {
method(w, item, m.header, &m.generics, &m.decl, link, parent, cx)
@@ -3098,7 +3098,7 @@ fn item_struct(
let mut fields = s
.fields
.iter()
.filter_map(|f| match f.kind {
.filter_map(|f| match *f.kind {
clean::StructFieldItem(ref ty) => Some((f, ty)),
_ => None,
})
@@ -3148,7 +3148,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
let mut fields = s
.fields
.iter()
.filter_map(|f| match f.kind {
.filter_map(|f| match *f.kind {
clean::StructFieldItem(ref ty) => Some((f, ty)),
_ => None,
})
@@ -3201,7 +3201,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
for v in &e.variants {
write!(w, " ");
let name = v.name.as_ref().unwrap();
match v.kind {
match *v.kind {
clean::VariantItem(ref var) => match var.kind {
clean::VariantKind::CLike => write!(w, "{}", name),
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,
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 {
write!(w, "(");
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);

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!(
"{}.{}.fields",
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 {
use crate::clean::StructFieldItem;
if let StructFieldItem(ref ty) = field.kind {
if let StructFieldItem(ref ty) = *field.kind {
let id = cx.derive_id(format!(
"variant.{}.field.{}",
variant.name.as_ref().unwrap(),
@@ -3379,7 +3380,7 @@ fn render_struct(
let mut has_visible_fields = false;
write!(w, " {{");
for field in fields {
if let clean::StructFieldItem(ref ty) = field.kind {
if let clean::StructFieldItem(ref ty) = *field.kind {
write!(
w,
"\n{} {}{}: {},",
@@ -3410,7 +3411,7 @@ fn render_struct(
if i > 0 {
write!(w, ", ");
}
match field.kind {
match *field.kind {
clean::StrippedItem(box clean::StructFieldItem(..)) => write!(w, "_"),
clean::StructFieldItem(ref ty) => {
write!(w, "{}{}", field.visibility.print_with_space(cx.tcx()), ty.print())
@@ -3457,7 +3458,7 @@ fn render_union(

write!(w, " {{\n{}", tab);
for field in fields {
if let clean::StructFieldItem(ref ty) = field.kind {
if let clean::StructFieldItem(ref ty) = *field.kind {
write!(
w,
" {}{}: {},\n{}",
@@ -3619,7 +3620,7 @@ fn render_deref_methods(
.inner_impl()
.items
.iter()
.find_map(|item| match item.kind {
.find_map(|item| match *item.kind {
clean::TypedefItem(ref t, true) => Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
_ => (&t.type_, &t.type_),
@@ -3641,7 +3642,7 @@ fn render_deref_methods(
}

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::TyMethodItem(ref method) => method.decl.self_type(),
_ => None,
@@ -3692,7 +3693,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
));
let t_did = impl_.trait_.def_id().unwrap();
for it in &impl_.items {
if let clean::TypedefItem(ref tydef, _) = it.kind {
if let clean::TypedefItem(ref tydef, _) = *it.kind {
out.push_str("<span class=\"where fmt-newline\"> ");
assoc_type(
&mut out,
@@ -3764,7 +3765,7 @@ fn render_impl(
fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute);
if show_def_docs {
for it in &i.inner_impl().items {
if let clean::TypedefItem(ref tydef, _) = it.kind {
if let clean::TypedefItem(ref tydef, _) = *it.kind {
write!(w, "<span class=\"where fmt-newline\"> ");
assoc_type(w, it, &[], Some(&tydef.type_), AssocItemLink::Anchor(None), "");
write!(w, ";</span>");
@@ -3846,7 +3847,7 @@ fn render_impl(
} else {
(true, " hidden")
};
match item.kind {
match *item.kind {
clean::MethodItem(..) | clean::TyMethodItem(_) => {
// Only render when the method is not static or we allow static methods
if render_method_item {
@@ -4123,7 +4124,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache:
write!(
buffer,
"<p class=\"location\">{}{}</p>",
match it.kind {
match *it.kind {
clean::StructItem(..) => "Struct ",
clean::TraitItem(..) => "Trait ",
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")
);
}
match it.kind {
match *it.kind {
clean::StructItem(ref s) => sidebar_struct(buffer, it, s),
clean::TraitItem(ref t) => sidebar_trait(buffer, it, t),
clean::PrimitiveItem(_) => sidebar_primitive(buffer, it),
@@ -4303,7 +4304,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
.find(|i| i.inner_impl().trait_.def_id() == c.deref_trait_did)
{
if let Some((target, real_target)) =
impl_.inner_impl().items.iter().find_map(|item| match item.kind {
impl_.inner_impl().items.iter().find_map(|item| match *item.kind {
clean::TypedefItem(ref t, true) => Some(match *t {
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
_ => (&t.type_, &t.type_),
@@ -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)> {
match item.kind {
match *item.kind {
clean::ItemKind::ImplItem(ref i) => {
if let Some(ref trait_) = i.trait_ {
Some((
@@ -4593,7 +4594,7 @@ fn sidebar_typedef(buf: &mut Buffer, it: &clean::Item) {
fn get_struct_fields_name(fields: &[clean::Item]) -> String {
let mut fields = fields
.iter()
.filter(|f| if let clean::StructFieldItem(..) = f.kind { true } else { false })
.filter(|f| matches!(*f.kind, clean::StructFieldItem(..)))
.filter_map(|f| match f.name {
Some(ref name) => {
Some(format!("<a href=\"#structfield.{name}\">{name}</a>", name = name))
4 changes: 2 additions & 2 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
@@ -19,9 +19,9 @@ impl JsonRenderer<'_> {
let item_type = ItemType::from(&item);
let deprecation = item.deprecation(self.tcx);
let clean::Item { source, name, attrs, kind, visibility, def_id } = item;
match kind {
match *kind {
clean::StrippedItem(_) => None,
_ => Some(Item {
kind => Some(Item {
id: def_id.into(),
crate_id: def_id.krate.as_u32(),
name: name.map(|sym| sym.to_string()),
4 changes: 2 additions & 2 deletions src/librustdoc/json/mod.rs
Original file line number Diff line number Diff line change
@@ -178,9 +178,9 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
cache: &Cache,
) -> Result<(), Error> {
use clean::types::ItemKind::*;
if let ModuleItem(m) = &item.kind {
if let ModuleItem(m) = &*item.kind {
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
ImportItem(_) => self.item(item.clone(), cache).unwrap(),
ExternCrateItem(_, _) => self.item(item.clone(), cache).unwrap(),
2 changes: 1 addition & 1 deletion src/librustdoc/passes/calculate_doc_coverage.rs
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ impl<'a, 'b> CoverageCalculator<'a, 'b> {

impl<'a, 'b> fold::DocFolder for CoverageCalculator<'a, 'b> {
fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
match i.kind {
match *i.kind {
_ if !i.def_id.is_local() => {
// non-local items are skipped because they can be out of the users control,
// especially in the case of trait impls, which rustdoc eagerly inlines
8 changes: 4 additions & 4 deletions src/librustdoc/passes/collect_trait_impls.rs
Original file line number Diff line number Diff line change
@@ -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
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() {
let target = items
.iter()
.find_map(|item| match item.kind {
.find_map(|item| match *item.kind {
TypedefItem(ref t, true) => Some(&t.type_),
_ => None,
})
@@ -78,7 +78,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
}

new_items.retain(|it| {
if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = it.kind {
if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = *it.kind {
cleaner.keep_item(for_)
|| trait_.as_ref().map_or(false, |t| cleaner.keep_item(t))
|| blanket_impl.is_some()
@@ -124,7 +124,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
}

if let Some(ref mut it) = krate.module {
if let ModuleItem(Module { ref mut items, .. }) = it.kind {
if let ModuleItem(Module { ref mut items, .. }) = *it.kind {
items.extend(synth.impls);
items.extend(new_items);
} else {
2 changes: 1 addition & 1 deletion src/librustdoc/passes/doc_test_lints.rs
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ impl crate::doctest::Tester for Tests {

crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
if matches!(
item.kind,
*item.kind,
clean::StructFieldItem(_)
| clean::VariantItem(_)
| clean::AssocConstItem(_, _)
2 changes: 1 addition & 1 deletion src/librustdoc/passes/strip_hidden.rs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ impl<'a> DocFolder for Stripper<'a> {
if i.attrs.lists(sym::doc).has_word(sym::hidden) {
debug!("strip_hidden: stripping {:?} {:?}", i.type_(), i.name);
// use a dedicated hidden item for given item type if any
match i.kind {
match *i.kind {
clean::StructFieldItem(..) | clean::ModuleItem(..) => {
// We need to recurse into stripped modules to
// strip things like impl methods but when doing so
8 changes: 4 additions & 4 deletions src/librustdoc/passes/stripper.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ crate struct Stripper<'a> {

impl<'a> DocFolder for Stripper<'a> {
fn fold_item(&mut self, i: Item) -> Option<Item> {
match i.kind {
match *i.kind {
clean::StrippedItem(..) => {
// We need to recurse into stripped modules to strip things
// like impl methods but when doing so we must not add any
@@ -86,7 +86,7 @@ impl<'a> DocFolder for Stripper<'a> {
clean::KeywordItem(..) => {}
}

let fastreturn = match i.kind {
let fastreturn = match *i.kind {
// nothing left to do for traits (don't want to filter their
// methods out, visibility controlled by the trait)
clean::TraitItem(..) => true,
@@ -121,7 +121,7 @@ crate struct ImplStripper<'a> {

impl<'a> DocFolder for ImplStripper<'a> {
fn fold_item(&mut self, i: Item) -> Option<Item> {
if let clean::ImplItem(ref imp) = i.kind {
if let clean::ImplItem(ref imp) = *i.kind {
// emptied none trait impls can be stripped
if imp.trait_.is_none() && imp.items.is_empty() {
return None;
@@ -160,7 +160,7 @@ crate struct ImportStripper;

impl DocFolder for ImportStripper {
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,
_ => Some(self.fold_item_recur(i)),
}