From 84f82d348c1b9d9c20579ded7e2dd2981ed454b9 Mon Sep 17 00:00:00 2001 From: Jack Huey Date: Wed, 16 Dec 2020 19:14:21 -0500 Subject: [PATCH] Revert explicit lifetimes --- compiler/rustc_hir/src/hir.rs | 4 +- src/librustdoc/clean/mod.rs | 312 +++++++++++++++++----------------- src/librustdoc/clean/utils.rs | 12 +- 3 files changed, 160 insertions(+), 168 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 4ff5c0a678e..03af81ae02a 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -314,12 +314,12 @@ pub struct GenericArgs<'hir> { pub parenthesized: bool, } -impl<'tcx> GenericArgs<'tcx> { +impl GenericArgs<'_> { pub const fn none() -> Self { Self { args: &[], bindings: &[], parenthesized: false } } - pub fn inputs(&self) -> &[Ty<'tcx>] { + pub fn inputs(&self) -> &[Ty<'_>] { if self.parenthesized { for arg in self.args { match arg { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index dac42058b1b..4d33a1e6961 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -48,42 +48,42 @@ crate use self::types::Type::*; crate use self::types::Visibility::{Inherited, Public}; crate use self::types::*; -crate trait Clean<'tcx, T> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> T; +crate trait Clean { + fn clean(&self, cx: &mut DocContext<'_>) -> T; } -impl<'tcx, T: Clean<'tcx, U>, U> Clean<'tcx, Vec> for [T] { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Vec { +impl, U> Clean> for [T] { + fn clean(&self, cx: &mut DocContext<'_>) -> Vec { self.iter().map(|x| x.clean(cx)).collect() } } -impl<'tcx, T: Clean<'tcx, U>, U, V: Idx> Clean<'tcx, IndexVec> for IndexVec { - fn clean(&self, cx: &mut DocContext<'tcx>) -> IndexVec { +impl, U, V: Idx> Clean> for IndexVec { + fn clean(&self, cx: &mut DocContext<'_>) -> IndexVec { self.iter().map(|x| x.clean(cx)).collect() } } -impl<'tcx, T: Clean<'tcx, U>, U> Clean<'tcx, U> for &T { - fn clean(&self, cx: &mut DocContext<'tcx>) -> U { +impl, U> Clean for &T { + fn clean(&self, cx: &mut DocContext<'_>) -> U { (**self).clean(cx) } } -impl<'tcx, T: Clean<'tcx, U>, U> Clean<'tcx, U> for Rc { - fn clean(&self, cx: &mut DocContext<'tcx>) -> U { +impl, U> Clean for Rc { + fn clean(&self, cx: &mut DocContext<'_>) -> U { (**self).clean(cx) } } -impl<'tcx, T: Clean<'tcx, U>, U> Clean<'tcx, Option> for Option { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Option { +impl, U> Clean> for Option { + fn clean(&self, cx: &mut DocContext<'_>) -> Option { self.as_ref().map(|v| v.clean(cx)) } } -impl<'tcx> Clean<'tcx, ExternalCrate> for CrateNum { - fn clean(&self, cx: &mut DocContext<'tcx>) -> ExternalCrate { +impl Clean for CrateNum { + fn clean(&self, cx: &mut DocContext<'_>) -> ExternalCrate { let tcx = cx.tcx; let root = DefId { krate: *self, index: CRATE_DEF_INDEX }; let krate_span = tcx.def_span(root); @@ -204,8 +204,8 @@ impl<'tcx> Clean<'tcx, ExternalCrate> for CrateNum { } } -impl<'tcx> Clean<'tcx, Item> for doctree::Module<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for doctree::Module<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let mut items: Vec = vec![]; items.extend(self.foreigns.iter().map(|x| x.clean(cx))); items.extend(self.mods.iter().map(|x| x.clean(cx))); @@ -237,14 +237,14 @@ impl<'tcx> Clean<'tcx, Item> for doctree::Module<'tcx> { } } -impl<'tcx> Clean<'tcx, Attributes> for [ast::Attribute] { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Attributes { +impl Clean for [ast::Attribute] { + fn clean(&self, cx: &mut DocContext<'_>) -> Attributes { Attributes::from_ast(cx.sess().diagnostic(), self, None) } } -impl<'tcx> Clean<'tcx, GenericBound> for hir::GenericBound<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericBound { +impl Clean for hir::GenericBound<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound { match *self { hir::GenericBound::Outlives(lt) => GenericBound::Outlives(lt.clean(cx)), hir::GenericBound::LangItemTrait(lang_item, span, _, generic_args) => { @@ -270,8 +270,8 @@ impl<'tcx> Clean<'tcx, GenericBound> for hir::GenericBound<'tcx> { } } -impl<'tcx> Clean<'tcx, Type> for (ty::TraitRef<'tcx>, &[TypeBinding]) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Type { +impl Clean for (ty::TraitRef<'_>, &[TypeBinding]) { + fn clean(&self, cx: &mut DocContext<'_>) -> Type { let (trait_ref, bounds) = *self; inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait); let path = external_path( @@ -289,8 +289,8 @@ impl<'tcx> Clean<'tcx, Type> for (ty::TraitRef<'tcx>, &[TypeBinding]) { } } -impl<'tcx> Clean<'tcx, GenericBound> for ty::TraitRef<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericBound { +impl<'tcx> Clean for ty::TraitRef<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound { GenericBound::TraitBound( PolyTrait { trait_: (*self, &[][..]).clean(cx), generic_params: vec![] }, hir::TraitBoundModifier::None, @@ -298,8 +298,8 @@ impl<'tcx> Clean<'tcx, GenericBound> for ty::TraitRef<'tcx> { } } -impl<'tcx> Clean<'tcx, GenericBound> for (ty::PolyTraitRef<'tcx>, &[TypeBinding]) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericBound { +impl Clean for (ty::PolyTraitRef<'_>, &[TypeBinding]) { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound { let (poly_trait_ref, bounds) = *self; let poly_trait_ref = poly_trait_ref.lift_to_tcx(cx.tcx).unwrap(); @@ -326,14 +326,14 @@ impl<'tcx> Clean<'tcx, GenericBound> for (ty::PolyTraitRef<'tcx>, &[TypeBinding] } } -impl<'tcx> Clean<'tcx, GenericBound> for ty::PolyTraitRef<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericBound { +impl<'tcx> Clean for ty::PolyTraitRef<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound { (*self, &[][..]).clean(cx) } } -impl<'tcx> Clean<'tcx, Option>> for InternalSubsts<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Option> { +impl<'tcx> Clean>> for InternalSubsts<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> Option> { let mut v = Vec::new(); v.extend(self.regions().filter_map(|r| r.clean(cx)).map(GenericBound::Outlives)); v.extend(self.types().map(|t| { @@ -346,8 +346,8 @@ impl<'tcx> Clean<'tcx, Option>> for InternalSubsts<'tcx> { } } -impl<'tcx> Clean<'tcx, Lifetime> for hir::Lifetime { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Lifetime { +impl Clean for hir::Lifetime { + fn clean(&self, cx: &mut DocContext<'_>) -> Lifetime { let def = cx.tcx.named_region(self.hir_id); match def { Some( @@ -365,8 +365,8 @@ impl<'tcx> Clean<'tcx, Lifetime> for hir::Lifetime { } } -impl<'tcx> Clean<'tcx, Lifetime> for hir::GenericParam<'tcx> { - fn clean(&self, _: &mut DocContext<'tcx>) -> Lifetime { +impl Clean for hir::GenericParam<'_> { + fn clean(&self, _: &mut DocContext<'_>) -> Lifetime { match self.kind { hir::GenericParamKind::Lifetime { .. } => { if !self.bounds.is_empty() { @@ -389,8 +389,8 @@ impl<'tcx> Clean<'tcx, Lifetime> for hir::GenericParam<'tcx> { } } -impl<'tcx> Clean<'tcx, Constant> for hir::ConstArg { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Constant { +impl Clean for hir::ConstArg { + fn clean(&self, cx: &mut DocContext<'_>) -> Constant { Constant { type_: cx .tcx @@ -401,14 +401,14 @@ impl<'tcx> Clean<'tcx, Constant> for hir::ConstArg { } } -impl<'tcx> Clean<'tcx, Lifetime> for ty::GenericParamDef { - fn clean(&self, _cx: &mut DocContext<'tcx>) -> Lifetime { +impl Clean for ty::GenericParamDef { + fn clean(&self, _cx: &mut DocContext<'_>) -> Lifetime { Lifetime(self.name) } } -impl<'tcx> Clean<'tcx, Option> for ty::RegionKind { - fn clean(&self, _cx: &mut DocContext<'tcx>) -> Option { +impl Clean> for ty::RegionKind { + fn clean(&self, _cx: &mut DocContext<'_>) -> Option { match *self { ty::ReStatic => Some(Lifetime::statik()), ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name) }) => { @@ -429,8 +429,8 @@ impl<'tcx> Clean<'tcx, Option> for ty::RegionKind { } } -impl<'tcx> Clean<'tcx, WherePredicate> for hir::WherePredicate<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> WherePredicate { +impl Clean for hir::WherePredicate<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> WherePredicate { match *self { hir::WherePredicate::BoundPredicate(ref wbp) => WherePredicate::BoundPredicate { ty: wbp.bounded_ty.clean(cx), @@ -449,8 +449,8 @@ impl<'tcx> Clean<'tcx, WherePredicate> for hir::WherePredicate<'tcx> { } } -impl<'a> Clean<'a, Option> for ty::Predicate<'a> { - fn clean(&self, cx: &mut DocContext<'a>) -> Option { +impl<'a> Clean> for ty::Predicate<'a> { + fn clean(&self, cx: &mut DocContext<'_>) -> Option { let bound_predicate = self.kind(); match bound_predicate.skip_binder() { ty::PredicateKind::Trait(pred, _) => Some(bound_predicate.rebind(pred).clean(cx)), @@ -469,8 +469,8 @@ impl<'a> Clean<'a, Option> for ty::Predicate<'a> { } } -impl<'tcx> Clean<'tcx, WherePredicate> for ty::PolyTraitPredicate<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> WherePredicate { +impl<'a> Clean for ty::PolyTraitPredicate<'a> { + fn clean(&self, cx: &mut DocContext<'_>) -> WherePredicate { let poly_trait_ref = self.map_bound(|pred| pred.trait_ref); WherePredicate::BoundPredicate { ty: poly_trait_ref.skip_binder().self_ty().clean(cx), @@ -479,10 +479,10 @@ impl<'tcx> Clean<'tcx, WherePredicate> for ty::PolyTraitPredicate<'tcx> { } } -impl<'tcx> Clean<'tcx, Option> +impl<'tcx> Clean> for ty::OutlivesPredicate, ty::Region<'tcx>> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Option { + fn clean(&self, cx: &mut DocContext<'_>) -> Option { let ty::OutlivesPredicate(a, b) = self; if let (ty::ReEmpty(_), ty::ReEmpty(_)) = (a, b) { @@ -496,10 +496,8 @@ impl<'tcx> Clean<'tcx, Option> } } -impl<'tcx> Clean<'tcx, Option> - for ty::OutlivesPredicate, ty::Region<'tcx>> -{ - fn clean(&self, cx: &mut DocContext<'tcx>) -> Option { +impl<'tcx> Clean> for ty::OutlivesPredicate, ty::Region<'tcx>> { + fn clean(&self, cx: &mut DocContext<'_>) -> Option { let ty::OutlivesPredicate(ty, lt) = self; if let ty::ReEmpty(_) = lt { @@ -513,15 +511,15 @@ impl<'tcx> Clean<'tcx, Option> } } -impl<'tcx> Clean<'tcx, WherePredicate> for ty::ProjectionPredicate<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> WherePredicate { +impl<'tcx> Clean for ty::ProjectionPredicate<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> WherePredicate { let ty::ProjectionPredicate { projection_ty, ty } = self; WherePredicate::EqPredicate { lhs: projection_ty.clean(cx), rhs: ty.clean(cx) } } } -impl<'tcx> Clean<'tcx, Type> for ty::ProjectionTy<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Type { +impl<'tcx> Clean for ty::ProjectionTy<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> Type { let lifted = self.lift_to_tcx(cx.tcx).unwrap(); let trait_ = match lifted.trait_ref(cx.tcx).clean(cx) { GenericBound::TraitBound(t, _) => t.trait_, @@ -535,8 +533,8 @@ impl<'tcx> Clean<'tcx, Type> for ty::ProjectionTy<'tcx> { } } -impl<'tcx> Clean<'tcx, GenericParamDef> for ty::GenericParamDef { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericParamDef { +impl Clean for ty::GenericParamDef { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericParamDef { let (name, kind) = match self.kind { ty::GenericParamDefKind::Lifetime => (self.name, GenericParamDefKind::Lifetime), ty::GenericParamDefKind::Type { has_default, synthetic, .. } => { @@ -565,8 +563,8 @@ impl<'tcx> Clean<'tcx, GenericParamDef> for ty::GenericParamDef { } } -impl<'tcx> Clean<'tcx, GenericParamDef> for hir::GenericParam<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericParamDef { +impl Clean for hir::GenericParam<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericParamDef { let (name, kind) = match self.kind { hir::GenericParamKind::Lifetime { .. } => { let name = if !self.bounds.is_empty() { @@ -608,8 +606,8 @@ impl<'tcx> Clean<'tcx, GenericParamDef> for hir::GenericParam<'tcx> { } } -impl<'tcx> Clean<'tcx, Generics> for hir::Generics<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Generics { +impl Clean for hir::Generics<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Generics { // Synthetic type-parameters are inserted after normal ones. // In order for normal parameters to be able to refer to synthetic ones, // scans them first. @@ -688,8 +686,8 @@ impl<'tcx> Clean<'tcx, Generics> for hir::Generics<'tcx> { } } -impl<'a, 'tcx> Clean<'tcx, Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx>) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Generics { +impl<'a, 'tcx> Clean for (&'a ty::Generics, ty::GenericPredicates<'tcx>) { + fn clean(&self, cx: &mut DocContext<'_>) -> Generics { use self::WherePredicate as WP; use std::collections::BTreeMap; @@ -853,13 +851,13 @@ impl<'a, 'tcx> Clean<'tcx, Generics> for (&'a ty::Generics, ty::GenericPredicate } } -fn clean_fn_or_proc_macro<'a, 'tcx>( - item: &hir::Item<'tcx>, - sig: &'a hir::FnSig<'tcx>, - generics: &'a hir::Generics<'tcx>, +fn clean_fn_or_proc_macro( + item: &hir::Item<'_>, + sig: &'a hir::FnSig<'a>, + generics: &'a hir::Generics<'a>, body_id: hir::BodyId, name: &mut Symbol, - cx: &mut DocContext<'tcx>, + cx: &mut DocContext<'_>, ) -> ItemKind { let attrs = cx.tcx.hir().attrs(item.hir_id()); let macro_kind = attrs.iter().find_map(|a| { @@ -913,18 +911,16 @@ fn clean_fn_or_proc_macro<'a, 'tcx>( } } -impl<'a, 'tcx> Clean<'tcx, Function> - for (&'a hir::FnSig<'tcx>, &'a hir::Generics<'tcx>, hir::BodyId) -{ - fn clean(&self, cx: &mut DocContext<'tcx>) -> Function { +impl<'a> Clean for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::BodyId) { + fn clean(&self, cx: &mut DocContext<'_>) -> Function { let (generics, decl) = enter_impl_trait(cx, |cx| (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx))); Function { decl, generics, header: self.0.header } } } -impl<'a, 'tcx> Clean<'tcx, Arguments> for (&'a [hir::Ty<'tcx>], &'a [Ident]) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Arguments { +impl<'a> Clean for (&'a [hir::Ty<'a>], &'a [Ident]) { + fn clean(&self, cx: &mut DocContext<'_>) -> Arguments { Arguments { values: self .0 @@ -942,8 +938,8 @@ impl<'a, 'tcx> Clean<'tcx, Arguments> for (&'a [hir::Ty<'tcx>], &'a [Ident]) { } } -impl<'a, 'tcx> Clean<'tcx, Arguments> for (&'a [hir::Ty<'tcx>], hir::BodyId) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Arguments { +impl<'a> Clean for (&'a [hir::Ty<'a>], hir::BodyId) { + fn clean(&self, cx: &mut DocContext<'_>) -> Arguments { let body = cx.tcx.hir().body(self.1); Arguments { @@ -952,7 +948,7 @@ impl<'a, 'tcx> Clean<'tcx, Arguments> for (&'a [hir::Ty<'tcx>], hir::BodyId) { .iter() .enumerate() .map(|(i, ty)| Argument { - name: Symbol::intern(&rustc_hir_pretty::param_to_string(&body.params[i])), + name: name_from_pat(&body.params[i].pat), type_: ty.clean(cx), }) .collect(), @@ -960,13 +956,13 @@ impl<'a, 'tcx> Clean<'tcx, Arguments> for (&'a [hir::Ty<'tcx>], hir::BodyId) { } } -impl<'a, 'tcx, A: Copy> Clean<'tcx, FnDecl> for (&'a hir::FnDecl<'tcx>, A) +impl<'a, A: Copy> Clean for (&'a hir::FnDecl<'a>, A) where - (&'a [hir::Ty<'a>], A): Clean<'tcx, Arguments>, + (&'a [hir::Ty<'a>], A): Clean, { - fn clean(&self, cx: &mut DocContext<'tcx>) -> FnDecl { + fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl { FnDecl { - inputs: (&self.0.inputs[..], self.1).clean(cx), + inputs: (self.0.inputs, self.1).clean(cx), output: self.0.output.clean(cx), c_variadic: self.0.c_variadic, attrs: Attributes::default(), @@ -974,8 +970,8 @@ where } } -impl<'tcx> Clean<'tcx, FnDecl> for (DefId, ty::PolyFnSig<'tcx>) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> FnDecl { +impl<'tcx> Clean for (DefId, ty::PolyFnSig<'tcx>) { + fn clean(&self, cx: &mut DocContext<'_>) -> FnDecl { let (did, sig) = *self; let mut names = if did.is_local() { &[] } else { cx.tcx.fn_arg_names(did) }.iter(); @@ -998,8 +994,8 @@ impl<'tcx> Clean<'tcx, FnDecl> for (DefId, ty::PolyFnSig<'tcx>) { } } -impl<'tcx> Clean<'tcx, FnRetTy> for hir::FnRetTy<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> FnRetTy { +impl Clean for hir::FnRetTy<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> FnRetTy { match *self { Self::Return(ref typ) => Return(typ.clean(cx)), Self::DefaultReturn(..) => DefaultReturn, @@ -1007,7 +1003,7 @@ impl<'tcx> Clean<'tcx, FnRetTy> for hir::FnRetTy<'tcx> { } } -impl Clean<'_, bool> for hir::IsAuto { +impl Clean for hir::IsAuto { fn clean(&self, _: &mut DocContext<'_>) -> bool { match *self { hir::IsAuto::Yes => true, @@ -1016,15 +1012,15 @@ impl Clean<'_, bool> for hir::IsAuto { } } -impl<'tcx> Clean<'tcx, Type> for hir::TraitRef<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Type { +impl Clean for hir::TraitRef<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Type { let path = self.path.clean(cx); resolve_type(cx, path, self.hir_ref_id) } } -impl<'tcx> Clean<'tcx, PolyTrait> for hir::PolyTraitRef<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> PolyTrait { +impl Clean for hir::PolyTraitRef<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> PolyTrait { PolyTrait { trait_: self.trait_ref.clean(cx), generic_params: self.bound_generic_params.clean(cx), @@ -1032,14 +1028,14 @@ impl<'tcx> Clean<'tcx, PolyTrait> for hir::PolyTraitRef<'tcx> { } } -impl<'tcx> Clean<'tcx, TypeKind> for hir::def::DefKind { - fn clean(&self, _: &mut DocContext<'tcx>) -> TypeKind { +impl Clean for hir::def::DefKind { + fn clean(&self, _: &mut DocContext<'_>) -> TypeKind { (*self).into() } } -impl<'tcx> Clean<'tcx, Item> for hir::TraitItem<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for hir::TraitItem<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let local_did = self.def_id.to_def_id(); cx.with_param_env(local_did, |cx| { let inner = match self.kind { @@ -1079,8 +1075,8 @@ impl<'tcx> Clean<'tcx, Item> for hir::TraitItem<'tcx> { } } -impl<'tcx> Clean<'tcx, Item> for hir::ImplItem<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for hir::ImplItem<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let local_did = self.def_id.to_def_id(); cx.with_param_env(local_did, |cx| { let inner = match self.kind { @@ -1128,8 +1124,8 @@ impl<'tcx> Clean<'tcx, Item> for hir::ImplItem<'tcx> { } } -impl<'tcx> Clean<'tcx, Item> for ty::AssocItem { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for ty::AssocItem { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let tcx = cx.tcx; let kind = match self.kind { ty::AssocKind::Const => { @@ -1280,7 +1276,7 @@ impl<'tcx> Clean<'tcx, Item> for ty::AssocItem { } } -fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type { +fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type { use rustc_hir::GenericParamCount; let hir::Ty { hir_id, span, ref kind } = *hir_ty; let qpath = match kind { @@ -1432,8 +1428,8 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type } } -impl<'tcx> Clean<'tcx, Type> for hir::Ty<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Type { +impl Clean for hir::Ty<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Type { use rustc_hir::*; match self.kind { @@ -1535,8 +1531,8 @@ fn normalize(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option> { } } -impl<'tcx> Clean<'tcx, Type> for Ty<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Type { +impl<'tcx> Clean for Ty<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> Type { debug!("cleaning type: {:?}", self); let ty = normalize(cx, self).unwrap_or(self); match *ty.kind() { @@ -1743,8 +1739,8 @@ impl<'tcx> Clean<'tcx, Type> for Ty<'tcx> { } } -impl<'tcx> Clean<'tcx, Constant> for ty::Const<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Constant { +impl<'tcx> Clean for ty::Const<'tcx> { + fn clean(&self, cx: &mut DocContext<'_>) -> Constant { // FIXME: instead of storing the stringified expression, store `self` directly instead. Constant { type_: self.ty.clean(cx), @@ -1753,8 +1749,8 @@ impl<'tcx> Clean<'tcx, Constant> for ty::Const<'tcx> { } } -impl<'tcx> Clean<'tcx, Item> for hir::FieldDef<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for hir::FieldDef<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let what_rustc_thinks = Item::from_hir_id_and_parts( self.hir_id, Some(self.ident.name), @@ -1766,8 +1762,8 @@ impl<'tcx> Clean<'tcx, Item> for hir::FieldDef<'tcx> { } } -impl Clean<'tcx, Item> for ty::FieldDef { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for ty::FieldDef { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let what_rustc_thinks = Item::from_def_id_and_parts( self.did, Some(self.ident.name), @@ -1779,8 +1775,8 @@ impl Clean<'tcx, Item> for ty::FieldDef { } } -impl<'tcx> Clean<'tcx, Visibility> for hir::Visibility<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Visibility { +impl Clean for hir::Visibility<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Visibility { match self.node { hir::VisibilityKind::Public => Visibility::Public, hir::VisibilityKind::Inherited => Visibility::Inherited, @@ -1797,8 +1793,8 @@ impl<'tcx> Clean<'tcx, Visibility> for hir::Visibility<'tcx> { } } -impl<'tcx> Clean<'tcx, Visibility> for ty::Visibility { - fn clean(&self, _cx: &mut DocContext<'tcx>) -> Visibility { +impl Clean for ty::Visibility { + fn clean(&self, _cx: &mut DocContext<'_>) -> Visibility { match *self { ty::Visibility::Public => Visibility::Public, // NOTE: this is not quite right: `ty` uses `Invisible` to mean 'private', @@ -1812,8 +1808,8 @@ impl<'tcx> Clean<'tcx, Visibility> for ty::Visibility { } } -impl<'tcx> Clean<'tcx, VariantStruct> for rustc_hir::VariantData<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> VariantStruct { +impl Clean for rustc_hir::VariantData<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> VariantStruct { VariantStruct { struct_type: CtorKind::from_hir(self), fields: self.fields().iter().map(|x| x.clean(cx)).collect(), @@ -1822,8 +1818,8 @@ impl<'tcx> Clean<'tcx, VariantStruct> for rustc_hir::VariantData<'tcx> { } } -impl<'tcx> Clean<'tcx, Item> for ty::VariantDef { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for ty::VariantDef { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let kind = match self.ctor_kind { CtorKind::Const => Variant::CLike, CtorKind::Fn => Variant::Tuple( @@ -1853,8 +1849,8 @@ impl<'tcx> Clean<'tcx, Item> for ty::VariantDef { } } -impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Variant { +impl Clean for hir::VariantData<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Variant { match self { hir::VariantData::Struct(..) => Variant::Struct(self.clean(cx)), hir::VariantData::Tuple(..) => { @@ -1865,14 +1861,14 @@ impl<'tcx> Clean<'tcx, Variant> for hir::VariantData<'tcx> { } } -impl<'tcx> Clean<'tcx, Span> for rustc_span::Span { - fn clean(&self, _cx: &mut DocContext<'tcx>) -> Span { +impl Clean for rustc_span::Span { + fn clean(&self, _cx: &mut DocContext<'_>) -> Span { Span::from_rustc_span(*self) } } -impl<'tcx> Clean<'tcx, Path> for hir::Path<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Path { +impl Clean for hir::Path<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Path { Path { global: self.is_global(), res: self.res, @@ -1881,8 +1877,8 @@ impl<'tcx> Clean<'tcx, Path> for hir::Path<'tcx> { } } -impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> GenericArgs { +impl Clean for hir::GenericArgs<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> GenericArgs { if self.parenthesized { let output = self.bindings[0].ty().clean(cx); GenericArgs::Parenthesized { @@ -1909,28 +1905,28 @@ impl<'tcx> Clean<'tcx, GenericArgs> for hir::GenericArgs<'tcx> { } } -impl<'tcx> Clean<'tcx, PathSegment> for hir::PathSegment<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> PathSegment { +impl Clean for hir::PathSegment<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> PathSegment { PathSegment { name: self.ident.name, args: self.args().clean(cx) } } } -impl<'tcx> Clean<'tcx, String> for Ident { +impl Clean for Ident { #[inline] - fn clean(&self, cx: &mut DocContext<'tcx>) -> String { + fn clean(&self, cx: &mut DocContext<'_>) -> String { self.name.clean(cx) } } -impl<'tcx> Clean<'tcx, String> for Symbol { +impl Clean for Symbol { #[inline] - fn clean(&self, _: &mut DocContext<'tcx>) -> String { + fn clean(&self, _: &mut DocContext<'_>) -> String { self.to_string() } } -impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> BareFunctionDecl { +impl Clean for hir::BareFnTy<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> BareFunctionDecl { let (generic_params, decl) = enter_impl_trait(cx, |cx| { (self.generic_params.clean(cx), (&*self.decl, self.param_names).clean(cx)) }); @@ -1938,8 +1934,8 @@ impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> { } } -impl<'tcx> Clean<'tcx, Vec> for (&hir::Item<'tcx>, Option) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Vec { +impl Clean> for (&hir::Item<'_>, Option) { + fn clean(&self, cx: &mut DocContext<'_>) -> Vec { use hir::ItemKind; let (item, renamed) = self; @@ -2022,8 +2018,8 @@ impl<'tcx> Clean<'tcx, Vec> for (&hir::Item<'tcx>, Option) { } } -impl<'tcx> Clean<'tcx, Item> for hir::Variant<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for hir::Variant<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let kind = VariantItem(self.data.clean(cx)); let what_rustc_thinks = Item::from_hir_id_and_parts(self.id, Some(self.ident.name), kind, cx); @@ -2032,9 +2028,9 @@ impl<'tcx> Clean<'tcx, Item> for hir::Variant<'tcx> { } } -impl<'tcx> Clean<'tcx, bool> for ty::ImplPolarity { +impl Clean for ty::ImplPolarity { /// Returns whether the impl has negative polarity. - fn clean(&self, _: &mut DocContext<'tcx>) -> bool { + fn clean(&self, _: &mut DocContext<'_>) -> bool { match self { &ty::ImplPolarity::Positive | // FIXME: do we want to do something else here? @@ -2044,11 +2040,7 @@ impl<'tcx> Clean<'tcx, bool> for ty::ImplPolarity { } } -fn clean_impl<'tcx>( - impl_: &hir::Impl<'tcx>, - hir_id: hir::HirId, - cx: &mut DocContext<'tcx>, -) -> Vec { +fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>) -> Vec { let tcx = cx.tcx; let mut ret = Vec::new(); let trait_ = impl_.of_trait.clean(cx); @@ -2093,11 +2085,11 @@ fn clean_impl<'tcx>( ret } -fn clean_extern_crate<'tcx>( - krate: &hir::Item<'tcx>, +fn clean_extern_crate( + krate: &hir::Item<'_>, name: Symbol, orig_name: Option, - cx: &mut DocContext<'tcx>, + cx: &mut DocContext<'_>, ) -> Vec { // this is the ID of the `extern crate` statement let cnum = cx.tcx.extern_mod_stmt_cnum(krate.def_id).unwrap_or(LOCAL_CRATE); @@ -2140,12 +2132,12 @@ fn clean_extern_crate<'tcx>( }] } -fn clean_use_statement<'tcx>( - import: &hir::Item<'tcx>, +fn clean_use_statement( + import: &hir::Item<'_>, name: Symbol, - path: &hir::Path<'tcx>, + path: &hir::Path<'_>, kind: hir::UseKind, - cx: &mut DocContext<'tcx>, + cx: &mut DocContext<'_>, ) -> Vec { // We need this comparison because some imports (for std types for example) // are "inserted" as well but directly by the compiler and they should not be @@ -2235,8 +2227,8 @@ fn clean_use_statement<'tcx>( vec![Item::from_def_id_and_parts(import.def_id.to_def_id(), None, ImportItem(inner), cx)] } -impl<'tcx> Clean<'tcx, Item> for (&hir::ForeignItem<'tcx>, Option) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for (&hir::ForeignItem<'_>, Option) { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let (item, renamed) = self; cx.with_param_env(item.def_id.to_def_id(), |cx| { let kind = match item.kind { @@ -2272,8 +2264,8 @@ impl<'tcx> Clean<'tcx, Item> for (&hir::ForeignItem<'tcx>, Option) { } } -impl<'tcx> Clean<'tcx, Item> for (&hir::MacroDef<'tcx>, Option) { - fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { +impl Clean for (&hir::MacroDef<'_>, Option) { + fn clean(&self, cx: &mut DocContext<'_>) -> Item { let (item, renamed) = self; let name = renamed.unwrap_or(item.ident.name); let tts = item.ast.body.inner_tokens().trees().collect::>(); @@ -2321,14 +2313,14 @@ impl<'tcx> Clean<'tcx, Item> for (&hir::MacroDef<'tcx>, Option) { } } -impl<'tcx> Clean<'tcx, TypeBinding> for hir::TypeBinding<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBinding { +impl Clean for hir::TypeBinding<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> TypeBinding { TypeBinding { name: self.ident.name, kind: self.kind.clean(cx) } } } -impl<'tcx> Clean<'tcx, TypeBindingKind> for hir::TypeBindingKind<'tcx> { - fn clean(&self, cx: &mut DocContext<'tcx>) -> TypeBindingKind { +impl Clean for hir::TypeBindingKind<'_> { + fn clean(&self, cx: &mut DocContext<'_>) -> TypeBindingKind { match *self { hir::TypeBindingKind::Equality { ref ty } => { TypeBindingKind::Equality { ty: ty.clean(cx) } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index ce802902f5b..32bac53e8f5 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -84,12 +84,12 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate { } } -fn external_generic_args<'tcx>( - cx: &mut DocContext<'tcx>, +fn external_generic_args( + cx: &mut DocContext<'_>, trait_did: Option, has_self: bool, bindings: Vec, - substs: SubstsRef<'tcx>, + substs: SubstsRef<'_>, ) -> GenericArgs { let mut skip_self = has_self; let mut ty_kind = None; @@ -136,13 +136,13 @@ fn external_generic_args<'tcx>( // trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar // from Fn<(A, B,), C> to Fn(A, B) -> C -pub(super) fn external_path<'tcx>( - cx: &mut DocContext<'tcx>, +pub(super) fn external_path( + cx: &mut DocContext<'_>, name: Symbol, trait_did: Option, has_self: bool, bindings: Vec, - substs: SubstsRef<'tcx>, + substs: SubstsRef<'_>, ) -> Path { Path { global: false,