Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Cfg {
| CfgEntry::All(..)
| CfgEntry::NameValue { .. }
| CfgEntry::Version(..)
| CfgEntry::Not(box CfgEntry::NameValue { .. }, _) => true,
| CfgEntry::Not(CfgEntry::NameValue { .. }, _) => true,
CfgEntry::Not(..) | CfgEntry::Bool(..) => false,
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ impl Display<'_> {
impl fmt::Display for Display<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 {
CfgEntry::Not(box CfgEntry::Any(sub_cfgs, _), _) => {
CfgEntry::Not(CfgEntry::Any(sub_cfgs, _), _) => {
let separator = if sub_cfgs.iter().all(is_simple_cfg) { " nor " } else { ", nor " };
fmt.write_str("neither ")?;

Expand All @@ -399,10 +399,10 @@ impl fmt::Display for Display<'_> {
})
.joined(separator, fmt)
}
CfgEntry::Not(box simple @ CfgEntry::NameValue { .. }, _) => {
CfgEntry::Not(simple @ CfgEntry::NameValue { .. }, _) => {
write!(fmt, "non-{}", Display(simple, self.1))
}
CfgEntry::Not(box c, _) => write!(fmt, "not ({})", Display(c, self.1)),
CfgEntry::Not(c, _) => write!(fmt, "not ({})", Display(c, self.1)),

CfgEntry::Any(sub_cfgs, _) => {
let separator = if sub_cfgs.iter().all(is_simple_cfg) { " or " } else { ", or " };
Expand Down
9 changes: 3 additions & 6 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,11 +1472,8 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
generics.where_predicates.retain_mut(|pred| match *pred {
WherePredicate::BoundPredicate {
ty:
QPath(box QPathData {
ref assoc,
ref self_type,
trait_: Some(ref trait_),
..
QPath(QPathData {
ref assoc, ref self_type, trait_: Some(ref trait_), ..
}),
bounds: ref mut pred_bounds,
..
Expand Down Expand Up @@ -2786,7 +2783,7 @@ fn add_without_unwanted_attributes<'hir>(
hir::Attribute::Parsed(AttributeKind::DocComment { .. }) => {
attrs.push((Cow::Borrowed(attr), import_parent));
}
hir::Attribute::Parsed(AttributeKind::Doc(box d)) => {
hir::Attribute::Parsed(AttributeKind::Doc(d)) => {
// Remove attributes from `normal` that should not be inherited by `use` re-export.
let DocAttribute {
first_span: _,
Expand Down
29 changes: 17 additions & 12 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ impl Item {

/// Returns true if item is an associated function with a `self` parameter.
pub(crate) fn has_self_param(&self) -> bool {
if let ItemKind::MethodItem(box Function { decl, .. }, _) = &self.inner.kind {
if let ItemKind::MethodItem(Function { decl, .. }, _) = &self.inner.kind {
decl.receiver_type().is_some()
} else {
false
Expand All @@ -505,8 +505,8 @@ impl Item {
};
match kind {
ItemKind::ModuleItem(Module { span, .. }) => Some(*span),
ItemKind::ImplItem(box Impl { kind: ImplKind::Auto, .. }) => None,
ItemKind::ImplItem(box Impl { kind: ImplKind::Blanket(_), .. }) => {
ItemKind::ImplItem(Impl { kind: ImplKind::Auto, .. }) => None,
ItemKind::ImplItem(Impl { kind: ImplKind::Blanket(_), .. }) => {
if let ItemId::Blanket { impl_id, .. } = self.item_id {
Some(rustc_span(impl_id, tcx))
} else {
Expand Down Expand Up @@ -667,16 +667,21 @@ impl Item {
self.type_() == ItemType::Variant
}
pub(crate) fn is_associated_type(&self) -> bool {
matches!(self.kind, AssocTypeItem(..) | StrippedItem(box AssocTypeItem(..)))
matches!(self.kind, AssocTypeItem(..) | StrippedItem(AssocTypeItem(..)))
}
pub(crate) fn is_required_associated_type(&self) -> bool {
matches!(self.kind, RequiredAssocTypeItem(..) | StrippedItem(box RequiredAssocTypeItem(..)))
matches!(self.kind, RequiredAssocTypeItem(..) | StrippedItem(RequiredAssocTypeItem(..)))
}
pub(crate) fn is_associated_const(&self) -> bool {
matches!(self.kind, ProvidedAssocConstItem(..) | ImplAssocConstItem(..) | StrippedItem(box (ProvidedAssocConstItem(..) | ImplAssocConstItem(..))))
matches!(
self.kind,
ProvidedAssocConstItem(..)
| ImplAssocConstItem(..)
| StrippedItem(ProvidedAssocConstItem(..) | ImplAssocConstItem(..))
)
}
pub(crate) fn is_required_associated_const(&self) -> bool {
matches!(self.kind, RequiredAssocConstItem(..) | StrippedItem(box RequiredAssocConstItem(..)))
matches!(self.kind, RequiredAssocConstItem(..) | StrippedItem(RequiredAssocConstItem(..)))
}
pub(crate) fn is_method(&self) -> bool {
self.type_() == ItemType::Method
Expand Down Expand Up @@ -1508,9 +1513,9 @@ impl Type {

pub(crate) fn primitive_type(&self) -> Option<PrimitiveType> {
match *self {
Primitive(p) | BorrowedRef { type_: box Primitive(p), .. } => Some(p),
Slice(..) | BorrowedRef { type_: box Slice(..), .. } => Some(PrimitiveType::Slice),
Array(..) | BorrowedRef { type_: box Array(..), .. } => Some(PrimitiveType::Array),
Primitive(p) | BorrowedRef { type_: Primitive(p), .. } => Some(p),
Slice(..) | BorrowedRef { type_: Slice(..), .. } => Some(PrimitiveType::Slice),
Array(..) | BorrowedRef { type_: Array(..), .. } => Some(PrimitiveType::Array),
Tuple(ref tys) => {
if tys.is_empty() {
Some(PrimitiveType::Unit)
Expand Down Expand Up @@ -1590,7 +1595,7 @@ impl Type {
Type::Path { path } => return Some(path.def_id()),
DynTrait(bounds, _) => return bounds.first().map(|b| b.trait_.def_id()),
Primitive(p) => return cache.primitive_locations.get(p).cloned(),
BorrowedRef { type_: box Generic(..), .. } => PrimitiveType::Reference,
BorrowedRef { type_: Generic(..), .. } => PrimitiveType::Reference,
BorrowedRef { type_, .. } => return type_.def_id(cache),
Tuple(tys) => {
if tys.is_empty() {
Expand All @@ -1605,7 +1610,7 @@ impl Type {
Type::Pat(..) => PrimitiveType::Pat,
Type::FieldOf(..) => PrimitiveType::FieldOf,
RawPointer(..) => PrimitiveType::RawPointer,
QPath(box QPathData { self_type, .. }) => return self_type.def_id(cache),
QPath(QPathData { self_type, .. }) => return self_type.def_id(cache),
Generic(_) | SelfTy | Infer | ImplTrait(_) | UnsafeBinder(_) => return None,
};
Primitive(t).def_id(cache)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub(crate) trait DocFolder: Sized {
/// don't override!
fn fold_item_recur(&mut self, mut item: Item) -> Item {
item.inner.kind = match item.inner.kind {
StrippedItem(box i) => StrippedItem(Box::new(self.fold_inner_recur(i))),
StrippedItem(i) => StrippedItem(Box::new(self.fold_inner_recur(*i))),
_ => self.fold_inner_recur(item.inner.kind),
};
item
Expand Down
112 changes: 56 additions & 56 deletions src/librustdoc/formats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl DocFolder for CacheBuilder<'_, '_> {
// 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 {
clean::StrippedItem(box clean::ModuleItem(..)) => {
clean::StrippedItem(clean::ModuleItem(..)) => {
mem::replace(&mut self.cache.stripped_mod, true)
}
_ => self.cache.stripped_mod,
Expand Down Expand Up @@ -409,69 +409,69 @@ impl DocFolder for CacheBuilder<'_, '_> {

// Once we've recursively found all the generics, hoard off all the
// implementations elsewhere.
let ret = if let clean::Item {
inner: box clean::ItemInner { kind: 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 = FxIndexSet::default();
match i.for_ {
clean::Type::Path { ref path }
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
dids.insert(path.def_id());
if let Some(generics) = path.generics()
&& let ty::Adt(adt, _) = self
.tcx
.type_of(path.def_id())
.instantiate_identity()
.skip_norm_wip()
.kind()
&& adt.is_fundamental()
{
for ty in generics {
dids.extend(ty.def_id(self.cache));
let ret =
if let clean::Item { inner: clean::ItemInner { kind: 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 = FxIndexSet::default();
match i.for_ {
clean::Type::Path { ref path }
| clean::BorrowedRef { type_: clean::Type::Path { ref path }, .. } => {
dids.insert(path.def_id());
if let Some(generics) = path.generics()
&& let ty::Adt(adt, _) = self
.tcx
.type_of(path.def_id())
.instantiate_identity()
.skip_norm_wip()
.kind()
&& adt.is_fundamental()
{
for ty in generics {
dids.extend(ty.def_id(self.cache));
}
}
}
}
clean::DynTrait(ref bounds, _)
| clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => {
dids.insert(bounds[0].trait_.def_id());
}
ref t => {
let did = t
.primitive_type()
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
clean::DynTrait(ref bounds, _)
| clean::BorrowedRef { type_: clean::DynTrait(ref bounds, _), .. } => {
dids.insert(bounds[0].trait_.def_id());
}
ref t => {
let did = t
.primitive_type()
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());

dids.extend(did);
dids.extend(did);
}
}
}

if let Some(trait_) = &i.trait_
&& let Some(generics) = trait_.generics()
{
for bound in generics {
dids.extend(bound.def_id(self.cache));
if let Some(trait_) = &i.trait_
&& let Some(generics) = trait_.generics()
{
for bound in generics {
dids.extend(bound.def_id(self.cache));
}
}
}
let impl_item = Impl { impl_item: item };
let impl_did = impl_item.def_id();
let trait_did = impl_item.trait_did();
if trait_did.is_none_or(|d| self.cache.traits.contains_key(&d)) {
for did in dids {
if self.impl_ids.entry(did).or_default().insert(impl_did) {
self.cache.impls.entry(did).or_default().push(impl_item.clone());
let impl_item = Impl { impl_item: item };
let impl_did = impl_item.def_id();
let trait_did = impl_item.trait_did();
if trait_did.is_none_or(|d| self.cache.traits.contains_key(&d)) {
for did in dids {
if self.impl_ids.entry(did).or_default().insert(impl_did) {
self.cache.impls.entry(did).or_default().push(impl_item.clone());
}
}
} else {
let trait_did = trait_did.expect("no trait did");
self.cache.orphan_trait_impls.push((trait_did, dids, impl_item));
}
None
} else {
let trait_did = trait_did.expect("no trait did");
self.cache.orphan_trait_impls.push((trait_did, dids, impl_item));
}
None
} else {
Some(item)
};
Some(item)
};

if pushed {
self.cache.stack.pop().expect("stack already empty");
Expand Down Expand Up @@ -655,7 +655,7 @@ enum ParentStackItem {
impl ParentStackItem {
fn new(item: &clean::Item) -> Self {
match &item.kind {
clean::ItemKind::ImplItem(box clean::Impl { for_, trait_, generics, kind, .. }) => {
clean::ItemKind::ImplItem(clean::Impl { for_, trait_, generics, kind, .. }) => {
ParentStackItem::Impl {
for_: for_.clone(),
trait_: trait_.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/formats/item_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ item_type! {
impl<'a> From<&'a clean::Item> for ItemType {
fn from(item: &'a clean::Item) -> ItemType {
let kind = match &item.kind {
clean::StrippedItem(box item) => item,
clean::StrippedItem(item) => item,
kind => kind,
};

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/formats/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ fn run_format_inner<'tcx, T: FormatRenderer<'tcx>>(
prof.generic_activity_with_arg("render_mod_item", item.name.unwrap().to_string());

cx.mod_item_in(item)?;
let (clean::StrippedItem(box clean::ModuleItem(ref module))
| clean::ModuleItem(ref module)) = item.inner.kind
let (clean::StrippedItem(clean::ModuleItem(ref module)) | clean::ModuleItem(ref module)) =
item.inner.kind
else {
unreachable!()
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ fn fmt_type(
}
}
},
clean::Slice(box clean::Generic(name)) => {
clean::Slice(clean::Generic(name)) => {
primitive_link(f, PrimitiveType::Slice, format_args!("[{name}]"), cx)
}
clean::Slice(t) => Wrapped::with_square_brackets().wrap(print_type(t, cx)).fmt(f),
Expand All @@ -974,7 +974,7 @@ fn fmt_type(
fmt::Display::fmt(&print_type(t, cx), f)?;
write!(f, ", {field})")
}
clean::Array(box clean::Generic(name), n) if !f.alternate() => primitive_link(
clean::Array(clean::Generic(name), n) if !f.alternate() => primitive_link(
f,
PrimitiveType::Array,
format_args!("[{name}; {n}]", n = Escape(n)),
Expand Down Expand Up @@ -1280,7 +1280,7 @@ fn print_parameter(parameter: &clean::Parameter, cx: &Context<'_>) -> impl fmt::
if let Some(self_ty) = parameter.to_receiver() {
match self_ty {
clean::SelfTy => f.write_str("self"),
clean::BorrowedRef { lifetime, mutability, type_: box clean::SelfTy } => {
clean::BorrowedRef { lifetime, mutability, type_: clean::SelfTy } => {
f.write_str(if f.alternate() { "&" } else { "&amp;" })?;
if let Some(lt) = lifetime {
write!(f, "{lt} ", lt = print_lifetime(lt))?;
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {

// Render sidebar-items.js used throughout this module.
if !self.info.render_redirect_pages {
let (clean::StrippedItem(box clean::ModuleItem(ref module))
let (clean::StrippedItem(clean::ModuleItem(ref module))
| clean::ModuleItem(ref module)) = item.kind
else {
unreachable!()
Expand Down
7 changes: 4 additions & 3 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ fn document_full_inner(
}

let kind = match &item.kind {
clean::ItemKind::StrippedItem(box kind) | kind => kind,
clean::ItemKind::StrippedItem(kind) => kind,
kind => kind,
};

if let clean::ItemKind::FunctionItem(..) | clean::ItemKind::MethodItem(..) = kind {
Expand Down Expand Up @@ -1582,7 +1583,7 @@ fn render_deref_methods(
.items
.iter()
.find_map(|item| match item.kind {
clean::AssocTypeItem(box ref t, _) => Some(match *t {
clean::AssocTypeItem(ref t, _) => Some(match *t {
clean::TypeAlias { item_type: Some(ref type_), .. } => (type_, &t.type_),
_ => (&t.type_, &t.type_),
}),
Expand Down Expand Up @@ -2709,7 +2710,7 @@ fn collect_paths_for_type(first_ty: &clean::Type, cache: &Cache) -> Vec<String>
clean::Type::BorrowedRef { type_, .. } => {
work.push_back(type_);
}
clean::Type::QPath(box clean::QPathData { self_type, trait_, .. }) => {
clean::Type::QPath(clean::QPathData { self_type, trait_, .. }) => {
work.push_back(self_type);
if let Some(trait_) = trait_ {
process_path(trait_.def_id());
Expand Down
Loading
Loading