summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs
blob: 874788e13ef091e21a5489a4afc1b18d1539637f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Make sure we suggest the bound `T: 'a` in the correct scope:
// trait, impl or associated fn.
// run-rustfix

struct Inv<'a>(Option<*mut &'a u8>);

fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {}

trait Trait1<'a>: Sized {
    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>) {
        check_bound(self, lt)
        //~^ ERROR parameter type `Self` may not live long enough
    }
}

trait Trait3<T> {
    fn foo<'a>(arg: T, lt: Inv<'a>) {
        check_bound(arg, lt)
        //~^ ERROR parameter type `T` may not live long enough
    }
}

trait Trait4<'a> {
    fn foo<T>(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> 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() {}