]> git.lizzy.rs Git - rust.git/blob - tests/ui/issues/issue-40288-2.rs
Rollup merge of #107091 - clubby789:infer-ftl-missing-dollar, r=compiler-errors
[rust.git] / tests / ui / issues / issue-40288-2.rs
1 fn prove_static<T: 'static + ?Sized>(_: &'static T) {}
2
3 fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
4     let mut out = [x];
5     {
6         let slice: &mut [_] = &mut out;
7         slice[0] = y;
8     }
9     out[0]
10     //~^ ERROR explicit lifetime required in the type of `y` [E0621]
11 }
12
13 struct Struct<T, U: ?Sized> {
14     head: T,
15     _tail: U
16 }
17
18 fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
19     let mut out = Struct { head: x, _tail: [()] };
20     {
21         let dst: &mut Struct<_, [()]> = &mut out;
22         dst.head = y;
23     }
24     out.head
25     //~^ ERROR explicit lifetime required in the type of `y` [E0621]
26 }
27
28 fn main() {
29     prove_static(lifetime_transmute_slice("", &String::from("foo")));
30     prove_static(lifetime_transmute_struct("", &String::from("bar")));
31 }