Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4f8ffd0

Browse files
committed
remove unnecessary lifetimes that can be elided
1 parent 8615bba commit 4f8ffd0

File tree

11 files changed

+49
-63
lines changed

11 files changed

+49
-63
lines changed

crates/hir-def/src/generics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ pub enum WherePredicateTypeTarget {
142142

143143
impl GenericParams {
144144
/// Iterator of type_or_consts field
145-
pub fn iter<'a>(
146-
&'a self,
145+
pub fn iter(
146+
&self,
147147
) -> impl DoubleEndedIterator<Item = (Idx<TypeOrConstParamData>, &TypeOrConstParamData)> {
148148
self.type_or_consts.iter()
149149
}

crates/hir-def/src/import_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ impl Query {
393393
/// Searches dependencies of `krate` for an importable path matching `query`.
394394
///
395395
/// This returns a list of items that could be imported from dependencies of `krate`.
396-
pub fn search_dependencies<'a>(
397-
db: &'a dyn DefDatabase,
396+
pub fn search_dependencies(
397+
db: &dyn DefDatabase,
398398
krate: CrateId,
399399
query: Query,
400400
) -> FxHashSet<ItemInNs> {

crates/hir-def/src/item_scope.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub(crate) enum BuiltinShadowMode {
9696
/// Legacy macros can only be accessed through special methods like `get_legacy_macros`.
9797
/// Other methods will only resolve values, types and module scoped macros only.
9898
impl ItemScope {
99-
pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, PerNs)> + 'a {
99+
pub fn entries(&self) -> impl Iterator<Item = (&Name, PerNs)> + '_ {
100100
// FIXME: shadowing
101101
self.types
102102
.keys()
@@ -169,7 +169,7 @@ impl ItemScope {
169169
iter.find_map(|(name, &(other_def, vis))| (other_def == def).then_some((name, vis)))
170170
}
171171

172-
pub(crate) fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a {
172+
pub(crate) fn traits(&self) -> impl Iterator<Item = TraitId> + '_ {
173173
self.types
174174
.values()
175175
.filter_map(|&(def, _)| match def {
@@ -326,7 +326,7 @@ impl ItemScope {
326326
changed
327327
}
328328

329-
pub(crate) fn resolutions<'a>(&'a self) -> impl Iterator<Item = (Option<Name>, PerNs)> + 'a {
329+
pub(crate) fn resolutions(&self) -> impl Iterator<Item = (Option<Name>, PerNs)> + '_ {
330330
self.entries().map(|(name, res)| (Some(name.clone()), res)).chain(
331331
self.unnamed_trait_imports
332332
.iter()

crates/hir-ty/src/autoderef.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ pub(crate) fn autoderef_step(
8282
}
8383

8484
// FIXME: replace uses of this with Autoderef above
85-
pub fn autoderef<'a>(
86-
db: &'a dyn HirDatabase,
85+
pub fn autoderef(
86+
db: &dyn HirDatabase,
8787
env: Arc<TraitEnvironment>,
8888
ty: Canonical<Ty>,
89-
) -> impl Iterator<Item = Canonical<Ty>> + 'a {
89+
) -> impl Iterator<Item = Canonical<Ty>> + '_ {
9090
let mut table = InferenceTable::new(db, env);
9191
let ty = table.instantiate_canonical(ty);
9292
let mut autoderef = Autoderef::new(&mut table, ty);

crates/hir-ty/src/consteval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,10 @@ pub(crate) fn const_eval_query_variant(
511511
)
512512
}
513513

514-
pub(crate) fn eval_to_const<'a>(
514+
pub(crate) fn eval_to_const(
515515
expr: Idx<Expr>,
516516
mode: ParamLoweringMode,
517-
ctx: &mut InferenceContext<'a>,
517+
ctx: &mut InferenceContext<'_>,
518518
args: impl FnOnce() -> Generics,
519519
debruijn: DebruijnIndex,
520520
) -> Const {

crates/hir-ty/src/interner.rs

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -228,26 +228,23 @@ impl chalk_ir::interner::Interner for Interner {
228228
Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags }))
229229
}
230230

231-
fn ty_data<'a>(self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
231+
fn ty_data(self, ty: &Self::InternedType) -> &chalk_ir::TyData<Self> {
232232
&ty.0
233233
}
234234

235235
fn intern_lifetime(self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
236236
Interned::new(InternedWrapper(lifetime))
237237
}
238238

239-
fn lifetime_data<'a>(
240-
self,
241-
lifetime: &'a Self::InternedLifetime,
242-
) -> &'a chalk_ir::LifetimeData<Self> {
239+
fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &chalk_ir::LifetimeData<Self> {
243240
&lifetime.0
244241
}
245242

246243
fn intern_const(self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
247244
Interned::new(InternedWrapper(constant))
248245
}
249246

250-
fn const_data<'a>(self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
247+
fn const_data(self, constant: &Self::InternedConst) -> &chalk_ir::ConstData<Self> {
251248
&constant.0
252249
}
253250

@@ -267,10 +264,10 @@ impl chalk_ir::interner::Interner for Interner {
267264
parameter
268265
}
269266

270-
fn generic_arg_data<'a>(
267+
fn generic_arg_data(
271268
self,
272-
parameter: &'a Self::InternedGenericArg,
273-
) -> &'a chalk_ir::GenericArgData<Self> {
269+
parameter: &Self::InternedGenericArg,
270+
) -> &chalk_ir::GenericArgData<Self> {
274271
parameter
275272
}
276273

@@ -285,11 +282,11 @@ impl chalk_ir::interner::Interner for Interner {
285282
data.into_iter().collect()
286283
}
287284

288-
fn goal_data<'a>(self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
285+
fn goal_data(self, goal: &Self::InternedGoal) -> &GoalData<Self> {
289286
goal
290287
}
291288

292-
fn goals_data<'a>(self, goals: &'a Self::InternedGoals) -> &'a [Goal<Interner>] {
289+
fn goals_data(self, goals: &Self::InternedGoals) -> &[Goal<Interner>] {
293290
goals
294291
}
295292

@@ -300,10 +297,7 @@ impl chalk_ir::interner::Interner for Interner {
300297
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
301298
}
302299

303-
fn substitution_data<'a>(
304-
self,
305-
substitution: &'a Self::InternedSubstitution,
306-
) -> &'a [GenericArg] {
300+
fn substitution_data(self, substitution: &Self::InternedSubstitution) -> &[GenericArg] {
307301
&substitution.as_ref().0
308302
}
309303

@@ -314,10 +308,10 @@ impl chalk_ir::interner::Interner for Interner {
314308
data
315309
}
316310

317-
fn program_clause_data<'a>(
311+
fn program_clause_data(
318312
self,
319-
clause: &'a Self::InternedProgramClause,
320-
) -> &'a chalk_ir::ProgramClauseData<Self> {
313+
clause: &Self::InternedProgramClause,
314+
) -> &chalk_ir::ProgramClauseData<Self> {
321315
clause
322316
}
323317

@@ -328,10 +322,10 @@ impl chalk_ir::interner::Interner for Interner {
328322
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
329323
}
330324

331-
fn program_clauses_data<'a>(
325+
fn program_clauses_data(
332326
self,
333-
clauses: &'a Self::InternedProgramClauses,
334-
) -> &'a [chalk_ir::ProgramClause<Self>] {
327+
clauses: &Self::InternedProgramClauses,
328+
) -> &[chalk_ir::ProgramClause<Self>] {
335329
clauses
336330
}
337331

@@ -342,10 +336,10 @@ impl chalk_ir::interner::Interner for Interner {
342336
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
343337
}
344338

345-
fn quantified_where_clauses_data<'a>(
339+
fn quantified_where_clauses_data(
346340
self,
347-
clauses: &'a Self::InternedQuantifiedWhereClauses,
348-
) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] {
341+
clauses: &Self::InternedQuantifiedWhereClauses,
342+
) -> &[chalk_ir::QuantifiedWhereClause<Self>] {
349343
clauses
350344
}
351345

@@ -356,10 +350,10 @@ impl chalk_ir::interner::Interner for Interner {
356350
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
357351
}
358352

359-
fn variable_kinds_data<'a>(
353+
fn variable_kinds_data(
360354
self,
361-
parameter_kinds: &'a Self::InternedVariableKinds,
362-
) -> &'a [chalk_ir::VariableKind<Self>] {
355+
parameter_kinds: &Self::InternedVariableKinds,
356+
) -> &[chalk_ir::VariableKind<Self>] {
363357
&parameter_kinds.as_ref().0
364358
}
365359

@@ -370,10 +364,10 @@ impl chalk_ir::interner::Interner for Interner {
370364
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
371365
}
372366

373-
fn canonical_var_kinds_data<'a>(
367+
fn canonical_var_kinds_data(
374368
self,
375-
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
376-
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
369+
canonical_var_kinds: &Self::InternedCanonicalVarKinds,
370+
) -> &[chalk_ir::CanonicalVarKind<Self>] {
377371
canonical_var_kinds
378372
}
379373

@@ -384,10 +378,10 @@ impl chalk_ir::interner::Interner for Interner {
384378
data.into_iter().collect()
385379
}
386380

387-
fn constraints_data<'a>(
381+
fn constraints_data(
388382
self,
389-
constraints: &'a Self::InternedConstraints,
390-
) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
383+
constraints: &Self::InternedConstraints,
384+
) -> &[chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
391385
constraints
392386
}
393387
fn debug_closure_id(
@@ -410,10 +404,7 @@ impl chalk_ir::interner::Interner for Interner {
410404
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
411405
}
412406

413-
fn variances_data<'a>(
414-
self,
415-
variances: &'a Self::InternedVariances,
416-
) -> &'a [chalk_ir::Variance] {
407+
fn variances_data(self, variances: &Self::InternedVariances) -> &[chalk_ir::Variance] {
417408
variances
418409
}
419410
}

crates/hir-ty/src/traits.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ impl TraitEnvironment {
5555
}
5656
}
5757

58-
pub fn traits_in_scope_from_clauses<'a>(
59-
&'a self,
60-
ty: Ty,
61-
) -> impl Iterator<Item = TraitId> + 'a {
58+
pub fn traits_in_scope_from_clauses(&self, ty: Ty) -> impl Iterator<Item = TraitId> + '_ {
6259
self.traits_from_clauses
6360
.iter()
6461
.filter_map(move |(self_ty, trait_id)| (*self_ty == ty).then_some(*trait_id))

crates/hir-ty/src/utils.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ pub(crate) struct Generics {
184184
}
185185

186186
impl Generics {
187-
pub(crate) fn iter_id<'a>(
188-
&'a self,
189-
) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + 'a {
187+
pub(crate) fn iter_id(&self) -> impl Iterator<Item = Either<TypeParamId, ConstParamId>> + '_ {
190188
self.iter().map(|(id, data)| match data {
191189
TypeOrConstParamData::TypeParamData(_) => Either::Left(TypeParamId::from_unchecked(id)),
192190
TypeOrConstParamData::ConstParamData(_) => {
@@ -216,9 +214,9 @@ impl Generics {
216214
}
217215

218216
/// Iterator over types and const params of parent.
219-
pub(crate) fn iter_parent<'a>(
220-
&'a self,
221-
) -> impl DoubleEndedIterator<Item = (TypeOrConstParamId, &'a TypeOrConstParamData)> + 'a {
217+
pub(crate) fn iter_parent(
218+
&self,
219+
) -> impl DoubleEndedIterator<Item = (TypeOrConstParamId, &TypeOrConstParamData)> {
222220
self.parent_generics().into_iter().flat_map(|it| {
223221
let to_toc_id =
224222
move |(local_id, p)| (TypeOrConstParamId { parent: it.def, local_id }, p);

crates/ide/src/doc_links.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl DocCommentToken {
285285
}
286286
}
287287

288-
fn broken_link_clone_cb<'a>(link: BrokenLink<'a>) -> Option<(CowStr<'a>, CowStr<'a>)> {
288+
fn broken_link_clone_cb(link: BrokenLink<'_>) -> Option<(CowStr<'_>, CowStr<'_>)> {
289289
Some((/*url*/ link.reference.clone(), /*title*/ link.reference))
290290
}
291291

crates/mbe/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ enum Mode {
116116
Template,
117117
}
118118

119-
fn next_op<'a>(
119+
fn next_op(
120120
first_peeked: &tt::TokenTree,
121-
src: &mut TtIter<'a>,
121+
src: &mut TtIter<'_>,
122122
mode: Mode,
123123
) -> Result<Op, ParseError> {
124124
let res = match first_peeked {

crates/project-model/src/cargo_workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ impl CargoWorkspace {
411411
CargoWorkspace { packages, targets, workspace_root }
412412
}
413413

414-
pub fn packages<'a>(&'a self) -> impl Iterator<Item = Package> + ExactSizeIterator + 'a {
414+
pub fn packages(&self) -> impl Iterator<Item = Package> + ExactSizeIterator + '_ {
415415
self.packages.iter().map(|(id, _pkg)| id)
416416
}
417417

0 commit comments

Comments
 (0)