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
}

0 commit comments

Comments
 (0)