rustdoc: simplify some & ref erences

This commit is contained in:
Matthias Krüger 2023-01-15 15:23:30 +01:00
parent bbb36fe545
commit fdd6af14a1
5 changed files with 12 additions and 14 deletions

View File

@ -402,15 +402,13 @@ fn make_final_bounds(
bound_params: Vec::new(), bound_params: Vec::new(),
}) })
}) })
.chain( .chain(lifetime_to_bounds.into_iter().filter(|(_, bounds)| !bounds.is_empty()).map(
lifetime_to_bounds.into_iter().filter(|&(_, ref bounds)| !bounds.is_empty()).map(
|(lifetime, bounds)| { |(lifetime, bounds)| {
let mut bounds_vec = bounds.into_iter().collect(); let mut bounds_vec = bounds.into_iter().collect();
self.sort_where_bounds(&mut bounds_vec); self.sort_where_bounds(&mut bounds_vec);
WherePredicate::RegionPredicate { lifetime, bounds: bounds_vec } WherePredicate::RegionPredicate { lifetime, bounds: bounds_vec }
}, },
), ))
)
.collect() .collect()
} }

View File

@ -46,7 +46,7 @@ pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> ThinVec<WP
// Look for equality predicates on associated types that can be merged into // Look for equality predicates on associated types that can be merged into
// general bound predicates. // general bound predicates.
equalities.retain(|&(ref lhs, ref rhs, ref bound_params)| { equalities.retain(|(lhs, rhs, bound_params)| {
let Some((ty, trait_did, name)) = lhs.projection() else { return true; }; let Some((ty, trait_did, name)) = lhs.projection() else { return true; };
let Some((bounds, _)) = tybounds.get_mut(ty) else { return true }; let Some((bounds, _)) = tybounds.get_mut(ty) else { return true };
let bound_params = bound_params let bound_params = bound_params

View File

@ -296,7 +296,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// for where the type was defined. On the other // for where the type was defined. On the other
// hand, `paths` always has the right // hand, `paths` always has the right
// information if present. // information if present.
Some(&(ref fqp, _)) => Some(&fqp[..fqp.len() - 1]), Some((fqp, _)) => Some(&fqp[..fqp.len() - 1]),
None => None, None => None,
}; };
((did, path), true) ((did, path), true)

View File

@ -962,7 +962,7 @@ fn fmt_type<'cx>(
clean::Tuple(ref typs) => { clean::Tuple(ref typs) => {
match &typs[..] { match &typs[..] {
&[] => primitive_link(f, PrimitiveType::Unit, "()", cx), &[] => primitive_link(f, PrimitiveType::Unit, "()", cx),
&[ref one] => { [one] => {
if let clean::Generic(name) = one { if let clean::Generic(name) = one {
primitive_link(f, PrimitiveType::Tuple, &format!("({name},)"), cx) primitive_link(f, PrimitiveType::Tuple, &format!("({name},)"), cx)
} else { } else {

View File

@ -29,7 +29,7 @@ pub(crate) fn build_index<'tcx>(
// Attach all orphan items to the type's definition if the type // Attach all orphan items to the type's definition if the type
// has since been learned. // has since been learned.
for &OrphanImplItem { parent, ref item, ref impl_generics } in &cache.orphan_impl_items { for &OrphanImplItem { parent, ref item, ref impl_generics } in &cache.orphan_impl_items {
if let Some(&(ref fqp, _)) = cache.paths.get(&parent) { if let Some((fqp, _)) = cache.paths.get(&parent) {
let desc = item let desc = item
.doc_value() .doc_value()
.map_or_else(String::new, |s| short_markdown_summary(&s, &item.link_names(cache))); .map_or_else(String::new, |s| short_markdown_summary(&s, &item.link_names(cache)));
@ -573,7 +573,7 @@ fn get_fn_inputs_and_outputs<'tcx>(
let decl = &func.decl; let decl = &func.decl;
let combined_generics; let combined_generics;
let (self_, generics) = if let Some(&(ref impl_self, ref impl_generics)) = impl_generics { let (self_, generics) = if let Some((impl_self, impl_generics)) = impl_generics {
match (impl_generics.is_empty(), func.generics.is_empty()) { match (impl_generics.is_empty(), func.generics.is_empty()) {
(true, _) => (Some(impl_self), &func.generics), (true, _) => (Some(impl_self), &func.generics),
(_, true) => (Some(impl_self), impl_generics), (_, true) => (Some(impl_self), impl_generics),