]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/ty-outlives/wf-unreachable.rs
Do not rename bound variables when verbose-printing binders.
[rust.git] / src / test / ui / nll / ty-outlives / wf-unreachable.rs
1 // Test that we check that user type annotations are well-formed, even in dead
2 // code.
3
4 fn uninit<'a>() {
5     return;
6     let x: &'static &'a ();                         //~ ERROR lifetime may not live long enough
7 }
8
9 fn var_type<'a>() {
10     return;
11     let x: &'static &'a () = &&();                  //~ ERROR lifetime may not live long enough
12 }
13
14 fn uninit_infer<'a>() {
15     let x: &'static &'a _;                          //~ ERROR lifetime may not live long enough
16     x = && ();
17 }
18
19 fn infer<'a>() {
20     return;
21     let x: &'static &'a _ = &&();                   //~ ERROR lifetime may not live long enough
22 }
23
24 fn uninit_no_var<'a>() {
25     return;
26     let _: &'static &'a ();                         //~ ERROR lifetime may not live long enough
27 }
28
29 fn no_var<'a>() {
30     return;
31     let _: &'static &'a () = &&();                  //~ ERROR lifetime may not live long enough
32 }
33
34 fn infer_no_var<'a>() {
35     return;
36     let _: &'static &'a _ = &&();                   //~ ERROR lifetime may not live long enough
37 }
38
39 trait X<'a, 'b> {}
40
41 struct C<'a, 'b, T: X<'a, 'b>>(T, &'a (), &'b ());
42
43 impl X<'_, '_> for i32 {}
44 impl<'a> X<'a, 'a> for () {}
45
46 // This type annotation is not well-formed because we substitute `()` for `_`.
47 fn required_substs<'a>() {
48     return;
49     let _: C<'static, 'a, _> = C((), &(), &());     //~ ERROR lifetime may not live long enough
50 }
51
52 fn main() {}