Skip to content

Commit e7c91ab

Browse files
committed
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
1 parent 6812aa3 commit e7c91ab

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

clippy_lints/src/use_self.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
209209
// Ensure the type we encounter and the one from the impl have the same lifetime parameters. It may be that
210210
// the lifetime parameters of `ty` are elided (`impl<'a> Foo<'a> { fn new() -> Self { Foo{..} } }`), in
211211
// which case we must still trigger the lint.
212-
&& (!has_lifetime(ty) || same_lifetimes(ty, impl_ty))
212+
&& same_lifetimes(ty, impl_ty)
213213
&& self.msrv.meets(cx, msrvs::TYPE_ALIAS_ENUM_VARIANTS)
214214
{
215215
span_lint(cx, hir_ty.span);
@@ -318,17 +318,3 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool {
318318
_ => a == b,
319319
}
320320
}
321-
322-
/// Checks whether `ty` has lifetime parameters.
323-
fn has_lifetime(ty: MiddleTy<'_>) -> bool {
324-
use rustc_middle::ty::{Adt, GenericArgKind};
325-
match ty.kind() {
326-
Adt(_, args) => args.iter().any(|arg| match arg.kind() {
327-
// TODO: Handle inferred lifetimes
328-
GenericArgKind::Lifetime(..) => true,
329-
GenericArgKind::Type(ty) => has_lifetime(ty),
330-
_ => false,
331-
}),
332-
_ => false,
333-
}
334-
}

0 commit comments

Comments
 (0)