Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 712463d

Browse files
committedSep 9, 2024
Auto merge of #129789 - notriddle:notriddle/inline-stmt-local, r=GuillaumeGomez
rustdoc: use strategic boxing to shrink `clean::Item` * `inline_stmt_id` is never a cross-crate DefId, so save space by not storing it. * Instead of two inner boxes for `Item`, use one.
2 parents c2f74c3 + 6590336 commit 712463d

28 files changed

+215
-197
lines changed
 

‎src/librustdoc/clean/auto_trait.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,19 @@ fn synthesize_auto_trait_impl<'tcx>(
115115

116116
Some(clean::Item {
117117
name: None,
118-
attrs: Default::default(),
118+
inner: Box::new(clean::ItemInner {
119+
attrs: Default::default(),
120+
kind: clean::ImplItem(Box::new(clean::Impl {
121+
safety: hir::Safety::Safe,
122+
generics,
123+
trait_: Some(clean_trait_ref_with_constraints(cx, trait_ref, ThinVec::new())),
124+
for_: clean_middle_ty(ty::Binder::dummy(ty), cx, None, None),
125+
items: Vec::new(),
126+
polarity,
127+
kind: clean::ImplKind::Auto,
128+
})),
129+
}),
119130
item_id: clean::ItemId::Auto { trait_: trait_def_id, for_: item_def_id },
120-
kind: Box::new(clean::ImplItem(Box::new(clean::Impl {
121-
safety: hir::Safety::Safe,
122-
generics,
123-
trait_: Some(clean_trait_ref_with_constraints(cx, trait_ref, ThinVec::new())),
124-
for_: clean_middle_ty(ty::Binder::dummy(ty), cx, None, None),
125-
items: Vec::new(),
126-
polarity,
127-
kind: clean::ImplKind::Auto,
128-
}))),
129131
cfg: None,
130132
inline_stmt_id: None,
131133
})

‎src/librustdoc/clean/blanket_impl.rs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,42 +84,44 @@ pub(crate) fn synthesize_blanket_impls(
8484

8585
blanket_impls.push(clean::Item {
8686
name: None,
87-
attrs: Default::default(),
8887
item_id: clean::ItemId::Blanket { impl_id: impl_def_id, for_: item_def_id },
89-
kind: Box::new(clean::ImplItem(Box::new(clean::Impl {
90-
safety: hir::Safety::Safe,
91-
generics: clean_ty_generics(
92-
cx,
93-
tcx.generics_of(impl_def_id),
94-
tcx.explicit_predicates_of(impl_def_id),
95-
),
96-
// FIXME(eddyb) compute both `trait_` and `for_` from
97-
// the post-inference `trait_ref`, as it's more accurate.
98-
trait_: Some(clean_trait_ref_with_constraints(
99-
cx,
100-
ty::Binder::dummy(trait_ref.instantiate_identity()),
101-
ThinVec::new(),
102-
)),
103-
for_: clean_middle_ty(
104-
ty::Binder::dummy(ty.instantiate_identity()),
105-
cx,
106-
None,
107-
None,
108-
),
109-
items: tcx
110-
.associated_items(impl_def_id)
111-
.in_definition_order()
112-
.filter(|item| !item.is_impl_trait_in_trait())
113-
.map(|item| clean_middle_assoc_item(item, cx))
114-
.collect(),
115-
polarity: ty::ImplPolarity::Positive,
116-
kind: clean::ImplKind::Blanket(Box::new(clean_middle_ty(
117-
ty::Binder::dummy(trait_ref.instantiate_identity().self_ty()),
118-
cx,
119-
None,
120-
None,
121-
))),
122-
}))),
88+
inner: Box::new(clean::ItemInner {
89+
attrs: Default::default(),
90+
kind: clean::ImplItem(Box::new(clean::Impl {
91+
safety: hir::Safety::Safe,
92+
generics: clean_ty_generics(
93+
cx,
94+
tcx.generics_of(impl_def_id),
95+
tcx.explicit_predicates_of(impl_def_id),
96+
),
97+
// FIXME(eddyb) compute both `trait_` and `for_` from
98+
// the post-inference `trait_ref`, as it's more accurate.
99+
trait_: Some(clean_trait_ref_with_constraints(
100+
cx,
101+
ty::Binder::dummy(trait_ref.instantiate_identity()),
102+
ThinVec::new(),
103+
)),
104+
for_: clean_middle_ty(
105+
ty::Binder::dummy(ty.instantiate_identity()),
106+
cx,
107+
None,
108+
None,
109+
),
110+
items: tcx
111+
.associated_items(impl_def_id)
112+
.in_definition_order()
113+
.filter(|item| !item.is_impl_trait_in_trait())
114+
.map(|item| clean_middle_assoc_item(item, cx))
115+
.collect(),
116+
polarity: ty::ImplPolarity::Positive,
117+
kind: clean::ImplKind::Blanket(Box::new(clean_middle_ty(
118+
ty::Binder::dummy(trait_ref.instantiate_identity().self_ty()),
119+
cx,
120+
None,
121+
None,
122+
))),
123+
})),
124+
}),
123125
cfg: None,
124126
inline_stmt_id: None,
125127
});

‎src/librustdoc/clean/inline.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55

66
use rustc_data_structures::fx::FxHashSet;
77
use rustc_hir::def::{DefKind, Res};
8-
use rustc_hir::def_id::{DefId, DefIdSet, LocalModDefId};
8+
use rustc_hir::def_id::{DefId, DefIdSet, LocalDefId, LocalModDefId};
99
use rustc_hir::Mutability;
1010
use rustc_metadata::creader::{CStore, LoadedMacro};
1111
use rustc_middle::ty::fast_reject::SimplifiedType;
@@ -43,7 +43,7 @@ pub(crate) fn try_inline(
4343
cx: &mut DocContext<'_>,
4444
res: Res,
4545
name: Symbol,
46-
attrs: Option<(&[ast::Attribute], Option<DefId>)>,
46+
attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>,
4747
visited: &mut DefIdSet,
4848
) -> Option<Vec<clean::Item>> {
4949
let did = res.opt_def_id()?;
@@ -152,14 +152,8 @@ pub(crate) fn try_inline(
152152
};
153153

154154
cx.inlined.insert(did.into());
155-
let mut item = crate::clean::generate_item_with_correct_attrs(
156-
cx,
157-
kind,
158-
did,
159-
name,
160-
import_def_id.and_then(|def_id| def_id.as_local()),
161-
None,
162-
);
155+
let mut item =
156+
crate::clean::generate_item_with_correct_attrs(cx, kind, did, name, import_def_id, None);
163157
// The visibility needs to reflect the one from the reexport and not from the "source" DefId.
164158
item.inline_stmt_id = import_def_id;
165159
ret.push(item);
@@ -198,7 +192,7 @@ pub(crate) fn try_inline_glob(
198192
visited,
199193
inlined_names,
200194
Some(&reexports),
201-
Some((attrs, Some(import.owner_id.def_id.to_def_id()))),
195+
Some((attrs, Some(import.owner_id.def_id))),
202196
);
203197
items.retain(|item| {
204198
if let Some(name) = item.name {
@@ -372,7 +366,7 @@ fn build_type_alias(
372366
pub(crate) fn build_impls(
373367
cx: &mut DocContext<'_>,
374368
did: DefId,
375-
attrs: Option<(&[ast::Attribute], Option<DefId>)>,
369+
attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>,
376370
ret: &mut Vec<clean::Item>,
377371
) {
378372
let _prof_timer = cx.tcx.sess.prof.generic_activity("build_inherent_impls");
@@ -405,7 +399,7 @@ pub(crate) fn build_impls(
405399
pub(crate) fn merge_attrs(
406400
cx: &mut DocContext<'_>,
407401
old_attrs: &[ast::Attribute],
408-
new_attrs: Option<(&[ast::Attribute], Option<DefId>)>,
402+
new_attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>,
409403
) -> (clean::Attributes, Option<Arc<clean::cfg::Cfg>>) {
410404
// NOTE: If we have additional attributes (from a re-export),
411405
// always insert them first. This ensure that re-export
@@ -416,7 +410,7 @@ pub(crate) fn merge_attrs(
416410
both.extend_from_slice(old_attrs);
417411
(
418412
if let Some(item_id) = item_id {
419-
Attributes::from_ast_with_additional(old_attrs, (inner, item_id))
413+
Attributes::from_ast_with_additional(old_attrs, (inner, item_id.to_def_id()))
420414
} else {
421415
Attributes::from_ast(&both)
422416
},
@@ -431,7 +425,7 @@ pub(crate) fn merge_attrs(
431425
pub(crate) fn build_impl(
432426
cx: &mut DocContext<'_>,
433427
did: DefId,
434-
attrs: Option<(&[ast::Attribute], Option<DefId>)>,
428+
attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>,
435429
ret: &mut Vec<clean::Item>,
436430
) {
437431
if !cx.inlined.insert(did.into()) {
@@ -623,7 +617,7 @@ pub(crate) fn build_impl(
623617
ImplKind::Normal
624618
},
625619
})),
626-
Box::new(merged_attrs),
620+
merged_attrs,
627621
cfg,
628622
));
629623
}
@@ -641,7 +635,7 @@ fn build_module_items(
641635
visited: &mut DefIdSet,
642636
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
643637
allowed_def_ids: Option<&DefIdSet>,
644-
attrs: Option<(&[ast::Attribute], Option<DefId>)>,
638+
attrs: Option<(&[ast::Attribute], Option<LocalDefId>)>,
645639
) -> Vec<clean::Item> {
646640
let mut items = Vec::new();
647641

@@ -673,27 +667,29 @@ fn build_module_items(
673667
let prim_ty = clean::PrimitiveType::from(p);
674668
items.push(clean::Item {
675669
name: None,
676-
attrs: Box::default(),
677670
// We can use the item's `DefId` directly since the only information ever used
678671
// from it is `DefId.krate`.
679672
item_id: ItemId::DefId(did),
680-
kind: Box::new(clean::ImportItem(clean::Import::new_simple(
681-
item.ident.name,
682-
clean::ImportSource {
683-
path: clean::Path {
684-
res,
685-
segments: thin_vec![clean::PathSegment {
686-
name: prim_ty.as_sym(),
687-
args: clean::GenericArgs::AngleBracketed {
688-
args: Default::default(),
689-
constraints: ThinVec::new(),
690-
},
691-
}],
673+
inner: Box::new(clean::ItemInner {
674+
attrs: Default::default(),
675+
kind: clean::ImportItem(clean::Import::new_simple(
676+
item.ident.name,
677+
clean::ImportSource {
678+
path: clean::Path {
679+
res,
680+
segments: thin_vec![clean::PathSegment {
681+
name: prim_ty.as_sym(),
682+
args: clean::GenericArgs::AngleBracketed {
683+
args: Default::default(),
684+
constraints: ThinVec::new(),
685+
},
686+
}],
687+
},
688+
did: None,
692689
},
693-
did: None,
694-
},
695-
true,
696-
))),
690+
true,
691+
)),
692+
}),
697693
cfg: None,
698694
inline_stmt_id: None,
699695
});
@@ -745,15 +741,16 @@ fn build_macro(
745741
cx: &mut DocContext<'_>,
746742
def_id: DefId,
747743
name: Symbol,
748-
import_def_id: Option<DefId>,
744+
import_def_id: Option<LocalDefId>,
749745
macro_kind: MacroKind,
750746
is_doc_hidden: bool,
751747
) -> clean::ItemKind {
752748
match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.tcx) {
753749
LoadedMacro::MacroDef(item_def, _) => match macro_kind {
754750
MacroKind::Bang => {
755751
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
756-
let vis = cx.tcx.visibility(import_def_id.unwrap_or(def_id));
752+
let vis =
753+
cx.tcx.visibility(import_def_id.map(|d| d.to_def_id()).unwrap_or(def_id));
757754
clean::MacroItem(clean::Macro {
758755
source: utils::display_macro_source(
759756
cx,

‎src/librustdoc/clean/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ fn generate_item_with_correct_attrs(
203203
let attrs = Attributes::from_ast_iter(attrs.iter().map(|(attr, did)| (&**attr, *did)), false);
204204

205205
let name = renamed.or(Some(name));
206-
let mut item = Item::from_def_id_and_attrs_and_parts(def_id, name, kind, Box::new(attrs), cfg);
207-
item.inline_stmt_id = import_id.map(|local| local.to_def_id());
206+
let mut item = Item::from_def_id_and_attrs_and_parts(def_id, name, kind, attrs, cfg);
207+
item.inline_stmt_id = import_id;
208208
item
209209
}
210210

@@ -2927,7 +2927,7 @@ fn clean_extern_crate<'tcx>(
29272927
})
29282928
&& !cx.output_format.is_json();
29292929

2930-
let krate_owner_def_id = krate.owner_id.to_def_id();
2930+
let krate_owner_def_id = krate.owner_id.def_id;
29312931
if please_inline {
29322932
if let Some(items) = inline::try_inline(
29332933
cx,
@@ -2941,7 +2941,7 @@ fn clean_extern_crate<'tcx>(
29412941
}
29422942

29432943
vec![Item::from_def_id_and_parts(
2944-
krate_owner_def_id,
2944+
krate_owner_def_id.to_def_id(),
29452945
Some(name),
29462946
ExternCrateItem { src: orig_name },
29472947
cx,
@@ -2988,7 +2988,7 @@ fn clean_use_statement_inner<'tcx>(
29882988
let inline_attr = attrs.lists(sym::doc).get_word_attr(sym::inline);
29892989
let pub_underscore = visibility.is_public() && name == kw::Underscore;
29902990
let current_mod = cx.tcx.parent_module_from_def_id(import.owner_id.def_id);
2991-
let import_def_id = import.owner_id.def_id.to_def_id();
2991+
let import_def_id = import.owner_id.def_id;
29922992

29932993
// The parent of the module in which this import resides. This
29942994
// is the same as `current_mod` if that's already the top
@@ -3071,7 +3071,7 @@ fn clean_use_statement_inner<'tcx>(
30713071
)
30723072
{
30733073
items.push(Item::from_def_id_and_parts(
3074-
import_def_id,
3074+
import_def_id.to_def_id(),
30753075
None,
30763076
ImportItem(Import::new_simple(name, resolve_use_source(cx, path), false)),
30773077
cx,
@@ -3081,7 +3081,7 @@ fn clean_use_statement_inner<'tcx>(
30813081
Import::new_simple(name, resolve_use_source(cx, path), true)
30823082
};
30833083

3084-
vec![Item::from_def_id_and_parts(import_def_id, None, ImportItem(inner), cx)]
3084+
vec![Item::from_def_id_and_parts(import_def_id.to_def_id(), None, ImportItem(inner), cx)]
30853085
}
30863086

30873087
fn clean_maybe_renamed_foreign_item<'tcx>(

‎src/librustdoc/clean/types.rs

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,30 @@ pub(crate) struct Item {
320320
/// The name of this item.
321321
/// Optional because not every item has a name, e.g. impls.
322322
pub(crate) name: Option<Symbol>,
323-
pub(crate) attrs: Box<Attributes>,
324-
/// Information about this item that is specific to what kind of item it is.
325-
/// E.g., struct vs enum vs function.
326-
pub(crate) kind: Box<ItemKind>,
323+
pub(crate) inner: Box<ItemInner>,
327324
pub(crate) item_id: ItemId,
328-
/// This is the `DefId` of the `use` statement if the item was inlined.
329-
pub(crate) inline_stmt_id: Option<DefId>,
325+
/// This is the `LocalDefId` of the `use` statement if the item was inlined.
326+
/// The crate metadata doesn't hold this information, so the `use` statement
327+
/// always belongs to the current crate.
328+
pub(crate) inline_stmt_id: Option<LocalDefId>,
330329
pub(crate) cfg: Option<Arc<Cfg>>,
331330
}
332331

332+
#[derive(Clone)]
333+
pub(crate) struct ItemInner {
334+
/// Information about this item that is specific to what kind of item it is.
335+
/// E.g., struct vs enum vs function.
336+
pub(crate) kind: ItemKind,
337+
pub(crate) attrs: Attributes,
338+
}
339+
340+
impl std::ops::Deref for Item {
341+
type Target = ItemInner;
342+
fn deref(&self) -> &ItemInner {
343+
&*self.inner
344+
}
345+
}
346+
333347
/// NOTE: this does NOT unconditionally print every item, to avoid thousands of lines of logs.
334348
/// If you want to see the debug output for attributes and the `kind` as well, use `{:#?}` instead of `{:?}`.
335349
impl fmt::Debug for Item {
@@ -389,9 +403,9 @@ impl Item {
389403
}
390404

391405
pub(crate) fn span(&self, tcx: TyCtxt<'_>) -> Option<Span> {
392-
let kind = match &*self.kind {
393-
ItemKind::StrippedItem(k) => k,
394-
_ => &*self.kind,
406+
let kind = match &self.kind {
407+
ItemKind::StrippedItem(k) => &*k,
408+
_ => &self.kind,
395409
};
396410
match kind {
397411
ItemKind::ModuleItem(Module { span, .. }) => Some(*span),
@@ -436,7 +450,7 @@ impl Item {
436450
def_id,
437451
name,
438452
kind,
439-
Box::new(Attributes::from_ast(ast_attrs)),
453+
Attributes::from_ast(ast_attrs),
440454
ast_attrs.cfg(cx.tcx, &cx.cache.hidden_cfg),
441455
)
442456
}
@@ -445,16 +459,15 @@ impl Item {
445459
def_id: DefId,
446460
name: Option<Symbol>,
447461
kind: ItemKind,
448-
attrs: Box<Attributes>,
462+
attrs: Attributes,
449463
cfg: Option<Arc<Cfg>>,
450464
) -> Item {
451465
trace!("name={name:?}, def_id={def_id:?} cfg={cfg:?}");
452466

453467
Item {
454468
item_id: def_id.into(),
455-
kind: Box::new(kind),
469+
inner: Box::new(ItemInner { kind, attrs }),
456470
name,
457-
attrs,
458471
cfg,
459472
inline_stmt_id: None,
460473
}
@@ -522,16 +535,16 @@ impl Item {
522535
self.type_() == ItemType::Variant
523536
}
524537
pub(crate) fn is_associated_type(&self) -> bool {
525-
matches!(&*self.kind, AssocTypeItem(..) | StrippedItem(box AssocTypeItem(..)))
538+
matches!(self.kind, AssocTypeItem(..) | StrippedItem(box AssocTypeItem(..)))
526539
}
527540
pub(crate) fn is_ty_associated_type(&self) -> bool {
528-
matches!(&*self.kind, TyAssocTypeItem(..) | StrippedItem(box TyAssocTypeItem(..)))
541+
matches!(self.kind, TyAssocTypeItem(..) | StrippedItem(box TyAssocTypeItem(..)))
529542
}
530543
pub(crate) fn is_associated_const(&self) -> bool {
531-
matches!(&*self.kind, AssocConstItem(..) | StrippedItem(box AssocConstItem(..)))
544+
matches!(self.kind, AssocConstItem(..) | StrippedItem(box AssocConstItem(..)))
532545
}
533546
pub(crate) fn is_ty_associated_const(&self) -> bool {
534-
matches!(&*self.kind, TyAssocConstItem(..) | StrippedItem(box TyAssocConstItem(..)))
547+
matches!(self.kind, TyAssocConstItem(..) | StrippedItem(box TyAssocConstItem(..)))
535548
}
536549
pub(crate) fn is_method(&self) -> bool {
537550
self.type_() == ItemType::Method
@@ -555,14 +568,14 @@ impl Item {
555568
self.type_() == ItemType::Keyword
556569
}
557570
pub(crate) fn is_stripped(&self) -> bool {
558-
match *self.kind {
571+
match self.kind {
559572
StrippedItem(..) => true,
560573
ImportItem(ref i) => !i.should_be_displayed,
561574
_ => false,
562575
}
563576
}
564577
pub(crate) fn has_stripped_entries(&self) -> Option<bool> {
565-
match *self.kind {
578+
match self.kind {
566579
StructItem(ref struct_) => Some(struct_.has_stripped_entries()),
567580
UnionItem(ref union_) => Some(union_.has_stripped_entries()),
568581
EnumItem(ref enum_) => Some(enum_.has_stripped_entries()),
@@ -605,7 +618,7 @@ impl Item {
605618
}
606619

607620
pub(crate) fn is_default(&self) -> bool {
608-
match *self.kind {
621+
match self.kind {
609622
ItemKind::MethodItem(_, Some(defaultness)) => {
610623
defaultness.has_value() && !defaultness.is_final()
611624
}
@@ -633,7 +646,7 @@ impl Item {
633646
};
634647
hir::FnHeader { safety: sig.safety(), abi: sig.abi(), constness, asyncness }
635648
}
636-
let header = match *self.kind {
649+
let header = match self.kind {
637650
ItemKind::ForeignFunctionItem(_, safety) => {
638651
let def_id = self.def_id().unwrap();
639652
let abi = tcx.fn_sig(def_id).skip_binder().abi();
@@ -672,7 +685,7 @@ impl Item {
672685
ItemId::DefId(def_id) => def_id,
673686
};
674687

675-
match *self.kind {
688+
match self.kind {
676689
// Primitives and Keywords are written in the source code as private modules.
677690
// The modules need to be private so that nobody actually uses them, but the
678691
// keywords and primitives that they are documenting are public.
@@ -702,7 +715,7 @@ impl Item {
702715
_ => {}
703716
}
704717
let def_id = match self.inline_stmt_id {
705-
Some(inlined) => inlined,
718+
Some(inlined) => inlined.to_def_id(),
706719
None => def_id,
707720
};
708721
Some(tcx.visibility(def_id))
@@ -2559,13 +2572,13 @@ mod size_asserts {
25592572

25602573
use super::*;
25612574
// tidy-alphabetical-start
2562-
static_assert_size!(Crate, 64); // frequently moved by-value
2575+
static_assert_size!(Crate, 56); // frequently moved by-value
25632576
static_assert_size!(DocFragment, 32);
25642577
static_assert_size!(GenericArg, 32);
25652578
static_assert_size!(GenericArgs, 32);
25662579
static_assert_size!(GenericParamDef, 40);
25672580
static_assert_size!(Generics, 16);
2568-
static_assert_size!(Item, 56);
2581+
static_assert_size!(Item, 48);
25692582
static_assert_size!(ItemKind, 48);
25702583
static_assert_size!(PathSegment, 40);
25712584
static_assert_size!(Type, 32);

‎src/librustdoc/clean/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
3636
// understood by rustdoc.
3737
let mut module = clean_doc_module(&module, cx);
3838

39-
match *module.kind {
39+
match module.kind {
4040
ItemKind::ModuleItem(ref module) => {
4141
for it in &module.items {
4242
// `compiler_builtins` should be masked too, but we can't apply
@@ -60,7 +60,7 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
6060
let primitives = local_crate.primitives(cx.tcx);
6161
let keywords = local_crate.keywords(cx.tcx);
6262
{
63-
let ItemKind::ModuleItem(ref mut m) = *module.kind else { unreachable!() };
63+
let ItemKind::ModuleItem(ref mut m) = &mut module.inner.kind else { unreachable!() };
6464
m.items.extend(primitives.iter().map(|&(def_id, prim)| {
6565
Item::from_def_id_and_parts(
6666
def_id,
@@ -281,7 +281,7 @@ pub(crate) fn build_deref_target_impls(
281281
let tcx = cx.tcx;
282282

283283
for item in items {
284-
let target = match *item.kind {
284+
let target = match item.kind {
285285
ItemKind::AssocTypeItem(ref t, _) => &t.type_,
286286
_ => continue,
287287
};

‎src/librustdoc/fold.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::clean::*;
22

33
pub(crate) fn strip_item(mut item: Item) -> Item {
4-
if !matches!(*item.kind, StrippedItem(..)) {
5-
item.kind = Box::new(StrippedItem(item.kind));
4+
if !matches!(item.inner.kind, StrippedItem(..)) {
5+
item.inner.kind = StrippedItem(Box::new(item.inner.kind));
66
}
77
item
88
}
@@ -99,10 +99,10 @@ pub(crate) trait DocFolder: Sized {
9999

100100
/// don't override!
101101
fn fold_item_recur(&mut self, mut item: Item) -> Item {
102-
item.kind = Box::new(match *item.kind {
102+
item.inner.kind = match item.inner.kind {
103103
StrippedItem(box i) => StrippedItem(Box::new(self.fold_inner_recur(i))),
104-
_ => self.fold_inner_recur(*item.kind),
105-
});
104+
_ => self.fold_inner_recur(item.inner.kind),
105+
};
106106
item
107107
}
108108

‎src/librustdoc/formats/cache.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
216216

217217
// If this is a stripped module,
218218
// we don't want it or its children in the search index.
219-
let orig_stripped_mod = match *item.kind {
219+
let orig_stripped_mod = match item.kind {
220220
clean::StrippedItem(box clean::ModuleItem(..)) => {
221221
mem::replace(&mut self.cache.stripped_mod, true)
222222
}
@@ -232,7 +232,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
232232

233233
// If the impl is from a masked crate or references something from a
234234
// masked crate then remove it completely.
235-
if let clean::ImplItem(ref i) = *item.kind
235+
if let clean::ImplItem(ref i) = item.kind
236236
&& (self.cache.masked_crates.contains(&item.item_id.krate())
237237
|| i.trait_
238238
.as_ref()
@@ -246,9 +246,9 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
246246

247247
// Propagate a trait method's documentation to all implementors of the
248248
// trait.
249-
if let clean::TraitItem(ref t) = *item.kind {
249+
if let clean::TraitItem(ref t) = item.kind {
250250
self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| (**t).clone());
251-
} else if let clean::ImplItem(ref i) = *item.kind
251+
} else if let clean::ImplItem(ref i) = item.kind
252252
&& let Some(trait_) = &i.trait_
253253
&& !i.kind.is_blanket()
254254
{
@@ -263,7 +263,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
263263
// Index this method for searching later on.
264264
let search_name = if !item.is_stripped() {
265265
item.name.or_else(|| {
266-
if let clean::ImportItem(ref i) = *item.kind
266+
if let clean::ImportItem(ref i) = item.kind
267267
&& let clean::ImportKind::Simple(s) = i.kind
268268
{
269269
Some(s)
@@ -287,7 +287,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
287287
_ => false,
288288
};
289289

290-
match *item.kind {
290+
match item.kind {
291291
clean::StructItem(..)
292292
| clean::EnumItem(..)
293293
| clean::TypeAliasItem(..)
@@ -350,7 +350,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
350350
}
351351

352352
// Maintain the parent stack.
353-
let (item, parent_pushed) = match *item.kind {
353+
let (item, parent_pushed) = match item.kind {
354354
clean::TraitItem(..)
355355
| clean::EnumItem(..)
356356
| clean::ForeignTypeItem
@@ -367,7 +367,11 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
367367

368368
// Once we've recursively found all the generics, hoard off all the
369369
// implementations elsewhere.
370-
let ret = if let clean::Item { kind: box clean::ImplItem(ref i), .. } = item {
370+
let ret = if let clean::Item {
371+
inner: box clean::ItemInner { kind: clean::ImplItem(ref i), .. },
372+
..
373+
} = item
374+
{
371375
// Figure out the id of this impl. This may map to a
372376
// primitive rather than always to a struct/enum.
373377
// Note: matching twice to restrict the lifetime of the `i` borrow.
@@ -436,7 +440,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
436440
fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::Item, name: Symbol) {
437441
// Item has a name, so it must also have a DefId (can't be an impl, let alone a blanket or auto impl).
438442
let item_def_id = item.item_id.as_def_id().unwrap();
439-
let (parent_did, parent_path) = match *item.kind {
443+
let (parent_did, parent_path) = match item.kind {
440444
clean::StrippedItem(..) => return,
441445
clean::AssocConstItem(..) | clean::AssocTypeItem(..)
442446
if cache.parent_stack.last().is_some_and(|parent| parent.is_trait_impl()) =>
@@ -528,7 +532,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
528532
// - It's either an inline, or a true re-export
529533
// - It's got the same name
530534
// - Both of them have the same exact path
531-
let defid = match &*item.kind {
535+
let defid = match &item.kind {
532536
clean::ItemKind::ImportItem(import) => import.source.did.unwrap_or(item_def_id),
533537
_ => item_def_id,
534538
};
@@ -605,7 +609,7 @@ enum ParentStackItem {
605609

606610
impl ParentStackItem {
607611
fn new(item: &clean::Item) -> Self {
608-
match &*item.kind {
612+
match &item.kind {
609613
clean::ItemKind::ImplItem(box clean::Impl { for_, trait_, generics, kind, .. }) => {
610614
ParentStackItem::Impl {
611615
for_: for_.clone(),

‎src/librustdoc/formats/item_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Serialize for ItemType {
7070

7171
impl<'a> From<&'a clean::Item> for ItemType {
7272
fn from(item: &'a clean::Item) -> ItemType {
73-
let kind = match *item.kind {
73+
let kind = match item.kind {
7474
clean::StrippedItem(box ref item) => item,
7575
ref kind => kind,
7676
};

‎src/librustdoc/formats/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) struct Impl {
1616

1717
impl Impl {
1818
pub(crate) fn inner_impl(&self) -> &clean::Impl {
19-
match *self.impl_item.kind {
19+
match self.impl_item.kind {
2020
clean::ImplItem(ref impl_) => impl_,
2121
_ => panic!("non-impl item found in impl"),
2222
}

‎src/librustdoc/formats/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub(crate) fn run_format<'tcx, T: FormatRenderer<'tcx>>(
7777

7878
cx.mod_item_in(&item)?;
7979
let (clean::StrippedItem(box clean::ModuleItem(module)) | clean::ModuleItem(module)) =
80-
*item.kind
80+
item.inner.kind
8181
else {
8282
unreachable!()
8383
};

‎src/librustdoc/html/render/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
800800
// Render sidebar-items.js used throughout this module.
801801
if !self.render_redirect_pages {
802802
let (clean::StrippedItem(box clean::ModuleItem(ref module))
803-
| clean::ModuleItem(ref module)) = *item.kind
803+
| clean::ModuleItem(ref module)) = item.kind
804804
else {
805805
unreachable!()
806806
};

‎src/librustdoc/html/render/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ fn document_full_inner<'a, 'cx: 'a>(
620620
}
621621
}
622622

623-
let kind = match &*item.kind {
623+
let kind = match &item.kind {
624624
clean::ItemKind::StrippedItem(box kind) | kind => kind,
625625
};
626626

@@ -1072,7 +1072,7 @@ fn render_assoc_item(
10721072
cx: &mut Context<'_>,
10731073
render_mode: RenderMode,
10741074
) {
1075-
match &*item.kind {
1075+
match &item.kind {
10761076
clean::StrippedItem(..) => {}
10771077
clean::TyMethodItem(m) => {
10781078
assoc_method(w, item, &m.generics, &m.decl, link, parent, cx, render_mode)
@@ -1350,7 +1350,7 @@ fn render_deref_methods(
13501350
.inner_impl()
13511351
.items
13521352
.iter()
1353-
.find_map(|item| match *item.kind {
1353+
.find_map(|item| match item.kind {
13541354
clean::AssocTypeItem(box ref t, _) => Some(match *t {
13551355
clean::TypeAlias { item_type: Some(ref type_), .. } => (type_, &t.type_),
13561356
_ => (&t.type_, &t.type_),
@@ -1381,7 +1381,7 @@ fn render_deref_methods(
13811381
}
13821382

13831383
fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) -> bool {
1384-
let self_type_opt = match *item.kind {
1384+
let self_type_opt = match item.kind {
13851385
clean::MethodItem(ref method, _) => method.decl.receiver_type(),
13861386
clean::TyMethodItem(ref method) => method.decl.receiver_type(),
13871387
_ => None,
@@ -1491,7 +1491,7 @@ fn notable_traits_decl(ty: &clean::Type, cx: &Context<'_>) -> (String, String) {
14911491

14921492
write!(&mut out, "<div class=\"where\">{}</div>", impl_.print(false, cx));
14931493
for it in &impl_.items {
1494-
if let clean::AssocTypeItem(ref tydef, ref _bounds) = *it.kind {
1494+
if let clean::AssocTypeItem(ref tydef, ref _bounds) = it.kind {
14951495
out.push_str("<div class=\"where\"> ");
14961496
let empty_set = FxHashSet::default();
14971497
let src_link = AssocItemLink::GotoSource(trait_did.into(), &empty_set);
@@ -1659,7 +1659,7 @@ fn render_impl(
16591659
let method_toggle_class = if item_type.is_method() { " method-toggle" } else { "" };
16601660
write!(w, "<details class=\"toggle{method_toggle_class}\" open><summary>");
16611661
}
1662-
match &*item.kind {
1662+
match &item.kind {
16631663
clean::MethodItem(..) | clean::TyMethodItem(_) => {
16641664
// Only render when the method is not static or we allow static methods
16651665
if render_method_item {
@@ -1690,7 +1690,7 @@ fn render_impl(
16901690
w.write_str("</h4></section>");
16911691
}
16921692
}
1693-
clean::TyAssocConstItem(generics, ty) => {
1693+
clean::TyAssocConstItem(ref generics, ref ty) => {
16941694
let source_id = format!("{item_type}.{name}");
16951695
let id = cx.derive_id(&source_id);
16961696
write!(w, "<section id=\"{id}\" class=\"{item_type}{in_trait_class}\">");
@@ -1734,7 +1734,7 @@ fn render_impl(
17341734
);
17351735
w.write_str("</h4></section>");
17361736
}
1737-
clean::TyAssocTypeItem(generics, bounds) => {
1737+
clean::TyAssocTypeItem(ref generics, ref bounds) => {
17381738
let source_id = format!("{item_type}.{name}");
17391739
let id = cx.derive_id(&source_id);
17401740
write!(w, "<section id=\"{id}\" class=\"{item_type}{in_trait_class}\">");
@@ -1808,7 +1808,7 @@ fn render_impl(
18081808

18091809
if !impl_.is_negative_trait_impl() {
18101810
for trait_item in &impl_.items {
1811-
match *trait_item.kind {
1811+
match trait_item.kind {
18121812
clean::MethodItem(..) | clean::TyMethodItem(_) => methods.push(trait_item),
18131813
clean::TyAssocTypeItem(..) | clean::AssocTypeItem(..) => {
18141814
assoc_types.push(trait_item)
@@ -2051,7 +2051,7 @@ pub(crate) fn render_impl_summary(
20512051
write!(w, "{}", inner_impl.print(use_absolute, cx));
20522052
if show_def_docs {
20532053
for it in &inner_impl.items {
2054-
if let clean::AssocTypeItem(ref tydef, ref _bounds) = *it.kind {
2054+
if let clean::AssocTypeItem(ref tydef, ref _bounds) = it.kind {
20552055
w.write_str("<div class=\"where\"> ");
20562056
assoc_type(
20572057
w,
@@ -2172,7 +2172,7 @@ fn get_id_for_impl<'tcx>(tcx: TyCtxt<'tcx>, impl_id: ItemId) -> String {
21722172
}
21732173

21742174
fn extract_for_impl_name(item: &clean::Item, cx: &Context<'_>) -> Option<(String, String)> {
2175-
match *item.kind {
2175+
match item.kind {
21762176
clean::ItemKind::ImplItem(ref i) if i.trait_.is_some() => {
21772177
// Alternative format produces no URLs,
21782178
// so this parameter does nothing.

‎src/librustdoc/html/render/print_item.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn print_where_clause_and_check<'a, 'tcx: 'a>(
178178

179179
pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buffer) {
180180
debug_assert!(!item.is_stripped());
181-
let typ = match *item.kind {
181+
let typ = match item.kind {
182182
clean::ModuleItem(_) => {
183183
if item.is_crate() {
184184
"Crate "
@@ -252,7 +252,7 @@ pub(super) fn print_item(cx: &mut Context<'_>, item: &clean::Item, buf: &mut Buf
252252

253253
item_vars.render_into(buf).unwrap();
254254

255-
match &*item.kind {
255+
match &item.kind {
256256
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
257257
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f, _) => {
258258
item_function(buf, cx, item, f)
@@ -411,7 +411,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
411411
);
412412
}
413413

414-
match *myitem.kind {
414+
match myitem.kind {
415415
clean::ExternCrateItem { ref src } => {
416416
use crate::html::format::anchor;
417417

@@ -477,7 +477,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
477477
continue;
478478
}
479479

480-
let unsafety_flag = match *myitem.kind {
480+
let unsafety_flag = match myitem.kind {
481481
clean::FunctionItem(_) | clean::ForeignFunctionItem(..)
482482
if myitem.fn_header(tcx).unwrap().safety == hir::Safety::Unsafe =>
483483
{
@@ -1439,7 +1439,7 @@ fn item_union(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, s: &clean:
14391439
self.s
14401440
.fields
14411441
.iter()
1442-
.filter_map(|f| match *f.kind {
1442+
.filter_map(|f| match f.kind {
14431443
clean::StructFieldItem(ref ty) => Some((f, ty)),
14441444
_ => None,
14451445
})
@@ -1457,7 +1457,7 @@ fn print_tuple_struct_fields<'a, 'cx: 'a>(
14571457
display_fn(|f| {
14581458
if !s.is_empty()
14591459
&& s.iter().all(|field| {
1460-
matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
1460+
matches!(field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
14611461
})
14621462
{
14631463
return f.write_str("<span class=\"comment\">/* private fields */</span>");
@@ -1467,7 +1467,7 @@ fn print_tuple_struct_fields<'a, 'cx: 'a>(
14671467
if i > 0 {
14681468
f.write_str(", ")?;
14691469
}
1470-
match *ty.kind {
1470+
match ty.kind {
14711471
clean::StrippedItem(box clean::StructFieldItem(_)) => f.write_str("_")?,
14721472
clean::StructFieldItem(ref ty) => write!(f, "{}", ty.print(cx))?,
14731473
_ => unreachable!(),
@@ -1521,7 +1521,7 @@ fn should_show_enum_discriminant(
15211521
) -> bool {
15221522
let mut has_variants_with_value = false;
15231523
for variant in variants {
1524-
if let clean::VariantItem(ref var) = *variant.kind
1524+
if let clean::VariantItem(ref var) = variant.kind
15251525
&& matches!(var.kind, clean::VariantKind::CLike)
15261526
{
15271527
has_variants_with_value |= var.discriminant.is_some();
@@ -1592,7 +1592,7 @@ fn render_enum_fields(
15921592
continue;
15931593
}
15941594
w.write_str(TAB);
1595-
match *v.kind {
1595+
match v.kind {
15961596
clean::VariantItem(ref var) => match var.kind {
15971597
clean::VariantKind::CLike => display_c_like_variant(
15981598
w,
@@ -1659,7 +1659,7 @@ fn item_variants(
16591659
" rightside",
16601660
);
16611661
w.write_str("<h3 class=\"code-header\">");
1662-
if let clean::VariantItem(ref var) = *variant.kind
1662+
if let clean::VariantItem(ref var) = variant.kind
16631663
&& let clean::VariantKind::CLike = var.kind
16641664
{
16651665
display_c_like_variant(
@@ -1675,7 +1675,7 @@ fn item_variants(
16751675
w.write_str(variant.name.unwrap().as_str());
16761676
}
16771677

1678-
let clean::VariantItem(variant_data) = &*variant.kind else { unreachable!() };
1678+
let clean::VariantItem(variant_data) = &variant.kind else { unreachable!() };
16791679

16801680
if let clean::VariantKind::Tuple(ref s) = variant_data.kind {
16811681
write!(w, "({})", print_tuple_struct_fields(cx, s));
@@ -1716,7 +1716,7 @@ fn item_variants(
17161716
document_non_exhaustive(variant)
17171717
);
17181718
for field in fields {
1719-
match *field.kind {
1719+
match field.kind {
17201720
clean::StrippedItem(box clean::StructFieldItem(_)) => {}
17211721
clean::StructFieldItem(ref ty) => {
17221722
let id = cx.derive_id(format!(
@@ -1886,7 +1886,7 @@ fn item_fields(
18861886
) {
18871887
let mut fields = fields
18881888
.iter()
1889-
.filter_map(|f| match *f.kind {
1889+
.filter_map(|f| match f.kind {
18901890
clean::StructFieldItem(ref ty) => Some((f, ty)),
18911891
_ => None,
18921892
})
@@ -2196,14 +2196,14 @@ fn render_union<'a, 'cx: 'a>(
21962196

21972197
write!(f, "{{\n")?;
21982198
let count_fields =
2199-
fields.iter().filter(|field| matches!(*field.kind, clean::StructFieldItem(..))).count();
2199+
fields.iter().filter(|field| matches!(field.kind, clean::StructFieldItem(..))).count();
22002200
let toggle = should_hide_fields(count_fields);
22012201
if toggle {
22022202
toggle_open(&mut f, format_args!("{count_fields} fields"));
22032203
}
22042204

22052205
for field in fields {
2206-
if let clean::StructFieldItem(ref ty) = *field.kind {
2206+
if let clean::StructFieldItem(ref ty) = field.kind {
22072207
write!(
22082208
f,
22092209
" {}{}: {},\n",
@@ -2279,14 +2279,14 @@ fn render_struct_fields(
22792279
w.write_str("{");
22802280
}
22812281
let count_fields =
2282-
fields.iter().filter(|f| matches!(*f.kind, clean::StructFieldItem(..))).count();
2282+
fields.iter().filter(|f| matches!(f.kind, clean::StructFieldItem(..))).count();
22832283
let has_visible_fields = count_fields > 0;
22842284
let toggle = should_hide_fields(count_fields);
22852285
if toggle {
22862286
toggle_open(&mut w, format_args!("{count_fields} fields"));
22872287
}
22882288
for field in fields {
2289-
if let clean::StructFieldItem(ref ty) = *field.kind {
2289+
if let clean::StructFieldItem(ref ty) = field.kind {
22902290
write!(
22912291
w,
22922292
"\n{tab} {vis}{name}: {ty},",
@@ -2314,7 +2314,7 @@ fn render_struct_fields(
23142314
w.write_str("(");
23152315
if !fields.is_empty()
23162316
&& fields.iter().all(|field| {
2317-
matches!(*field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
2317+
matches!(field.kind, clean::StrippedItem(box clean::StructFieldItem(..)))
23182318
})
23192319
{
23202320
write!(w, "<span class=\"comment\">/* private fields */</span>");
@@ -2323,7 +2323,7 @@ fn render_struct_fields(
23232323
if i > 0 {
23242324
w.write_str(", ");
23252325
}
2326-
match *field.kind {
2326+
match field.kind {
23272327
clean::StrippedItem(box clean::StructFieldItem(..)) => write!(w, "_"),
23282328
clean::StructFieldItem(ref ty) => {
23292329
write!(w, "{}{}", visibility_print_with_space(field, cx), ty.print(cx),)

‎src/librustdoc/html/render/search_index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ pub(crate) fn get_function_type_for_search<'tcx>(
758758
None
759759
}
760760
});
761-
let (mut inputs, mut output, where_clause) = match *item.kind {
761+
let (mut inputs, mut output, where_clause) = match item.kind {
762762
clean::FunctionItem(ref f) | clean::MethodItem(ref f, _) | clean::TyMethodItem(ref f) => {
763763
get_fn_inputs_and_outputs(f, tcx, impl_or_trait_generics, cache)
764764
}
@@ -1132,7 +1132,7 @@ fn simplify_fn_type<'tcx, 'a>(
11321132
&& trait_.items.iter().any(|at| at.is_ty_associated_type())
11331133
{
11341134
for assoc_ty in &trait_.items {
1135-
if let clean::ItemKind::TyAssocTypeItem(_generics, bounds) = &*assoc_ty.kind
1135+
if let clean::ItemKind::TyAssocTypeItem(_generics, bounds) = &assoc_ty.kind
11361136
&& let Some(name) = assoc_ty.name
11371137
{
11381138
let idx = -isize::try_from(rgen.len() + 1).unwrap();

‎src/librustdoc/html/render/sidebar.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub(crate) mod filters {
119119
pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
120120
let mut ids = IdMap::new();
121121
let mut blocks: Vec<LinkBlock<'_>> = docblock_toc(cx, it, &mut ids).into_iter().collect();
122-
match *it.kind {
122+
match it.kind {
123123
clean::StructItem(ref s) => sidebar_struct(cx, it, s, &mut blocks),
124124
clean::TraitItem(ref t) => sidebar_trait(cx, it, t, &mut blocks),
125125
clean::PrimitiveItem(_) => sidebar_primitive(cx, it, &mut blocks),
@@ -143,7 +143,7 @@ pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buf
143143
// crate title is displayed as part of logo lockup
144144
let (title_prefix, title) = if !blocks.is_empty() && !it.is_crate() {
145145
(
146-
match *it.kind {
146+
match it.kind {
147147
clean::ModuleItem(..) => "Module ",
148148
_ => "",
149149
},
@@ -181,7 +181,7 @@ pub(super) fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buf
181181
fn get_struct_fields_name<'a>(fields: &'a [clean::Item]) -> Vec<Link<'a>> {
182182
let mut fields = fields
183183
.iter()
184-
.filter(|f| matches!(*f.kind, clean::StructFieldItem(..)))
184+
.filter(|f| matches!(f.kind, clean::StructFieldItem(..)))
185185
.filter_map(|f| {
186186
f.name.as_ref().map(|name| Link::new(format!("structfield.{name}"), name.as_str()))
187187
})
@@ -467,7 +467,7 @@ fn sidebar_deref_methods<'a>(
467467

468468
debug!("found Deref: {impl_:?}");
469469
if let Some((target, real_target)) =
470-
impl_.inner_impl().items.iter().find_map(|item| match *item.kind {
470+
impl_.inner_impl().items.iter().find_map(|item| match item.kind {
471471
clean::AssocTypeItem(box ref t, _) => Some(match *t {
472472
clean::TypeAlias { item_type: Some(ref type_), .. } => (type_, &t.type_),
473473
_ => (&t.type_, &t.type_),
@@ -587,7 +587,7 @@ fn sidebar_module(
587587
&& it
588588
.name
589589
.or_else(|| {
590-
if let clean::ImportItem(ref i) = *it.kind
590+
if let clean::ImportItem(ref i) = it.kind
591591
&& let clean::ImportKind::Simple(s) = i.kind
592592
{
593593
Some(s)

‎src/librustdoc/html/render/write_shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ impl<'cx, 'cache> DocVisitor for TypeImplCollector<'cx, 'cache> {
783783
fn visit_item(&mut self, it: &Item) {
784784
self.visit_item_recur(it);
785785
let cache = self.cache;
786-
let ItemKind::TypeAliasItem(ref t) = *it.kind else { return };
786+
let ItemKind::TypeAliasItem(ref t) = it.kind else { return };
787787
let Some(self_did) = it.item_id.as_def_id() else { return };
788788
if !self.visited_aliases.insert(self_did) {
789789
return;

‎src/librustdoc/json/conversions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl JsonRenderer<'_> {
4949
let visibility = item.visibility(self.tcx);
5050
let clean::Item { name, item_id, .. } = item;
5151
let id = id_from_item(&item, self.tcx);
52-
let inner = match *item.kind {
52+
let inner = match item.kind {
5353
clean::KeywordItem => return None,
5454
clean::StrippedItem(ref inner) => {
5555
match &**inner {
@@ -294,7 +294,7 @@ pub(crate) fn id_from_item_inner(
294294
}
295295

296296
pub(crate) fn id_from_item(item: &clean::Item, tcx: TyCtxt<'_>) -> Id {
297-
match *item.kind {
297+
match item.kind {
298298
clean::ItemKind::ImportItem(ref import) => {
299299
let extra =
300300
import.source.did.map(ItemId::from).map(|i| id_from_item_inner(i, tcx, None, None));
@@ -310,7 +310,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
310310
let is_crate = item.is_crate();
311311
let header = item.fn_header(tcx);
312312

313-
match *item.kind {
313+
match item.inner.kind {
314314
ModuleItem(m) => {
315315
ItemEnum::Module(Module { is_crate, items: ids(m.items, tcx), is_stripped: false })
316316
}

‎src/librustdoc/json/import_finder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct ImportFinder {
2424

2525
impl DocFolder for ImportFinder {
2626
fn fold_item(&mut self, i: Item) -> Option<Item> {
27-
match *i.kind {
27+
match i.kind {
2828
clean::ImportItem(Import { source: ImportSource { did: Some(did), .. }, .. }) => {
2929
self.imported.insert(did);
3030
Some(i)

‎src/librustdoc/json/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'tcx> JsonRenderer<'tcx> {
8585
// document primitive items in an arbitrary crate by using
8686
// `rustc_doc_primitive`.
8787
let mut is_primitive_impl = false;
88-
if let clean::types::ItemKind::ImplItem(ref impl_) = *item.kind
88+
if let clean::types::ItemKind::ImplItem(ref impl_) = item.kind
8989
&& impl_.trait_.is_none()
9090
&& let clean::types::Type::Primitive(_) = impl_.for_
9191
{
@@ -164,7 +164,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
164164

165165
// Flatten items that recursively store other items. We include orphaned items from
166166
// stripped modules and etc that are otherwise reachable.
167-
if let ItemKind::StrippedItem(inner) = &*item.kind {
167+
if let ItemKind::StrippedItem(inner) = &item.kind {
168168
inner.inner_items().for_each(|i| self.item(i.clone()).unwrap());
169169
}
170170

‎src/librustdoc/passes/calculate_doc_coverage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'a, 'b> DocVisitor for CoverageCalculator<'a, 'b> {
195195
return;
196196
}
197197

198-
match *i.kind {
198+
match i.kind {
199199
clean::StrippedItem(..) => {
200200
// don't count items in stripped modules
201201
return;

‎src/librustdoc/passes/check_doc_test_visibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl crate::doctest::DocTestVisitor for Tests {
5757
pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
5858
if !cx.cache.effective_visibilities.is_directly_public(cx.tcx, item.item_id.expect_def_id())
5959
|| matches!(
60-
*item.kind,
60+
item.kind,
6161
clean::StructFieldItem(_)
6262
| clean::VariantItem(_)
6363
| clean::AssocConstItem(..)

‎src/librustdoc/passes/collect_trait_impls.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
160160

161161
// scan through included items ahead of time to splice in Deref targets to the "valid" sets
162162
for it in new_items_external.iter().chain(new_items_local.iter()) {
163-
if let ImplItem(box Impl { ref for_, ref trait_, ref items, .. }) = *it.kind
163+
if let ImplItem(box Impl { ref for_, ref trait_, ref items, .. }) = it.kind
164164
&& trait_.as_ref().map(|t| t.def_id()) == tcx.lang_items().deref_trait()
165165
&& cleaner.keep_impl(for_, true)
166166
{
167167
let target = items
168168
.iter()
169-
.find_map(|item| match *item.kind {
169+
.find_map(|item| match item.kind {
170170
AssocTypeItem(ref t, _) => Some(&t.type_),
171171
_ => None,
172172
})
@@ -200,7 +200,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
200200

201201
// Filter out external items that are not needed
202202
new_items_external.retain(|it| {
203-
if let ImplItem(box Impl { ref for_, ref trait_, ref kind, .. }) = *it.kind {
203+
if let ImplItem(box Impl { ref for_, ref trait_, ref kind, .. }) = it.kind {
204204
cleaner.keep_impl(
205205
for_,
206206
trait_.as_ref().map(|t| t.def_id()) == tcx.lang_items().deref_trait(),
@@ -211,7 +211,7 @@ pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) ->
211211
}
212212
});
213213

214-
if let ModuleItem(Module { items, .. }) = &mut *krate.module.kind {
214+
if let ModuleItem(Module { items, .. }) = &mut krate.module.inner.kind {
215215
items.extend(synth_impls);
216216
items.extend(new_items_external);
217217
items.extend(new_items_local);
@@ -258,7 +258,7 @@ impl<'cache> DocVisitor for ItemAndAliasCollector<'cache> {
258258
fn visit_item(&mut self, i: &Item) {
259259
self.items.insert(i.item_id);
260260

261-
if let TypeAliasItem(alias) = &*i.kind
261+
if let TypeAliasItem(alias) = &i.inner.kind
262262
&& let Some(did) = alias.type_.def_id(self.cache)
263263
{
264264
self.items.insert(ItemId::DefId(did));

‎src/librustdoc/passes/propagate_doc_cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'tcx> CfgPropagator<'a, 'tcx> {
3131
// Some items need to merge their attributes with their parents' otherwise a few of them
3232
// (mostly `cfg` ones) will be missing.
3333
fn merge_with_parent_attributes(&mut self, item: &mut Item) {
34-
let check_parent = match &*item.kind {
34+
let check_parent = match &item.kind {
3535
// impl blocks can be in different modules with different cfg and we need to get them
3636
// as well.
3737
ItemKind::ImplItem(_) => false,

‎src/librustdoc/passes/strip_aliased_non_local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct AliasedNonLocalStripper<'tcx> {
2323

2424
impl<'tcx> DocFolder for AliasedNonLocalStripper<'tcx> {
2525
fn fold_item(&mut self, i: Item) -> Option<Item> {
26-
Some(match *i.kind {
26+
Some(match i.kind {
2727
clean::TypeAliasItem(..) => {
2828
let mut stripper = NonLocalStripper { tcx: self.tcx };
2929
// don't call `fold_item` as that could strip the type-alias it-self

‎src/librustdoc/passes/strip_hidden.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a, 'tcx> Stripper<'a, 'tcx> {
8989
impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
9090
fn fold_item(&mut self, i: Item) -> Option<Item> {
9191
let has_doc_hidden = i.is_doc_hidden();
92-
let is_impl_or_exported_macro = match *i.kind {
92+
let is_impl_or_exported_macro = match i.kind {
9393
clean::ImplItem(..) => true,
9494
// If the macro has the `#[macro_export]` attribute, it means it's accessible at the
9595
// crate level so it should be handled differently.
@@ -138,7 +138,7 @@ impl<'a, 'tcx> DocFolder for Stripper<'a, 'tcx> {
138138
// module it's defined in. Both of these are marked "stripped," and
139139
// not included in the final docs, but since they still have an effect
140140
// on the final doc, cannot be completely removed from the Clean IR.
141-
match *i.kind {
141+
match i.kind {
142142
clean::StructFieldItem(..) | clean::ModuleItem(..) | clean::VariantItem(..) => {
143143
// We need to recurse into stripped modules to
144144
// strip things like impl methods but when doing so

‎src/librustdoc/passes/stripper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn is_item_reachable(
3939

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

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

196196
impl<'a> DocFolder for ImplStripper<'a, '_> {
197197
fn fold_item(&mut self, i: Item) -> Option<Item> {
198-
if let clean::ImplItem(ref imp) = *i.kind {
198+
if let clean::ImplItem(ref imp) = i.kind {
199199
// Impl blocks can be skipped if they are: empty; not a trait impl; and have no
200200
// documentation.
201201
//
@@ -272,7 +272,7 @@ impl<'tcx> ImportStripper<'tcx> {
272272

273273
impl<'tcx> DocFolder for ImportStripper<'tcx> {
274274
fn fold_item(&mut self, i: Item) -> Option<Item> {
275-
match *i.kind {
275+
match &i.kind {
276276
clean::ImportItem(imp)
277277
if !self.document_hidden && self.import_should_be_hidden(&i, &imp) =>
278278
{

‎src/librustdoc/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub(crate) trait DocVisitor: Sized {
4848

4949
/// don't override!
5050
fn visit_item_recur(&mut self, item: &Item) {
51-
match &*item.kind {
52-
StrippedItem(i) => self.visit_inner_recur(i),
51+
match &item.kind {
52+
StrippedItem(i) => self.visit_inner_recur(&*i),
5353
_ => self.visit_inner_recur(&item.kind),
5454
}
5555
}

0 commit comments

Comments
 (0)
Please sign in to comment.