]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/outlives-suggestion-more.rs
Auto merge of #105121 - oli-obk:simpler-cheaper-dump_mir, r=nnethercote
[rust.git] / src / test / ui / nll / outlives-suggestion-more.rs
1 // Test the more elaborate outlives suggestions.
2
3 // Should suggest: 'a: 'c, 'b: 'd
4 fn foo1<'a, 'b, 'c, 'd>(x: &'a usize, y: &'b usize) -> (&'c usize, &'d usize) {
5     (x, y) //~ERROR lifetime may not live long enough
6            //~^ERROR lifetime may not live long enough
7 }
8
9 // Should suggest: 'a: 'c and use 'static instead of 'b
10 fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) {
11     (x, y) //~ERROR lifetime may not live long enough
12            //~^ERROR lifetime may not live long enough
13 }
14
15 // Should suggest: 'a and 'b are the same and use 'static instead of 'c
16 fn foo3<'a, 'b, 'c, 'd, 'e>(
17     x: &'a usize,
18     y: &'b usize,
19     z: &'c usize,
20 ) -> (&'b usize, &'a usize, &'static usize) {
21     (x, y, z) //~ERROR lifetime may not live long enough
22               //~^ERROR lifetime may not live long enough
23               //~^^ERROR lifetime may not live long enough
24 }
25
26 fn main() {}