summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/ty-outlives/ty-param-fn.rs
blob: 4393a3b41697f3b3768fb419cc4c6d39a1ab33ba (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
#![allow(warnings)]

use std::fmt::Debug;

fn no_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
where
    T: Debug,
{
    x
    //~^ ERROR the parameter type `T` may not live long enough
}

fn correct_region<'a, T>(x: Box<T>) -> Box<Debug + 'a>
where
    T: 'a + Debug,
{
    x
}

fn wrong_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>
where
    T: 'b + Debug,
{
    x
    //~^ ERROR the parameter type `T` may not live long enough
}

fn outlives_region<'a, 'b, T>(x: Box<T>) -> Box<Debug + 'a>
where
    T: 'b + Debug,
    'b: 'a,
{
    x
}

fn main() {}