mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
parent
a3fcaee562
commit
88750f9ad7
2 changed files with 23 additions and 2 deletions
|
@ -9,7 +9,7 @@ use syntax::source_map::Span;
|
|||
use syntax::symbol::kw;
|
||||
|
||||
use crate::reexport::*;
|
||||
use crate::utils::{last_path_segment, span_lint};
|
||||
use crate::utils::{last_path_segment, span_lint, trait_ref_of_method};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for lifetime annotations which can be removed by
|
||||
|
@ -66,7 +66,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes {
|
|||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||
if let ImplItemKind::Method(ref sig, id) = item.node {
|
||||
check_fn_inner(cx, &sig.decl, Some(id), &item.generics, item.span);
|
||||
if trait_ref_of_method(cx, item.hir_id).is_none() {
|
||||
check_fn_inner(cx, &sig.decl, Some(id), &item.generics, item.span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,4 +61,23 @@ impl X {
|
|||
fn explicit_self_with_lifetime<'a>(self: &'a Self) {}
|
||||
}
|
||||
|
||||
// Methods implementing traits must have matching lifetimes
|
||||
mod issue4291 {
|
||||
#[derive(Debug)]
|
||||
pub struct Foo<'a>(&'a std::marker::PhantomData<u8>);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Bar<'a: 'b, 'b>(Foo<'a>, &'b std::marker::PhantomData<u8>);
|
||||
|
||||
trait LT {
|
||||
fn test<'a: 'b, 'b>(foo: &Foo<'a>, bar: &Bar<'a, 'b>);
|
||||
}
|
||||
|
||||
pub struct Baz;
|
||||
|
||||
impl LT for Baz {
|
||||
fn test<'a: 'b, 'b>(_foo: &Foo, _bar: &Bar) {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Reference in a new issue