summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/lifetimes/issue-105544.rs
blob: bd3bc1ef9bd2d55b8bee0fed2a3ce7560b438597 (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
// run-rustfix

#![allow(warnings)]

fn foo(d: impl Sized, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
    (d, p)
    //~^ ERROR the parameter type `impl Sized` may not live long enough
    //~| NOTE ...so that the type `impl Sized` will meet its required lifetime bounds
}

fn foo1<'b>(d: impl Sized, p: &'b mut ()) -> impl Sized + '_ {
//~^ HELP consider adding an explicit lifetime bound...
    (d, p) //~ NOTE ...so that the type `impl Sized` will meet its required lifetime bounds
    //~^ ERROR the parameter type `impl Sized` may not live long enough
}

fn foo2<'a>(d: impl Sized + 'a, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `impl Sized + 'a` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
    (d, p)
    //~^ ERROR the parameter type `impl Sized + 'a` may not live long enough
    //~| NOTE ...so that the type `impl Sized + 'a` will meet its required lifetime bounds
}

fn bar<T : Sized>(d: T, p: & mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
    (d, p)
    //~^ ERROR the parameter type `T` may not live long enough
    //~| NOTE ...so that the type `T` will meet its required lifetime bounds
}

fn bar1<'b, T : Sized>(d: T, p: &'b mut ()) -> impl Sized + '_ {
//~^ HELP consider adding an explicit lifetime bound...
    (d, p) //~ NOTE ...so that the type `T` will meet its required lifetime bounds
    //~^ ERROR the parameter type `T` may not live long enough
}

fn bar2<'a, T : Sized + 'a>(d: T, p: &mut ()) -> impl Sized + '_ { //~ NOTE the parameter type `T` must be valid for the anonymous lifetime defined here...
//~^ HELP consider adding an explicit lifetime bound
    (d, p)
    //~^ ERROR the parameter type `T` may not live long enough
    //~| NOTE ...so that the type `T` will meet its required lifetime bounds
}

fn main() {}