From 430b99bdacb6260c41d37b958ad8eeb28218a2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Wed, 11 Dec 2024 00:58:35 +0100 Subject: [PATCH] Fix clippy warnings in rust nightly 1.85 --- .github/workflows/rust.yml | 4 ++-- rinja/src/filters/escape.rs | 4 ++-- rinja_derive/src/config.rs | 2 +- rinja_parser/src/lib.rs | 14 +++++++------- rinja_parser/src/node.rs | 10 ++++------ testing/tests/methods.rs | 4 ++-- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ff7bf6e0..6634b391 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -29,7 +29,7 @@ jobs: tool: cargo-nextest - uses: Swatinem/rust-cache@v2 - run: cargo build --all-targets --features full - - run: cargo nextest run --all-targets --features full + - run: cargo nextest run --all-targets --no-tests=warn --features full Package: strategy: @@ -48,7 +48,7 @@ jobs: with: tool: cargo-nextest - uses: Swatinem/rust-cache@v2 - - run: cd ${{ matrix.package }} && cargo nextest run + - run: cd ${{ matrix.package }} && cargo nextest run --no-tests=warn - run: cd ${{ matrix.package }} && cargo clippy --all-targets -- -D warnings Docs: diff --git a/rinja/src/filters/escape.rs b/rinja/src/filters/escape.rs index 2e687a3a..4f4aae7d 100644 --- a/rinja/src/filters/escape.rs +++ b/rinja/src/filters/escape.rs @@ -601,14 +601,14 @@ const _: () = { } } - impl<'a, S: FastWritable + ?Sized> WriteWritable for &Writable<'a, S> { + impl WriteWritable for &Writable<'_, S> { #[inline] fn rinja_write(&self, dest: &mut W) -> crate::Result<()> { self.0.write_into(dest) } } - impl<'a, S: fmt::Display + ?Sized> WriteWritable for &&Writable<'a, S> { + impl WriteWritable for &&Writable<'_, S> { #[inline] fn rinja_write(&self, dest: &mut W) -> crate::Result<()> { Ok(write!(dest, "{}", self.0)?) diff --git a/rinja_derive/src/config.rs b/rinja_derive/src/config.rs index 9dc63ba3..ccd90dc4 100644 --- a/rinja_derive/src/config.rs +++ b/rinja_derive/src/config.rs @@ -42,7 +42,7 @@ struct ConfigKey<'a> { template_whitespace: Option, } -impl<'a> ToOwned for ConfigKey<'a> { +impl ToOwned for ConfigKey<'_> { type Owned = OwnedConfigKey; fn to_owned(&self) -> Self::Owned { diff --git a/rinja_parser/src/lib.rs b/rinja_parser/src/lib.rs index 84e6349c..b08adbe2 100644 --- a/rinja_parser/src/lib.rs +++ b/rinja_parser/src/lib.rs @@ -209,7 +209,7 @@ impl<'a, T> WithSpan<'a, T> { } } -impl<'a, T> Deref for WithSpan<'a, T> { +impl Deref for WithSpan<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -217,19 +217,19 @@ impl<'a, T> Deref for WithSpan<'a, T> { } } -impl<'a, T> DerefMut for WithSpan<'a, T> { +impl DerefMut for WithSpan<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } } -impl<'a, T: fmt::Debug> fmt::Debug for WithSpan<'a, T> { +impl fmt::Debug for WithSpan<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.inner) } } -impl<'a, T: Clone> Clone for WithSpan<'a, T> { +impl Clone for WithSpan<'_, T> { fn clone(&self) -> Self { Self { inner: self.inner.clone(), @@ -238,7 +238,7 @@ impl<'a, T: Clone> Clone for WithSpan<'a, T> { } } -impl<'a, T: PartialEq> PartialEq for WithSpan<'a, T> { +impl PartialEq for WithSpan<'_, T> { fn eq(&self, other: &Self) -> bool { // We never want to compare the span information. self.inner == other.inner @@ -822,14 +822,14 @@ impl Default for InnerSyntax<'static> { } } -impl<'a> fmt::Debug for Syntax<'a> { +impl fmt::Debug for Syntax<'_> { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_syntax("Syntax", self, f) } } -impl<'a> fmt::Debug for InnerSyntax<'a> { +impl fmt::Debug for InnerSyntax<'_> { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_syntax("InnerSyntax", self, f) diff --git a/rinja_parser/src/node.rs b/rinja_parser/src/node.rs index 2a23686f..307a4e59 100644 --- a/rinja_parser/src/node.rs +++ b/rinja_parser/src/node.rs @@ -648,12 +648,10 @@ impl<'a> Macro<'a> { .parse_next(i)?; match args { Some((args, Some(_))) => Ok((i, args)), - Some((_, None)) => { - return Err(winnow::error::ErrMode::Cut(ErrorContext::new( - "expected `)` to close macro argument list", - i, - ))); - } + Some((_, None)) => Err(winnow::error::ErrMode::Cut(ErrorContext::new( + "expected `)` to close macro argument list", + i, + ))), None => Ok((i, None)), } }; diff --git a/testing/tests/methods.rs b/testing/tests/methods.rs index 119d91c8..d86dbc8b 100644 --- a/testing/tests/methods.rs +++ b/testing/tests/methods.rs @@ -7,7 +7,7 @@ struct SelfMethodTemplate<'a> { } impl<'a> SelfMethodTemplate<'a> { - fn get_s(&self) -> &str { + fn get_s(&self) -> &'a str { self.s } } @@ -43,7 +43,7 @@ fn test_nested() { } impl<'a> NestedSelfMethodTemplate<'a> { - fn get_s(&self) -> &str { + fn get_s(&self) -> &'a str { "bar" } }