Skip to content

Commit e6fa163

Browse files
committed
Fix false positives
1 parent b35c04f commit e6fa163

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
565565
.collect();
566566
let mut checker = LifetimeChecker::<mir_nested_filter::All>::new(cx, hs);
567567

568+
walk_generics(&mut checker, &impl_.generics);
568569
if let Some(ref trait_ref) = impl_.of_trait {
569570
walk_trait_ref(&mut checker, trait_ref);
570571
}

tests/ui/extra_unused_lifetimes.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,30 @@ mod issue6437 {
8888
}
8989
}
9090

91+
// https://github.com/rust-lang/rust-clippy/pull/8737#pullrequestreview-951268213
92+
mod first_case {
93+
use serde::de::Visitor;
94+
pub trait Expected {
95+
fn fmt(&self, formatter: &mut std::fmt::Formatter);
96+
}
97+
98+
impl<'de, T> Expected for T
99+
where
100+
T: Visitor<'de>,
101+
{
102+
fn fmt(&self, formatter: &mut std::fmt::Formatter) {}
103+
}
104+
}
105+
106+
// https://github.com/rust-lang/rust-clippy/pull/8737#pullrequestreview-951268213
107+
mod second_case {
108+
pub trait Source {
109+
fn hey();
110+
}
111+
112+
impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
113+
fn hey() {}
114+
}
115+
}
116+
91117
fn main() {}

0 commit comments

Comments
 (0)