diff options
| author | klensy <klensy@users.noreply.github.com> | 2022-05-21 14:07:18 -0400 |
|---|---|---|
| committer | klensy <klensy@users.noreply.github.com> | 2022-05-24 12:24:41 -0400 |
| commit | 678059f7d03f05b5a9b81b509d251ac83e87f464 (patch) | |
| tree | 3c2530d6a7c6236fd5eaf0c1ea19385381d2d774 /src/librustdoc/clean | |
| parent | b2eba058e6e1c698723e47074561a30b50b5fa7a (diff) | |
| download | rust-678059f7d03f05b5a9b81b509d251ac83e87f464.tar.gz rust-678059f7d03f05b5a9b81b509d251ac83e87f464.zip | |
fix simple clippy lints
Diffstat (limited to 'src/librustdoc/clean')
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 8 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 54 | ||||
| -rw-r--r-- | src/librustdoc/clean/render_macro_matchers.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/clean/types.rs | 16 | ||||
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 2 |
5 files changed, 41 insertions, 41 deletions
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 27fb4709982..79d7c414bd3 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<WherePredicate>) { + fn sort_where_predicates(&self, predicates: &mut Vec<WherePredicate>) { // 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<GenericBound>) { + fn sort_where_bounds(&self, bounds: &mut Vec<GenericBound>) { // 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 4ddfae4dacc..5c7fae98d5b 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -248,7 +248,7 @@ impl Clean<Option<WherePredicate>> 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<FnRetTy> 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<Item> 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<Item> 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 `<X as Y>::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<Type> 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<Type> 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<TypeBindingKind> 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 a9c0fe6f079..f7700c43353 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 7118e05e58e..e10c61901d0 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 47597e0413a..50f793cf240 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -106,7 +106,7 @@ fn external_generic_args( bindings: Vec<TypeBinding>, 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 = |
