about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAda Alakbarova <ada.alakbarova@proton.me>2025-09-04 20:49:26 +0200
committerAda Alakbarova <ada.alakbarova@proton.me>2025-09-06 12:43:56 +0200
commite7c91ab13ad36e3dfefc4f4f92f4c6e5e445c8f6 (patch)
treec485459a644684d8fa5d7f3af8ff3acfe34a8cb5
parent6812aa3403cc6b8c5a229fc36f0022b06c276e3c (diff)
downloadrust-e7c91ab13ad36e3dfefc4f4f92f4c6e5e445c8f6.tar.gz
rust-e7c91ab13ad36e3dfefc4f4f92f4c6e5e445c8f6.zip
remove `has_lifetime`
It's now redundant to `same_lifetimes`: if `ty` and `impl_ty` are the
same type, and they both have no lifetimes, `same_lifetimes` will return
`true` already
-rw-r--r--clippy_lints/src/use_self.rs16
1 files changed, 1 insertions, 15 deletions
diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs
index e84641d4d1b..8210320591c 100644
--- a/clippy_lints/src/use_self.rs
+++ b/clippy_lints/src/use_self.rs
@@ -209,7 +209,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
             // Ensure the type we encounter and the one from the impl have the same lifetime parameters. It may be that
             // the lifetime parameters of `ty` are elided (`impl<'a> Foo<'a> { fn new() -> Self { Foo{..} } }`), in
             // which case we must still trigger the lint.
-            && (!has_lifetime(ty) || same_lifetimes(ty, impl_ty))
+            && same_lifetimes(ty, impl_ty)
             && self.msrv.meets(cx, msrvs::TYPE_ALIAS_ENUM_VARIANTS)
         {
             span_lint(cx, hir_ty.span);
@@ -318,17 +318,3 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool {
         _ => a == b,
     }
 }
-
-/// Checks whether `ty` has lifetime parameters.
-fn has_lifetime(ty: MiddleTy<'_>) -> bool {
-    use rustc_middle::ty::{Adt, GenericArgKind};
-    match ty.kind() {
-        Adt(_, args) => args.iter().any(|arg| match arg.kind() {
-            // TODO: Handle inferred lifetimes
-            GenericArgKind::Lifetime(..) => true,
-            GenericArgKind::Type(ty) => has_lifetime(ty),
-            _ => false,
-        }),
-        _ => false,
-    }
-}