blob: 2c1e3ad005cf2365023d5f9b1c2ea95669cfac67 [file] [log] [blame]
// Make sure we suggest the bound `T: 'a` in the correct scope:
// trait, impl or associated fn.
//@ run-rustfix
#![allow(dead_code)]
struct Inv<'a>(#[allow(dead_code)] Option<*mut &'a u8>);
fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {}
trait Trait1<'a>: Sized where Self: 'a {
fn foo(self, lt: Inv<'a>) {
check_bound(self, lt)
//~^ ERROR parameter type `Self` may not live long enough
}
}
trait Trait2: Sized {
fn foo<'a>(self, lt: Inv<'a>) where Self: 'a {
check_bound(self, lt)
//~^ ERROR parameter type `Self` may not live long enough
}
}
trait Trait3<T> {
fn foo<'a>(arg: T, lt: Inv<'a>) where T: 'a {
check_bound(arg, lt)
//~^ ERROR parameter type `T` may not live long enough
}
}
trait Trait4<'a> {
fn foo<T: 'a>(arg: T, lt: Inv<'a>) {
check_bound(arg, lt)
//~^ ERROR parameter type `T` may not live long enough
}
}
trait Trait5<'a> {
fn foo(self, _: Inv<'a>);
}
impl<'a, T: 'a> Trait5<'a> for T {
fn foo(self, lt: Inv<'a>) {
check_bound(self, lt);
//~^ ERROR parameter type `T` may not live long enough
}
}
fn main() {}