#![warn(clippy::needless_lifetimes)]
-#![allow(dead_code, clippy::needless_pass_by_value, clippy::trivially_copy_pass_by_ref)]
+#![allow(dead_code, clippy::needless_pass_by_value)]
fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
trait WithLifetime<'a> {}
-type WithLifetimeAlias<'a> = WithLifetime<'a>;
+type WithLifetimeAlias<'a> = dyn WithLifetime<'a>;
// Should not warn because it won't build without the lifetime.
-fn trait_obj_elided<'a>(_arg: &'a WithLifetime) -> &'a str {
+fn trait_obj_elided<'a>(_arg: &'a dyn WithLifetime) -> &'a str {
unimplemented!()
}
// Should warn because there is no lifetime on `Drop`, so this would be
// unambiguous if we elided the lifetime.
-fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str {
+fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
unimplemented!()
}
}
impl Test {
- fn iter<'a>(&'a self) -> Box<Iterator<Item = usize> + 'a> {
+ fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = usize> + 'a> {
unimplemented!()
}
}
unimplemented!()
}
+// Make sure we still warn on implementations
+mod issue4291 {
+ trait BadTrait {
+ fn needless_lt<'a>(x: &'a u8) {}
+ }
+
+ impl BadTrait for () {
+ fn needless_lt<'a>(_x: &'a u8) {}
+ }
+}
+
fn main() {}