From 678059f7d03f05b5a9b81b509d251ac83e87f464 Mon Sep 17 00:00:00 2001 From: klensy Date: Sat, 21 May 2022 14:07:18 -0400 Subject: [PATCH 1/2] fix simple clippy lints --- src/librustdoc/clean/auto_trait.rs | 8 +-- src/librustdoc/clean/mod.rs | 54 +++++++++---------- src/librustdoc/clean/render_macro_matchers.rs | 2 +- src/librustdoc/clean/types.rs | 16 +++--- src/librustdoc/clean/utils.rs | 2 +- src/librustdoc/config.rs | 2 +- src/librustdoc/doctest.rs | 4 +- src/librustdoc/formats/cache.rs | 2 +- src/librustdoc/html/format.rs | 13 ++--- src/librustdoc/html/markdown.rs | 12 ++--- src/librustdoc/html/render/context.rs | 8 +-- src/librustdoc/html/render/mod.rs | 8 +-- src/librustdoc/html/render/search_index.rs | 2 +- src/librustdoc/html/render/span_map.rs | 2 +- .../passes/calculate_doc_coverage.rs | 2 +- .../passes/check_code_block_syntax.rs | 2 +- .../passes/check_doc_test_visibility.rs | 4 +- .../passes/collect_intra_doc_links.rs | 19 ++++--- src/librustdoc/passes/html_tags.rs | 6 +-- src/librustdoc/visit.rs | 1 - src/librustdoc/visit_ast.rs | 2 +- 21 files changed, 81 insertions(+), 90 deletions(-) diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 27fb4709982bd..79d7c414bd39b 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -643,11 +643,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { /// both for visual consistency between 'rustdoc' runs, and to /// make writing tests much easier #[inline] - fn sort_where_predicates(&self, mut predicates: &mut Vec) { + fn sort_where_predicates(&self, predicates: &mut Vec) { // We should never have identical bounds - and if we do, // they're visually identical as well. Therefore, using // an unstable sort is fine. - self.unstable_debug_sort(&mut predicates); + self.unstable_debug_sort(predicates); } /// Ensure that the bounds are in a consistent order. The precise @@ -656,11 +656,11 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { /// both for visual consistency between 'rustdoc' runs, and to /// make writing tests much easier #[inline] - fn sort_where_bounds(&self, mut bounds: &mut Vec) { + fn sort_where_bounds(&self, bounds: &mut Vec) { // We should never have identical bounds - and if we do, // they're visually identical as well. Therefore, using // an unstable sort is fine. - self.unstable_debug_sort(&mut bounds); + self.unstable_debug_sort(bounds); } /// This might look horrendously hacky, but it's actually not that bad. diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 4ddfae4daccf8..5c7fae98d5b58 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -248,7 +248,7 @@ impl Clean> for hir::WherePredicate<'_> { hir::WherePredicate::BoundPredicate(ref wbp) => { let bound_params = wbp .bound_generic_params - .into_iter() + .iter() .map(|param| { // Higher-ranked params must be lifetimes. // Higher-ranked lifetimes can't have bounds. @@ -520,7 +520,7 @@ fn clean_generic_param( }, ) } - hir::GenericParamKind::Const { ref ty, default } => ( + hir::GenericParamKind::Const { ty, default } => ( param.name.ident().name, GenericParamDefKind::Const { did: cx.tcx.hir().local_def_id(param.hir_id).to_def_id(), @@ -942,7 +942,7 @@ fn clean_fn_decl_from_did_and_sig( // We assume all empty tuples are default return type. This theoretically can discard `-> ()`, // but shouldn't change any code meaning. let output = match sig.skip_binder().output().clean(cx) { - Type::Tuple(inner) if inner.len() == 0 => DefaultReturn, + Type::Tuple(inner) if inner.is_empty() => DefaultReturn, ty => Return(ty), }; @@ -967,7 +967,7 @@ fn clean_fn_decl_from_did_and_sig( impl Clean for hir::FnRetTy<'_> { fn clean(&self, cx: &mut DocContext<'_>) -> FnRetTy { match *self { - Self::Return(ref typ) => Return(typ.clean(cx)), + Self::Return(typ) => Return(typ.clean(cx)), Self::DefaultReturn(..) => DefaultReturn, } } @@ -1008,13 +1008,13 @@ impl Clean for hir::TraitItem<'_> { let local_did = self.def_id.to_def_id(); cx.with_param_env(local_did, |cx| { let inner = match self.kind { - hir::TraitItemKind::Const(ref ty, Some(default)) => AssocConstItem( + hir::TraitItemKind::Const(ty, Some(default)) => AssocConstItem( ty.clean(cx), ConstantKind::Local { def_id: local_did, body: default }, ), - hir::TraitItemKind::Const(ref ty, None) => TyAssocConstItem(ty.clean(cx)), + hir::TraitItemKind::Const(ty, None) => TyAssocConstItem(ty.clean(cx)), hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => { - let m = clean_function(cx, sig, &self.generics, body); + let m = clean_function(cx, sig, self.generics, body); MethodItem(m, None) } hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => { @@ -1055,16 +1055,16 @@ impl Clean for hir::ImplItem<'_> { let local_did = self.def_id.to_def_id(); cx.with_param_env(local_did, |cx| { let inner = match self.kind { - hir::ImplItemKind::Const(ref ty, expr) => { + hir::ImplItemKind::Const(ty, expr) => { let default = ConstantKind::Local { def_id: local_did, body: expr }; AssocConstItem(ty.clean(cx), default) } hir::ImplItemKind::Fn(ref sig, body) => { - let m = clean_function(cx, sig, &self.generics, body); + let m = clean_function(cx, sig, self.generics, body); let defaultness = cx.tcx.associated_item(self.def_id).defaultness; MethodItem(m, Some(defaultness)) } - hir::ImplItemKind::TyAlias(ref hir_ty) => { + hir::ImplItemKind::TyAlias(hir_ty) => { let type_ = hir_ty.clean(cx); let generics = self.generics.clean(cx); let item_type = hir_ty_to_ty(cx.tcx, hir_ty).clean(cx); @@ -1287,7 +1287,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type { let hir::TyKind::Path(qpath) = kind else { unreachable!() }; match qpath { - hir::QPath::Resolved(None, ref path) => { + hir::QPath::Resolved(None, path) => { if let Res::Def(DefKind::TyParam, did) = path.res { if let Some(new_ty) = cx.substs.get(&did).and_then(|p| p.as_ty()).cloned() { return new_ty; @@ -1304,7 +1304,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type { resolve_type(cx, path) } } - hir::QPath::Resolved(Some(ref qself), p) => { + hir::QPath::Resolved(Some(qself), p) => { // Try to normalize `::T` to a type let ty = hir_ty_to_ty(cx.tcx, hir_ty); if let Some(normalized_value) = normalize(cx, ty) { @@ -1328,7 +1328,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type { trait_, } } - hir::QPath::TypeRelative(ref qself, segment) => { + hir::QPath::TypeRelative(qself, segment) => { let ty = hir_ty_to_ty(cx.tcx, hir_ty); let res = match ty.kind() { ty::Projection(proj) => Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id), @@ -1455,8 +1455,8 @@ impl Clean for hir::Ty<'_> { let lifetime = if elided { None } else { Some(l.clean(cx)) }; BorrowedRef { lifetime, mutability: m.mutbl, type_: box m.ty.clean(cx) } } - TyKind::Slice(ref ty) => Slice(box ty.clean(cx)), - TyKind::Array(ref ty, ref length) => { + TyKind::Slice(ty) => Slice(box ty.clean(cx)), + TyKind::Array(ty, ref length) => { let length = match length { hir::ArrayLen::Infer(_, _) => "_".to_string(), hir::ArrayLen::Body(anon_const) => { @@ -1491,7 +1491,7 @@ impl Clean for hir::Ty<'_> { let lifetime = if !lifetime.is_elided() { Some(lifetime.clean(cx)) } else { None }; DynTrait(bounds, lifetime) } - TyKind::BareFn(ref barefn) => BareFunction(box barefn.clean(cx)), + TyKind::BareFn(barefn) => BareFunction(box barefn.clean(cx)), // Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s. TyKind::Infer | TyKind::Err => Infer, TyKind::Typeof(..) => panic!("unimplemented type {:?}", self.kind), @@ -1900,7 +1900,7 @@ fn clean_maybe_renamed_item( bounds: ty.bounds.iter().filter_map(|x| x.clean(cx)).collect(), generics: ty.generics.clean(cx), }), - ItemKind::TyAlias(hir_ty, ref generics) => { + ItemKind::TyAlias(hir_ty, generics) => { let rustdoc_ty = hir_ty.clean(cx); let ty = hir_ty_to_ty(cx.tcx, hir_ty).clean(cx); TypedefItem(Typedef { @@ -1909,26 +1909,26 @@ fn clean_maybe_renamed_item( item_type: Some(ty), }) } - ItemKind::Enum(ref def, ref generics) => EnumItem(Enum { + ItemKind::Enum(ref def, generics) => EnumItem(Enum { variants: def.variants.iter().map(|v| v.clean(cx)).collect(), generics: generics.clean(cx), }), - ItemKind::TraitAlias(ref generics, bounds) => TraitAliasItem(TraitAlias { + ItemKind::TraitAlias(generics, bounds) => TraitAliasItem(TraitAlias { generics: generics.clean(cx), bounds: bounds.iter().filter_map(|x| x.clean(cx)).collect(), }), - ItemKind::Union(ref variant_data, ref generics) => UnionItem(Union { + ItemKind::Union(ref variant_data, generics) => UnionItem(Union { generics: generics.clean(cx), fields: variant_data.fields().iter().map(|x| x.clean(cx)).collect(), }), - ItemKind::Struct(ref variant_data, ref generics) => StructItem(Struct { + ItemKind::Struct(ref variant_data, generics) => StructItem(Struct { struct_type: CtorKind::from_hir(variant_data), generics: generics.clean(cx), fields: variant_data.fields().iter().map(|x| x.clean(cx)).collect(), }), - ItemKind::Impl(ref impl_) => return clean_impl(impl_, item.hir_id(), cx), + ItemKind::Impl(impl_) => return clean_impl(impl_, item.hir_id(), cx), // proc macros can have a name set by attributes - ItemKind::Fn(ref sig, ref generics, body_id) => { + ItemKind::Fn(ref sig, generics, body_id) => { clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx) } ItemKind::Macro(ref macro_def, _) => { @@ -1937,7 +1937,7 @@ fn clean_maybe_renamed_item( source: display_macro_source(cx, name, macro_def, def_id, ty_vis), }) } - ItemKind::Trait(is_auto, unsafety, ref generics, bounds, item_ids) => { + ItemKind::Trait(is_auto, unsafety, generics, bounds, item_ids) => { let items = item_ids.iter().map(|ti| cx.tcx.hir().trait_item(ti.id).clean(cx)).collect(); TraitItem(Trait { @@ -2180,7 +2180,7 @@ fn clean_maybe_renamed_foreign_item( let def_id = item.def_id.to_def_id(); cx.with_param_env(def_id, |cx| { let kind = match item.kind { - hir::ForeignItemKind::Fn(decl, names, ref generics) => { + hir::ForeignItemKind::Fn(decl, names, generics) => { let (generics, decl) = enter_impl_trait(cx, |cx| { // NOTE: generics must be cleaned before args let generics = generics.clean(cx); @@ -2190,7 +2190,7 @@ fn clean_maybe_renamed_foreign_item( }); ForeignFunctionItem(Function { decl, generics }) } - hir::ForeignItemKind::Static(ref ty, mutability) => { + hir::ForeignItemKind::Static(ty, mutability) => { ForeignStaticItem(Static { type_: ty.clean(cx), mutability, expr: None }) } hir::ForeignItemKind::Type => ForeignTypeItem, @@ -2220,7 +2220,7 @@ impl Clean for hir::TypeBindingKind<'_> { hir::TypeBindingKind::Equality { ref term } => { TypeBindingKind::Equality { term: term.clean(cx) } } - hir::TypeBindingKind::Constraint { ref bounds } => TypeBindingKind::Constraint { + hir::TypeBindingKind::Constraint { bounds } => TypeBindingKind::Constraint { bounds: bounds.iter().filter_map(|b| b.clean(cx)).collect(), }, } diff --git a/src/librustdoc/clean/render_macro_matchers.rs b/src/librustdoc/clean/render_macro_matchers.rs index a9c0fe6f07971..f7700c433532d 100644 --- a/src/librustdoc/clean/render_macro_matchers.rs +++ b/src/librustdoc/clean/render_macro_matchers.rs @@ -171,7 +171,7 @@ fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) { if state != Start && needs_space { printer.space(); } - print_tt(printer, &tt); + print_tt(printer, tt); state = next_state; } } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 7118e05e58eb7..e10c61901d05a 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -880,7 +880,7 @@ impl AttributesExt for [ast::Attribute] { let mut doc_cfg = self .iter() .filter(|attr| attr.has_name(sym::doc)) - .flat_map(|attr| attr.meta_item_list().unwrap_or_else(Vec::new)) + .flat_map(|attr| attr.meta_item_list().unwrap_or_default()) .filter(|attr| attr.has_name(sym::cfg)) .peekable(); if doc_cfg.peek().is_some() && doc_cfg_active { @@ -1011,7 +1011,7 @@ pub(crate) enum DocFragmentKind { fn add_doc_fragment(out: &mut String, frag: &DocFragment) { let s = frag.doc.as_str(); let mut iter = s.lines(); - if s == "" { + if s.is_empty() { out.push('\n'); return; } @@ -1594,17 +1594,17 @@ impl Type { match (self, other) { // Recursive cases. (Type::Tuple(a), Type::Tuple(b)) => { - a.len() == b.len() && a.iter().zip(b).all(|(a, b)| a.is_same(&b, cache)) + a.len() == b.len() && a.iter().zip(b).all(|(a, b)| a.is_same(b, cache)) } - (Type::Slice(a), Type::Slice(b)) => a.is_same(&b, cache), - (Type::Array(a, al), Type::Array(b, bl)) => al == bl && a.is_same(&b, cache), + (Type::Slice(a), Type::Slice(b)) => a.is_same(b, cache), + (Type::Array(a, al), Type::Array(b, bl)) => al == bl && a.is_same(b, cache), (Type::RawPointer(mutability, type_), Type::RawPointer(b_mutability, b_type_)) => { - mutability == b_mutability && type_.is_same(&b_type_, cache) + mutability == b_mutability && type_.is_same(b_type_, cache) } ( Type::BorrowedRef { mutability, type_, .. }, Type::BorrowedRef { mutability: b_mutability, type_: b_type_, .. }, - ) => mutability == b_mutability && type_.is_same(&b_type_, cache), + ) => mutability == b_mutability && type_.is_same(b_type_, cache), // Placeholders and generics are equal to all other types. (Type::Infer, _) | (_, Type::Infer) => true, (Type::Generic(_), _) | (_, Type::Generic(_)) => true, @@ -1667,7 +1667,7 @@ impl Type { pub(crate) fn projection(&self) -> Option<(&Type, DefId, PathSegment)> { if let QPath { self_type, trait_, assoc, .. } = self { - Some((&self_type, trait_.def_id(), *assoc.clone())) + Some((self_type, trait_.def_id(), *assoc.clone())) } else { None } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 47597e0413ae1..50f793cf24025 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -106,7 +106,7 @@ fn external_generic_args( bindings: Vec, substs: SubstsRef<'_>, ) -> GenericArgs { - let args = substs_to_args(cx, &substs, has_self); + let args = substs_to_args(cx, substs, has_self); if cx.tcx.fn_trait_kind_from_lang_item(did).is_some() { let inputs = diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index b934a1a59d717..e59324331ae34 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -667,7 +667,7 @@ impl Options { return Err(1); } - let scrape_examples_options = ScrapeExamplesOptions::new(&matches, &diag)?; + let scrape_examples_options = ScrapeExamplesOptions::new(matches, &diag)?; let with_examples = matches.opt_strs("with-examples"); let call_locations = crate::scrape_examples::load_call_locations(with_examples, &diag)?; diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 3005bd9e4a4dd..a4ec4052e0567 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -228,7 +228,7 @@ fn scrape_test_config(attrs: &[ast::Attribute]) -> GlobalTestOptions { let test_attrs: Vec<_> = attrs .iter() .filter(|a| a.has_name(sym::doc)) - .flat_map(|a| a.meta_item_list().unwrap_or_else(Vec::new)) + .flat_map(|a| a.meta_item_list().unwrap_or_default()) .filter(|a| a.has_name(sym::test)) .collect(); let attrs = test_attrs.iter().flat_map(|a| a.meta_item_list().unwrap_or(&[])); @@ -738,7 +738,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool { } }; // If a parsing error happened, it's very likely that the attribute is incomplete. - if !parser.parse_attribute(InnerAttrPolicy::Permitted).is_ok() { + if parser.parse_attribute(InnerAttrPolicy::Permitted).is_err() { return false; } // We now check if there is an unclosed delimiter for the attribute. To do so, we look at diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index f5c0b5e6762bf..09aa042b1d02f 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -456,7 +456,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { let ty::Adt(adt, _) = self.tcx.type_of(path.def_id()).kind() && adt.is_fundamental() { for ty in generics { - if let Some(did) = ty.def_id(&self.cache) { + if let Some(did) = ty.def_id(self.cache) { dids.insert(did); } } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index da32d8c90be64..589d500cce288 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -545,10 +545,10 @@ pub(crate) enum HrefError { // Panics if `syms` is empty. pub(crate) fn join_with_double_colon(syms: &[Symbol]) -> String { let mut s = String::with_capacity(estimate_item_path_byte_length(syms.len())); - s.push_str(&syms[0].as_str()); + s.push_str(syms[0].as_str()); for sym in &syms[1..] { s.push_str("::"); - s.push_str(&sym.as_str()); + s.push_str(sym.as_str()); } s } @@ -1069,7 +1069,7 @@ impl clean::Impl { write!(f, " for ")?; } - if let Some(ref ty) = self.kind.as_blanket_ty() { + if let Some(ty) = self.kind.as_blanket_ty() { fmt_type(ty, f, use_absolute, cx)?; } else { fmt_type(&self.for_, f, use_absolute, cx)?; @@ -1311,8 +1311,7 @@ impl clean::Visibility { // is the same as no visibility modifier String::new() } else if parent_module - .map(|parent| find_nearest_parent_module(cx.tcx(), parent)) - .flatten() + .and_then(|parent| find_nearest_parent_module(cx.tcx(), parent)) == Some(vis_did) { "pub(super) ".to_owned() @@ -1358,9 +1357,7 @@ impl clean::Visibility { // `pub(in foo)` where `foo` is the parent module // is the same as no visibility modifier String::new() - } else if parent_module - .map(|parent| find_nearest_parent_module(tcx, parent)) - .flatten() + } else if parent_module.and_then(|parent| find_nearest_parent_module(tcx, parent)) == Some(vis_did) { "pub(super) ".to_owned() diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 8877f628332c9..91733004e44c3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1023,7 +1023,7 @@ impl Markdown<'_> { let Markdown { content: md, links, - mut ids, + ids, error_codes: codes, edition, playground, @@ -1046,7 +1046,7 @@ impl Markdown<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids, heading_offset); + let p = HeadingLinks::new(p, None, ids, heading_offset); let p = Footnotes::new(p); let p = LinkReplacer::new(p.map(|(ev, _)| ev), links); let p = TableWrapper::new(p); @@ -1059,7 +1059,7 @@ impl Markdown<'_> { impl MarkdownWithToc<'_> { pub(crate) fn into_string(self) -> String { - let MarkdownWithToc(md, mut ids, codes, edition, playground) = self; + let MarkdownWithToc(md, ids, codes, edition, playground) = self; let p = Parser::new_ext(md, main_body_opts()).into_offset_iter(); @@ -1068,7 +1068,7 @@ impl MarkdownWithToc<'_> { let mut toc = TocBuilder::new(); { - let p = HeadingLinks::new(p, Some(&mut toc), &mut ids, HeadingOffset::H1); + let p = HeadingLinks::new(p, Some(&mut toc), ids, HeadingOffset::H1); let p = Footnotes::new(p); let p = TableWrapper::new(p.map(|(ev, _)| ev)); let p = CodeBlocks::new(p, codes, edition, playground); @@ -1081,7 +1081,7 @@ impl MarkdownWithToc<'_> { impl MarkdownHtml<'_> { pub(crate) fn into_string(self) -> String { - let MarkdownHtml(md, mut ids, codes, edition, playground) = self; + let MarkdownHtml(md, ids, codes, edition, playground) = self; // This is actually common enough to special-case if md.is_empty() { @@ -1097,7 +1097,7 @@ impl MarkdownHtml<'_> { let mut s = String::with_capacity(md.len() * 3 / 2); - let p = HeadingLinks::new(p, None, &mut ids, HeadingOffset::H1); + let p = HeadingLinks::new(p, None, ids, HeadingOffset::H1); let p = Footnotes::new(p); let p = TableWrapper::new(p.map(|(ev, _)| ev)); let p = CodeBlocks::new(p, codes, edition, playground); diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 76377c438e832..da4273345cb03 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -232,18 +232,18 @@ impl<'tcx> Context<'tcx> { let mut path = String::new(); for name in &names[..names.len() - 1] { - path.push_str(&name.as_str()); + path.push_str(name.as_str()); path.push('/'); } - path.push_str(&item_path(ty, &names.last().unwrap().as_str())); + path.push_str(&item_path(ty, names.last().unwrap().as_str())); match self.shared.redirections { Some(ref redirections) => { let mut current_path = String::new(); for name in &self.current { - current_path.push_str(&name.as_str()); + current_path.push_str(name.as_str()); current_path.push('/'); } - current_path.push_str(&item_path(ty, &names.last().unwrap().as_str())); + current_path.push_str(&item_path(ty, names.last().unwrap().as_str())); redirections.borrow_mut().insert(current_path, path); } None => return layout::redirect(&format!("{}{}", self.root_path(), path)), diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 1b4a2cf1cb0ac..78191e715b863 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -840,7 +840,7 @@ fn render_stability_since_raw( let mut stability = String::new(); if let Some(ver) = stable_version { - stability.push_str(&ver.as_str()); + stability.push_str(ver.as_str()); title.push_str(&format!("Stable since Rust version {}", ver)); } @@ -2299,7 +2299,7 @@ fn sidebar_trait(cx: &Context<'_>, buf: &mut Buffer, it: &clean::Item, t: &clean buf, "foreign-impls", "Implementations on Foreign Types", - res.iter().map(|(name, id)| format!("{}", id, Escape(&name))), + res.iter().map(|(name, id)| format!("{}", id, Escape(name))), ); } } @@ -2798,7 +2798,7 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item) { hi - lo }; - let mut locs = call_locations.into_iter().collect::>(); + let mut locs = call_locations.iter().collect::>(); locs.sort_by_key(sort_criterion); locs }; @@ -2842,7 +2842,7 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item) { if it.peek().is_some() { write!(w, r#"