2018-12-09 23:26:16 +01:00
|
|
|
#![allow(
|
|
|
|
unused,
|
|
|
|
dead_code,
|
|
|
|
clippy::needless_lifetimes,
|
|
|
|
clippy::needless_pass_by_value,
|
|
|
|
clippy::trivially_copy_pass_by_ref
|
|
|
|
)]
|
2018-07-28 17:34:52 +02:00
|
|
|
#![warn(clippy::extra_unused_lifetimes)]
|
2015-12-06 22:36:22 +01:00
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
fn empty() {}
|
2015-12-06 22:36:22 +01:00
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
fn used_lt<'a>(x: &'a u8) {}
|
2015-12-06 22:36:22 +01:00
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
fn unused_lt<'a>(x: u8) {}
|
2015-12-06 22:36:22 +01:00
|
|
|
|
2017-02-08 14:58:07 +01:00
|
|
|
fn unused_lt_transitive<'a, 'b: 'a>(x: &'b u8) {
|
2015-12-06 22:36:22 +01:00
|
|
|
// 'a is useless here since it's not directly bound
|
|
|
|
}
|
|
|
|
|
|
|
|
fn lt_return<'a, 'b: 'a>(x: &'b u8) -> &'a u8 {
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn lt_return_only<'a>() -> &'a u8 {
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
|
2019-05-30 08:23:47 +02:00
|
|
|
fn unused_lt_blergh<'a>(x: Option<Box<dyn Send + 'a>>) {}
|
2015-12-06 22:36:22 +01:00
|
|
|
|
|
|
|
trait Foo<'a> {
|
|
|
|
fn x(&self, a: &'a u8);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Foo<'a> for u8 {
|
2018-12-09 23:26:16 +01:00
|
|
|
fn x(&self, a: &'a u8) {}
|
2015-12-06 22:36:22 +01:00
|
|
|
}
|
2015-12-10 17:44:12 +01:00
|
|
|
|
2016-05-17 23:25:20 +02:00
|
|
|
struct Bar;
|
|
|
|
|
|
|
|
impl Bar {
|
2017-02-08 14:58:07 +01:00
|
|
|
fn x<'a>(&self) {}
|
2016-05-17 23:25:20 +02:00
|
|
|
}
|
|
|
|
|
2015-12-10 17:44:12 +01:00
|
|
|
// test for #489 (used lifetimes in bounds)
|
2018-12-09 23:26:16 +01:00
|
|
|
pub fn parse<'a, I: Iterator<Item = &'a str>>(_it: &mut I) {
|
2015-12-10 17:44:12 +01:00
|
|
|
unimplemented!()
|
|
|
|
}
|
2018-12-09 23:26:16 +01:00
|
|
|
pub fn parse2<'a, I>(_it: &mut I)
|
|
|
|
where
|
|
|
|
I: Iterator<Item = &'a str>,
|
|
|
|
{
|
2015-12-10 17:44:12 +01:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
struct X {
|
|
|
|
x: u32,
|
|
|
|
}
|
2016-01-14 19:27:24 +01:00
|
|
|
|
|
|
|
impl X {
|
|
|
|
fn self_ref_with_lifetime<'a>(&'a self) {}
|
|
|
|
fn explicit_self_with_lifetime<'a>(self: &'a Self) {}
|
|
|
|
}
|
|
|
|
|
2019-08-31 08:16:04 +02:00
|
|
|
// Methods implementing traits must have matching lifetimes
|
|
|
|
mod issue4291 {
|
2019-09-01 07:55:29 +02:00
|
|
|
trait BadTrait {
|
|
|
|
fn unused_lt<'a>(x: u8) {}
|
2019-08-31 08:16:04 +02:00
|
|
|
}
|
|
|
|
|
2019-09-01 07:55:29 +02:00
|
|
|
impl BadTrait for () {
|
|
|
|
fn unused_lt<'a>(_x: u8) {}
|
2019-08-31 08:16:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-09 23:26:16 +01:00
|
|
|
fn main() {}
|