Skip to content

Commit 4e793e7

Browse files
committed
Use anonymous lifetime where possible
1 parent 70a01fe commit 4e793e7

File tree

30 files changed

+60
-60
lines changed

30 files changed

+60
-60
lines changed

crates/hir-def/src/body/pretty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct Printer<'a> {
105105
needs_indent: bool,
106106
}
107107

108-
impl<'a> Write for Printer<'a> {
108+
impl Write for Printer<'_> {
109109
fn write_str(&mut self, s: &str) -> fmt::Result {
110110
for line in s.split_inclusive('\n') {
111111
if self.needs_indent {
@@ -125,7 +125,7 @@ impl<'a> Write for Printer<'a> {
125125
}
126126
}
127127

128-
impl<'a> Printer<'a> {
128+
impl Printer<'_> {
129129
fn indented(&mut self, f: impl FnOnce(&mut Self)) {
130130
self.indent_level += 1;
131131
wln!(self);

crates/hir-def/src/item_tree/pretty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct Printer<'a> {
5252
needs_indent: bool,
5353
}
5454

55-
impl<'a> Printer<'a> {
55+
impl Printer<'_> {
5656
fn indented(&mut self, f: impl FnOnce(&mut Self)) {
5757
self.indent_level += 1;
5858
wln!(self);
@@ -572,7 +572,7 @@ impl<'a> Printer<'a> {
572572
}
573573
}
574574

575-
impl<'a> Write for Printer<'a> {
575+
impl Write for Printer<'_> {
576576
fn write_str(&mut self, s: &str) -> fmt::Result {
577577
for line in s.split_inclusive('\n') {
578578
if self.needs_indent {

crates/hir-expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ impl<L, R> InFile<Either<L, R>> {
850850
}
851851
}
852852

853-
impl<'a> InFile<&'a SyntaxNode> {
853+
impl InFile<&SyntaxNode> {
854854
pub fn ancestors_with_macros(
855855
self,
856856
db: &dyn db::ExpandDatabase,

crates/hir-expand/src/mod_path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct Display<'a> {
126126
path: &'a ModPath,
127127
}
128128

129-
impl<'a> fmt::Display for Display<'a> {
129+
impl fmt::Display for Display<'_> {
130130
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
131131
display_fmt_path(self.db, self.path, f, true)
132132
}
@@ -137,7 +137,7 @@ struct UnescapedDisplay<'a> {
137137
path: &'a UnescapedModPath<'a>,
138138
}
139139

140-
impl<'a> fmt::Display for UnescapedDisplay<'a> {
140+
impl fmt::Display for UnescapedDisplay<'_> {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142142
display_fmt_path(self.db, self.path.0, f, false)
143143
}

crates/hir-expand/src/name.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum Repr {
2424
TupleField(usize),
2525
}
2626

27-
impl<'a> UnescapedName<'a> {
27+
impl UnescapedName<'_> {
2828
/// Returns the textual representation of this name as a [`SmolStr`]. Prefer using this over
2929
/// [`ToString::to_string`] if possible as this conversion is cheaper in the general case.
3030
pub fn to_smol_str(&self) -> SmolStr {
@@ -40,7 +40,7 @@ impl<'a> UnescapedName<'a> {
4040
}
4141
}
4242

43-
pub fn display(&'a self, db: &dyn crate::db::ExpandDatabase) -> impl fmt::Display + 'a {
43+
pub fn display(&self, db: &dyn crate::db::ExpandDatabase) -> impl fmt::Display + '_ {
4444
_ = db;
4545
UnescapedDisplay { name: self }
4646
}
@@ -162,7 +162,7 @@ struct Display<'a> {
162162
name: &'a Name,
163163
}
164164

165-
impl<'a> fmt::Display for Display<'a> {
165+
impl fmt::Display for Display<'_> {
166166
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
167167
match &self.name.0 {
168168
Repr::Text(text) => fmt::Display::fmt(&text, f),
@@ -175,7 +175,7 @@ struct UnescapedDisplay<'a> {
175175
name: &'a UnescapedName<'a>,
176176
}
177177

178-
impl<'a> fmt::Display for UnescapedDisplay<'a> {
178+
impl fmt::Display for UnescapedDisplay<'_> {
179179
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
180180
match &self.name.0 .0 {
181181
Repr::Text(text) => {

crates/hir-ty/src/chalk_db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Inte
4646
pub(crate) type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
4747
pub(crate) type Variances = chalk_ir::Variances<Interner>;
4848

49-
impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
49+
impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
5050
fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> {
5151
self.db.associated_ty_data(id)
5252
}

crates/hir-ty/src/display.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub trait HirDisplay {
192192
}
193193
}
194194

195-
impl<'a> HirFormatter<'a> {
195+
impl HirFormatter<'_> {
196196
pub fn write_joined<T: HirDisplay>(
197197
&mut self,
198198
iter: impl IntoIterator<Item = T>,
@@ -342,7 +342,7 @@ impl<T: HirDisplay> HirDisplayWrapper<'_, T> {
342342
}
343343
}
344344

345-
impl<'a, T> fmt::Display for HirDisplayWrapper<'a, T>
345+
impl<T> fmt::Display for HirDisplayWrapper<'_, T>
346346
where
347347
T: HirDisplay,
348348
{
@@ -360,7 +360,7 @@ where
360360

361361
const TYPE_HINT_TRUNCATION: &str = "…";
362362

363-
impl<T: HirDisplay> HirDisplay for &'_ T {
363+
impl<T: HirDisplay> HirDisplay for &T {
364364
fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
365365
HirDisplay::hir_fmt(*self, f)
366366
}

crates/hir-ty/src/infer/coerce.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub(crate) fn coerce(
220220
Ok((adjustments, table.resolve_with_fallback(ty, &fallback)))
221221
}
222222

223-
impl<'a> InferenceContext<'a> {
223+
impl InferenceContext<'_> {
224224
/// Unify two types, but may coerce the first one to the second one
225225
/// using "implicit coercion rules" if needed.
226226
pub(super) fn coerce(
@@ -239,7 +239,7 @@ impl<'a> InferenceContext<'a> {
239239
}
240240
}
241241

242-
impl<'a> InferenceTable<'a> {
242+
impl InferenceTable<'_> {
243243
/// Unify two types, but may coerce the first one to the second one
244244
/// using "implicit coercion rules" if needed.
245245
pub(crate) fn coerce(

crates/hir-ty/src/infer/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use super::{
5050
InferenceContext, InferenceDiagnostic, TypeMismatch,
5151
};
5252

53-
impl<'a> InferenceContext<'a> {
53+
impl InferenceContext<'_> {
5454
pub(crate) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
5555
let ty = self.infer_expr_inner(tgt_expr, expected);
5656
if let Some(expected_ty) = expected.only_has_type(&mut self.table) {

crates/hir-ty/src/infer/mutability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{lower::lower_to_chalk_mutability, Adjust, Adjustment, AutoBorrow, Ov
1212

1313
use super::InferenceContext;
1414

15-
impl<'a> InferenceContext<'a> {
15+
impl InferenceContext<'_> {
1616
pub(crate) fn infer_mut_body(&mut self) {
1717
self.infer_mut_expr(self.body.body_expr, Mutability::Not);
1818
}

crates/hir-ty/src/infer/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl PatLike for PatId {
5656
}
5757
}
5858

59-
impl<'a> InferenceContext<'a> {
59+
impl InferenceContext<'_> {
6060
/// Infers type for tuple struct pattern or its corresponding assignee expression.
6161
///
6262
/// Ellipses found in the original pattern or expression must be filtered out.

crates/hir-ty/src/infer/unify.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
TraitEnvironment, Ty, TyBuilder, TyExt, TyKind, VariableKind,
2323
};
2424

25-
impl<'a> InferenceContext<'a> {
25+
impl InferenceContext<'_> {
2626
pub(super) fn canonicalize<T: TypeFoldable<Interner> + HasInterner<Interner = Interner>>(
2727
&mut self,
2828
t: T,
@@ -547,7 +547,7 @@ impl<'a> InferenceTable<'a> {
547547
table: &'a mut InferenceTable<'b>,
548548
highest_known_var: InferenceVar,
549549
}
550-
impl<'a, 'b> TypeFolder<Interner> for VarFudger<'a, 'b> {
550+
impl TypeFolder<Interner> for VarFudger<'_, '_> {
551551
fn as_dyn(&mut self) -> &mut dyn TypeFolder<Interner, Error = Self::Error> {
552552
self
553553
}
@@ -798,7 +798,7 @@ impl<'a> InferenceTable<'a> {
798798
}
799799
}
800800

801-
impl<'a> fmt::Debug for InferenceTable<'a> {
801+
impl fmt::Debug for InferenceTable<'_> {
802802
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
803803
f.debug_struct("InferenceTable").field("num_vars", &self.type_variable_table.len()).finish()
804804
}
@@ -826,7 +826,7 @@ mod resolve {
826826
pub(super) var_stack: &'a mut Vec<InferenceVar>,
827827
pub(super) fallback: F,
828828
}
829-
impl<'a, 'b, F> TypeFolder<Interner> for Resolver<'a, 'b, F>
829+
impl<F> TypeFolder<Interner> for Resolver<'_, '_, F>
830830
where
831831
F: Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg,
832832
{

crates/hir-ty/src/lower.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,10 @@ impl<'a> TyLoweringContext<'a> {
959959
}
960960

961961
pub(crate) fn lower_where_predicate(
962-
&'a self,
963-
where_predicate: &'a WherePredicate,
962+
&self,
963+
where_predicate: &WherePredicate,
964964
ignore_bindings: bool,
965-
) -> impl Iterator<Item = QuantifiedWhereClause> + 'a {
965+
) -> impl Iterator<Item = QuantifiedWhereClause> {
966966
match where_predicate {
967967
WherePredicate::ForLifetime { target, bound, .. }
968968
| WherePredicate::TypeBound { target, bound } => {

crates/hir-ty/src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn solve(
170170

171171
struct LoggingRustIrDatabaseLoggingOnDrop<'a>(LoggingRustIrDatabase<Interner, ChalkContext<'a>>);
172172

173-
impl<'a> Drop for LoggingRustIrDatabaseLoggingOnDrop<'a> {
173+
impl Drop for LoggingRustIrDatabaseLoggingOnDrop<'_> {
174174
fn drop(&mut self) {
175175
eprintln!("chalk program:\n{}", self.0);
176176
}

crates/hir-ty/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct SuperTraits<'a> {
8989
seen: FxHashSet<ChalkTraitId>,
9090
}
9191

92-
impl<'a> SuperTraits<'a> {
92+
impl SuperTraits<'_> {
9393
fn elaborate(&mut self, trait_ref: &TraitRef) {
9494
direct_super_trait_refs(self.db, trait_ref, |trait_ref| {
9595
if !self.seen.contains(&trait_ref.trait_id) {
@@ -99,7 +99,7 @@ impl<'a> SuperTraits<'a> {
9999
}
100100
}
101101

102-
impl<'a> Iterator for SuperTraits<'a> {
102+
impl Iterator for SuperTraits<'_> {
103103
type Item = TraitRef;
104104

105105
fn next(&mut self) -> Option<Self::Item> {

crates/hir/src/semantics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ pub struct SemanticsScope<'a> {
16311631
resolver: Resolver,
16321632
}
16331633

1634-
impl<'a> SemanticsScope<'a> {
1634+
impl SemanticsScope<'_> {
16351635
pub fn module(&self) -> Module {
16361636
Module { id: self.resolver.module() }
16371637
}

crates/ide-assists/src/handlers/pull_assignment_up.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct AssignmentsCollector<'a> {
102102
assignments: Vec<(ast::BinExpr, ast::Expr)>,
103103
}
104104

105-
impl<'a> AssignmentsCollector<'a> {
105+
impl AssignmentsCollector<'_> {
106106
fn collect_match(&mut self, match_expr: &ast::MatchExpr) -> Option<()> {
107107
for arm in match_expr.match_arm_list()?.arms() {
108108
match arm.expr()? {

crates/ide-db/src/path_transform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn postorder(item: &SyntaxNode) -> impl Iterator<Item = SyntaxNode> {
195195
})
196196
}
197197

198-
impl<'a> Ctx<'a> {
198+
impl Ctx<'_> {
199199
fn apply(&self, item: &SyntaxNode) {
200200
// `transform_path` may update a node's parent and that would break the
201201
// tree traversal. Thus all paths in the tree are collected into a vec

crates/ide-db/src/search.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,21 @@ pub struct FindUsages<'a> {
338338
search_self_mod: bool,
339339
}
340340

341-
impl<'a> FindUsages<'a> {
341+
impl FindUsages<'_> {
342342
/// Enable searching for `Self` when the definition is a type or `self` for modules.
343-
pub fn include_self_refs(mut self) -> FindUsages<'a> {
343+
pub fn include_self_refs(mut self) -> Self {
344344
self.include_self_kw_refs = def_to_ty(self.sema, &self.def);
345345
self.search_self_mod = true;
346346
self
347347
}
348348

349349
/// Limit the search to a given [`SearchScope`].
350-
pub fn in_scope(self, scope: SearchScope) -> FindUsages<'a> {
350+
pub fn in_scope(self, scope: SearchScope) -> Self {
351351
self.set_scope(Some(scope))
352352
}
353353

354354
/// Limit the search to a given [`SearchScope`].
355-
pub fn set_scope(mut self, scope: Option<SearchScope>) -> FindUsages<'a> {
355+
pub fn set_scope(mut self, scope: Option<SearchScope>) -> Self {
356356
assert!(self.scope.is_none());
357357
self.scope = scope;
358358
self

crates/ide-diagnostics/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct DiagnosticsContext<'a> {
194194
resolve: &'a AssistResolveStrategy,
195195
}
196196

197-
impl<'a> DiagnosticsContext<'a> {
197+
impl DiagnosticsContext<'_> {
198198
fn resolve_precise_location(
199199
&self,
200200
node: &InFile<SyntaxNodePtr>,

crates/ide-ssr/src/search.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub(crate) struct UsageCache {
2222
usages: Vec<(Definition, UsageSearchResult)>,
2323
}
2424

25-
impl<'db> MatchFinder<'db> {
25+
impl MatchFinder<'_> {
2626
/// Adds all matches for `rule` to `matches_out`. Matches may overlap in ways that make
2727
/// replacement impossible, so further processing is required in order to properly nest matches
2828
/// and remove overlapping matches. This is done in the `nesting` module.

crates/mbe/src/expander/matcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ impl<'a> Iterator for OpDelimitedIter<'a> {
884884
}
885885
}
886886

887-
impl<'a> TtIter<'a> {
887+
impl TtIter<'_> {
888888
fn expect_separator(&mut self, separator: &Separator) -> bool {
889889
let mut fork = self.clone();
890890
let ok = match separator {

crates/mbe/src/syntax_bridge.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,25 +509,25 @@ trait TokenConverter: Sized {
509509
fn id_alloc(&mut self) -> &mut TokenIdAlloc;
510510
}
511511

512-
impl<'a> SrcToken<RawConverter<'a>> for usize {
513-
fn kind(&self, ctx: &RawConverter<'a>) -> SyntaxKind {
512+
impl SrcToken<RawConverter<'_>> for usize {
513+
fn kind(&self, ctx: &RawConverter<'_>) -> SyntaxKind {
514514
ctx.lexed.kind(*self)
515515
}
516516

517-
fn to_char(&self, ctx: &RawConverter<'a>) -> Option<char> {
517+
fn to_char(&self, ctx: &RawConverter<'_>) -> Option<char> {
518518
ctx.lexed.text(*self).chars().next()
519519
}
520520

521521
fn to_text(&self, ctx: &RawConverter<'_>) -> SmolStr {
522522
ctx.lexed.text(*self).into()
523523
}
524524

525-
fn synthetic_id(&self, _ctx: &RawConverter<'a>) -> Option<SyntheticTokenId> {
525+
fn synthetic_id(&self, _ctx: &RawConverter<'_>) -> Option<SyntheticTokenId> {
526526
None
527527
}
528528
}
529529

530-
impl<'a> TokenConverter for RawConverter<'a> {
530+
impl TokenConverter for RawConverter<'_> {
531531
type Token = usize;
532532

533533
fn convert_doc_comment(&self, &token: &usize, span: tt::TokenId) -> Option<Vec<tt::TokenTree>> {
@@ -800,7 +800,7 @@ fn delim_to_str(d: tt::DelimiterKind, closing: bool) -> Option<&'static str> {
800800
Some(&texts[idx..texts.len() - (1 - idx)])
801801
}
802802

803-
impl<'a> TtTreeSink<'a> {
803+
impl TtTreeSink<'_> {
804804
/// Parses a float literal as if it was a one to two name ref nodes with a dot inbetween.
805805
/// This occurs when a float literal is used as a field access.
806806
fn float_split(&mut self, has_pseudo_dot: bool) {

crates/mbe/src/tt_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ impl<'a> Iterator for TtIter<'a> {
197197
}
198198
}
199199

200-
impl<'a> std::iter::ExactSizeIterator for TtIter<'a> {}
200+
impl std::iter::ExactSizeIterator for TtIter<'_> {}

crates/parser/src/shortcuts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum StrStep<'a> {
2424
Error { msg: &'a str, pos: usize },
2525
}
2626

27-
impl<'a> LexedStr<'a> {
27+
impl LexedStr<'_> {
2828
pub fn to_input(&self) -> crate::Input {
2929
let mut res = crate::Input::default();
3030
let mut was_joint = false;

0 commit comments

Comments
 (0)