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
|
// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" }
// { dg-enable-nn-line-numbers "" }
fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 {
// { dg-error "subset error, some lifetime constraints need to be added" "" { target *-*-* } .-1 }
y //~ ERROR
/*
{ dg-begin-multiline-output "" }
NN | fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 {
| ^~ ~~ ~~
| | | |
| | | lifetime defined here
| | lifetime defined here
| subset error occurs in this function
{ dg-end-multiline-output "" }
*/
}
fn missing_subset_fixed<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a {
y
}
fn complex_cfg_subset<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 {
// { dg-error "subset error, some lifetime constraints need to be added" "" { target *-*-* } .-1 }
if b {
y //~ ERROR
} else {
x
}
/*
{ dg-begin-multiline-output "" }
NN | fn complex_cfg_subset<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 {
| ^~ ~~ ~~
| | | |
| | | lifetime defined here
| | lifetime defined here
| subset error occurs in this function
{ dg-end-multiline-output "" }
*/
}
fn complex_cfg_subset_fixed<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a {
if b {
x
} else {
y
}
}
|