diff options
| author | Daniel Eades <danieleades@hotmail.com> | 2022-12-30 09:00:42 +0000 |
|---|---|---|
| committer | Daniel Eades <danieleades@hotmail.com> | 2023-01-02 15:02:54 +0000 |
| commit | 4f8ffd0ba4efc54ad09417d4aeb23f9fa00c1748 (patch) | |
| tree | 81720a5c2072b2e48be66240e9352d4da391c32d | |
| parent | 8615bba1054395891a6d881623b89ff5ee6ed5bd (diff) | |
| download | rust-4f8ffd0ba4efc54ad09417d4aeb23f9fa00c1748.tar.gz rust-4f8ffd0ba4efc54ad09417d4aeb23f9fa00c1748.zip | |
remove unnecessary lifetimes that can be elided
| -rw-r--r-- | crates/hir-def/src/generics.rs | 4 | ||||
| -rw-r--r-- | crates/hir-def/src/import_map.rs | 4 | ||||
| -rw-r--r-- | crates/hir-def/src/item_scope.rs | 6 | ||||
| -rw-r--r-- | crates/hir-ty/src/autoderef.rs | 6 | ||||
| -rw-r--r-- | crates/hir-ty/src/consteval.rs | 4 | ||||
| -rw-r--r-- | crates/hir-ty/src/interner.rs | 65 | ||||
| -rw-r--r-- | crates/hir-ty/src/traits.rs | 5 | ||||
| -rw-r--r-- | crates/hir-ty/src/utils.rs | 10 | ||||
| -rw-r--r-- | crates/ide/src/doc_links.rs | 2 | ||||
| -rw-r--r-- | crates/mbe/src/parser.rs | 4 | ||||
| -rw-r--r-- | crates/project-model/src/cargo_workspace.rs | 2 |
11 files changed, 49 insertions, 63 deletions
diff --git a/crates/hir-def/src/generics.rs b/crates/hir-def/src/generics.rs index 469b28c2d9e..f74559f5d66 100644 --- a/crates/hir-def/src/generics.rs +++ b/crates/hir-def/src/generics.rs @@ -142,8 +142,8 @@ pub enum WherePredicateTypeTarget { impl GenericParams { /// Iterator of type_or_consts field - pub fn iter<'a>( - &'a self, + pub fn iter( + &self, ) -> impl DoubleEndedIterator<Item = (Idx<TypeOrConstParamData>, &TypeOrConstParamData)> { self.type_or_consts.iter() } diff --git a/crates/hir-def/src/import_map.rs b/crates/hir-def/src/import_map.rs index 193c7662008..63e92df0e72 100644 --- a/crates/hir-def/src/import_map.rs +++ b/crates/hir-def/src/import_map.rs @@ -393,8 +393,8 @@ impl Query { /// Searches dependencies of `krate` for an importable path matching `query`. /// /// This returns a list of items that could be imported from dependencies of `krate`. -pub fn search_dependencies<'a>( - db: &'a dyn DefDatabase, +pub fn search_dependencies( + db: &dyn DefDatabase, krate: CrateId, query: Query, ) -> FxHashSet<ItemInNs> { diff --git a/crates/hir-def/src/item_scope.rs b/crates/hir-def/src/item_scope.rs index 6753d61ef81..c7b213b7e98 100644 --- a/crates/hir-def/src/item_scope.rs +++ b/crates/hir-def/src/item_scope.rs @@ -96,7 +96,7 @@ pub(crate) enum BuiltinShadowMode { /// Legacy macros can only be accessed through special methods like `get_legacy_macros`. /// Other methods will only resolve values, types and module scoped macros only. impl ItemScope { - pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a { + pub fn entries(&self) -> impl Iterator<Item = (&Name, PerNs)> + '_ { // FIXME: shadowing self.types .keys() @@ -169,7 +169,7 @@ impl ItemScope { iter.find_map(|(name, &(other_def, vis))| (other_def == def).then_some((name, vis))) } - pub(crate) fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a { + pub(crate) fn traits(&self) -> impl Iterator<Item = TraitId> + '_ { self.types .values() .filter_map(|&(def, _)| match def { @@ -326,7 +326,7 @@ impl ItemScope { changed } - pub(crate) fn resolutions<'a>(&'a self) -> impl Iterator<Item = (Option<Name>, PerNs)> + 'a { + pub(crate) fn resolutions(&self) -> impl Iterator<Item = (Option<Name>, PerNs)> + '_ { self.entries().map(|(name, res)| (Some(name.clone()), res)).chain( self.unnamed_trait_imports .iter() diff --git a/crates/hir-ty/src/autoderef.rs b/crates/hir-ty/src/autoderef.rs index 78911d8dc07..cbcf8f74c55 100644 --- a/crates/hir-ty/src/autoderef.rs +++ b/crates/hir-ty/src/autoderef.rs @@ -82,11 +82,11 @@ pub(crate) fn autoderef_step( } // FIXME: replace uses of this with Autoderef above -pub fn autoderef<'a>( - db: &'a dyn HirDatabase, +pub fn autoderef( + db: &dyn HirDatabase, env: Arc<TraitEnvironment>, ty: Canonical<Ty>, -) -> impl Iterator<Item = Canonical<Ty>> + 'a { +) -> impl Iterator<Item = Canonical<Ty>> + '_ { let mut table = InferenceTable::new(db, env); let ty = table.instantiate_canonical(ty); let mut autoderef = Autoderef::new(&mut table, ty); diff --git a/crates/hir-ty/src/consteval.rs b/crates/hir-ty/src/consteval.rs index d1660914766..dfec0aaa296 100644 --- a/crates/hir-ty/src/consteval.rs +++ b/crates/hir-ty/src/consteval.rs @@ -511,10 +511,10 @@ pub(crate) fn const_eval_query_variant( ) } -pub(crate) fn eval_to_const<'a>( +pub(crate) fn eval_to_const( expr: Idx<Expr>, mode: ParamLoweringMode, - ctx: &mut InferenceContext<'a>, + ctx: &mut InferenceContext<'_>, args: impl FnOnce() -> Generics, debruijn: DebruijnIndex, ) -> Const { diff --git a/crates/hir-ty/src/interner.rs b/crates/hir-ty/src/interner.rs index 01b5719be4c..441503a300e 100644 --- a/crates/hir-ty/src/interner.rs +++ b/crates/hir-ty/src/interner.rs @@ -228,7 +228,7 @@ impl chalk_ir::interner::Interner for Interner { Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags })) } - fn ty_data<'a>(self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> { + fn ty_data(self, ty: &Self::InternedType) -> &chalk_ir::TyData<Self> { &ty.0 } @@ -236,10 +236,7 @@ impl chalk_ir::interner::Interner for Interner { Interned::new(InternedWrapper(lifetime)) } - fn lifetime_data<'a>( - self, - lifetime: &'a Self::InternedLifetime, - ) -> &'a chalk_ir::LifetimeData<Self> { + fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &chalk_ir::LifetimeData<Self> { &lifetime.0 } @@ -247,7 +244,7 @@ impl chalk_ir::interner::Interner for Interner { Interned::new(InternedWrapper(constant)) } - fn const_data<'a>(self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> { + fn const_data(self, constant: &Self::InternedConst) -> &chalk_ir::ConstData<Self> { &constant.0 } @@ -267,10 +264,10 @@ impl chalk_ir::interner::Interner for Interner { parameter } - fn generic_arg_data<'a>( + fn generic_arg_data( self, - parameter: &'a Self::InternedGenericArg, - ) -> &'a chalk_ir::GenericArgData<Self> { + parameter: &Self::InternedGenericArg, + ) -> &chalk_ir::GenericArgData<Self> { parameter } @@ -285,11 +282,11 @@ impl chalk_ir::interner::Interner for Interner { data.into_iter().collect() } - fn goal_data<'a>(self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> { + fn goal_data(self, goal: &Self::InternedGoal) -> &GoalData<Self> { goal } - fn goals_data<'a>(self, goals: &'a Self::InternedGoals) -> &'a [Goal<Interner>] { + fn goals_data(self, goals: &Self::InternedGoals) -> &[Goal<Interner>] { goals } @@ -300,10 +297,7 @@ impl chalk_ir::interner::Interner for Interner { Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) } - fn substitution_data<'a>( - self, - substitution: &'a Self::InternedSubstitution, - ) -> &'a [GenericArg] { + fn substitution_data(self, substitution: &Self::InternedSubstitution) -> &[GenericArg] { &substitution.as_ref().0 } @@ -314,10 +308,10 @@ impl chalk_ir::interner::Interner for Interner { data } - fn program_clause_data<'a>( + fn program_clause_data( self, - clause: &'a Self::InternedProgramClause, - ) -> &'a chalk_ir::ProgramClauseData<Self> { + clause: &Self::InternedProgramClause, + ) -> &chalk_ir::ProgramClauseData<Self> { clause } @@ -328,10 +322,10 @@ impl chalk_ir::interner::Interner for Interner { Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) } - fn program_clauses_data<'a>( + fn program_clauses_data( self, - clauses: &'a Self::InternedProgramClauses, - ) -> &'a [chalk_ir::ProgramClause<Self>] { + clauses: &Self::InternedProgramClauses, + ) -> &[chalk_ir::ProgramClause<Self>] { clauses } @@ -342,10 +336,10 @@ impl chalk_ir::interner::Interner for Interner { Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) } - fn quantified_where_clauses_data<'a>( + fn quantified_where_clauses_data( self, - clauses: &'a Self::InternedQuantifiedWhereClauses, - ) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] { + clauses: &Self::InternedQuantifiedWhereClauses, + ) -> &[chalk_ir::QuantifiedWhereClause<Self>] { clauses } @@ -356,10 +350,10 @@ impl chalk_ir::interner::Interner for Interner { Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) } - fn variable_kinds_data<'a>( + fn variable_kinds_data( self, - parameter_kinds: &'a Self::InternedVariableKinds, - ) -> &'a [chalk_ir::VariableKind<Self>] { + parameter_kinds: &Self::InternedVariableKinds, + ) -> &[chalk_ir::VariableKind<Self>] { ¶meter_kinds.as_ref().0 } @@ -370,10 +364,10 @@ impl chalk_ir::interner::Interner for Interner { Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) } - fn canonical_var_kinds_data<'a>( + fn canonical_var_kinds_data( self, - canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, - ) -> &'a [chalk_ir::CanonicalVarKind<Self>] { + canonical_var_kinds: &Self::InternedCanonicalVarKinds, + ) -> &[chalk_ir::CanonicalVarKind<Self>] { canonical_var_kinds } @@ -384,10 +378,10 @@ impl chalk_ir::interner::Interner for Interner { data.into_iter().collect() } - fn constraints_data<'a>( + fn constraints_data( self, - constraints: &'a Self::InternedConstraints, - ) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] { + constraints: &Self::InternedConstraints, + ) -> &[chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] { constraints } fn debug_closure_id( @@ -410,10 +404,7 @@ impl chalk_ir::interner::Interner for Interner { Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?))) } - fn variances_data<'a>( - self, - variances: &'a Self::InternedVariances, - ) -> &'a [chalk_ir::Variance] { + fn variances_data(self, variances: &Self::InternedVariances) -> &[chalk_ir::Variance] { variances } } diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs index 2d3a93392b3..778a6b82047 100644 --- a/crates/hir-ty/src/traits.rs +++ b/crates/hir-ty/src/traits.rs @@ -55,10 +55,7 @@ impl TraitEnvironment { } } - pub fn traits_in_scope_from_clauses<'a>( - &'a self, - ty: Ty, - ) -> impl Iterator<Item = TraitId> + 'a { + pub fn traits_in_scope_from_clauses(&self, ty: Ty) -> impl Iterator<Item = TraitId> + '_ { self.traits_from_clauses .iter() .filter_map(move |(self_ty, trait_id)| (*self_ty == ty).then_some(*trait_id)) diff --git a/crates/hir-ty/src/utils.rs b/crates/hir-ty/src/utils.rs index 1f3470a3622..9893566bd54 100644 --- a/crates/hir-ty/src/utils.rs +++ b/crates/hir-ty/src/utils.rs @@ -184,9 +184,7 @@ pub(crate) struct Generics { } impl Generics { - pub(crate) fn iter_id<'a>( - &'a self, - ) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + 'a { + pub(crate) fn iter_id(&self) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + '_ { self.iter().map(|(id, data)| match data { TypeOrConstParamData::TypeParamData(_) => Either::Left(TypeParamId::from_unchecked(id)), TypeOrConstParamData::ConstParamData(_) => { @@ -216,9 +214,9 @@ impl Generics { } /// Iterator over types and const params of parent. - pub(crate) fn iter_parent<'a>( - &'a self, - ) -> impl DoubleEndedIterator<Item = (TypeOrConstParamId, &'a TypeOrConstParamData)> + 'a { + pub(crate) fn iter_parent( + &self, + ) -> impl DoubleEndedIterator<Item = (TypeOrConstParamId, &TypeOrConstParamData)> { self.parent_generics().into_iter().flat_map(|it| { let to_toc_id = move |(local_id, p)| (TypeOrConstParamId { parent: it.def, local_id }, p); diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index f937175deae..b4a7f2b918a 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -285,7 +285,7 @@ impl DocCommentToken { } } -fn broken_link_clone_cb<'a>(link: BrokenLink<'a>) -> Option<(CowStr<'a>, CowStr<'a>)> { +fn broken_link_clone_cb(link: BrokenLink<'_>) -> Option<(CowStr<'_>, CowStr<'_>)> { Some((/*url*/ link.reference.clone(), /*title*/ link.reference)) } diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index d4345ba4780..fad905e97f4 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs @@ -116,9 +116,9 @@ enum Mode { Template, } -fn next_op<'a>( +fn next_op( first_peeked: &tt::TokenTree, - src: &mut TtIter<'a>, + src: &mut TtIter<'_>, mode: Mode, ) -> Result<Op, ParseError> { let res = match first_peeked { diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs index f2a972094f8..467cf091787 100644 --- a/crates/project-model/src/cargo_workspace.rs +++ b/crates/project-model/src/cargo_workspace.rs @@ -411,7 +411,7 @@ impl CargoWorkspace { CargoWorkspace { packages, targets, workspace_root } } - pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + ExactSizeIterator + 'a { + pub fn packages(&self) -> impl Iterator<Item = Package> + ExactSizeIterator + '_ { self.packages.iter().map(|(id, _pkg)| id) } |
