summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/ty-outlives/wf-unreachable.rs
blob: c6f4c4afa3d3082a37ae9ea489538016e71a56d3 (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
48
49
50
51
52
// Test that we check that user type annotations are well-formed, even in dead
// code.

fn uninit<'a>() {
    return;
    let x: &'static &'a ();                         //~ ERROR lifetime may not live long enough
}

fn var_type<'a>() {
    return;
    let x: &'static &'a () = &&();                  //~ ERROR lifetime may not live long enough
}

fn uninit_infer<'a>() {
    let x: &'static &'a _;                          //~ ERROR lifetime may not live long enough
    x = && ();
}

fn infer<'a>() {
    return;
    let x: &'static &'a _ = &&();                   //~ ERROR lifetime may not live long enough
}

fn uninit_no_var<'a>() {
    return;
    let _: &'static &'a ();                         //~ ERROR lifetime may not live long enough
}

fn no_var<'a>() {
    return;
    let _: &'static &'a () = &&();                  //~ ERROR lifetime may not live long enough
}

fn infer_no_var<'a>() {
    return;
    let _: &'static &'a _ = &&();                   //~ ERROR lifetime may not live long enough
}

trait X<'a, 'b> {}

struct C<'a, 'b, T: X<'a, 'b>>(T, &'a (), &'b ());

impl X<'_, '_> for i32 {}
impl<'a> X<'a, 'a> for () {}

// This type annotation is not well-formed because we substitute `()` for `_`.
fn required_substs<'a>() {
    return;
    let _: C<'static, 'a, _> = C((), &(), &());     //~ ERROR lifetime may not live long enough
}

fn main() {}