From 790c752285a88dacd5e969dde704b2a9ff8823d0 Mon Sep 17 00:00:00 2001 From: Casper Meijn Date: Mon, 3 Feb 2025 14:49:33 +0100 Subject: [PATCH] style: Remove needless lifetimes This solves clippy warnings like this: ``` error: the following explicit lifetimes could be elided: 'a --> src/common.rs:30:6 | 30 | impl<'a> Text<'a> for String { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `-D clippy::needless-lifetimes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_lifetimes)]` help: elide the lifetimes | 30 - impl<'a> Text<'a> for String { 30 + impl Text<'_> for String { ``` --- src/common.rs | 2 +- src/format.rs | 2 +- src/query/ast.rs | 2 +- src/schema/ast.rs | 2 +- src/tokenizer.rs | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common.rs b/src/common.rs index cafdd76..7fe0c40 100644 --- a/src/common.rs +++ b/src/common.rs @@ -27,7 +27,7 @@ impl<'a> Text<'a> for &'a str { type Value = Self; } -impl<'a> Text<'a> for String { +impl Text<'_> for String { type Value = String; } diff --git a/src/format.rs b/src/format.rs index de24163..89a3f70 100644 --- a/src/format.rs +++ b/src/format.rs @@ -47,7 +47,7 @@ pub(crate) trait Displayable { fn display(&self, f: &mut Formatter); } -impl<'a> Formatter<'a> { +impl Formatter<'_> { pub fn new(style: &Style) -> Formatter { Formatter { buf: String::with_capacity(1024), diff --git a/src/query/ast.rs b/src/query/ast.rs index 1be1c7f..973b5cf 100644 --- a/src/query/ast.rs +++ b/src/query/ast.rs @@ -14,7 +14,7 @@ pub struct Document<'a, T: Text<'a>> { pub definitions: Vec>, } -impl<'a> Document<'a, String> { +impl Document<'_, String> { pub fn into_static(self) -> Document<'static, String> { // To support both reference and owned values in the AST, // all string data is represented with the ::common::Str<'a, T: Text<'a>> diff --git a/src/schema/ast.rs b/src/schema/ast.rs index db2908f..b7e919f 100644 --- a/src/schema/ast.rs +++ b/src/schema/ast.rs @@ -10,7 +10,7 @@ pub struct Document<'a, T: Text<'a>> { pub definitions: Vec>, } -impl<'a> Document<'a, String> { +impl Document<'_, String> { pub fn into_static(self) -> Document<'static, String> { // To support both reference and owned values in the AST, // all string data is represented with the ::common::Str<'a, T: Text<'a>> diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 3721eb4..9e06319 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -68,13 +68,13 @@ impl<'a> StreamOnce for TokenStream<'a> { } } -impl<'a> Positioned for TokenStream<'a> { +impl Positioned for TokenStream<'_> { fn position(&self) -> Self::Position { self.position } } -impl<'a> ResetStream for TokenStream<'a> { +impl ResetStream for TokenStream<'_> { type Checkpoint = Checkpoint; fn checkpoint(&self) -> Self::Checkpoint { Checkpoint { @@ -357,7 +357,7 @@ impl<'a> TokenStream<'a> { } } -impl<'a> fmt::Display for Token<'a> { +impl fmt::Display for Token<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}[{:?}]", self.value, self.kind) }