| 1 |
// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck -fdiagnostics-show-caret -fdiagnostics-show-line-numbers" } |
| 2 |
// { dg-enable-nn-line-numbers "" } |
| 3 |
|
| 4 |
fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { |
| 5 |
// { dg-error "subset error, some lifetime constraints need to be added" "" { target *-*-* } .-1 } |
| 6 |
y //~ ERROR |
| 7 |
/* |
| 8 |
{ dg-begin-multiline-output "" } |
| 9 |
NN | fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { |
| 10 |
| ^~ ~~ ~~ |
| 11 |
| | | | |
| 12 |
| | | lifetime defined here |
| 13 |
| | lifetime defined here |
| 14 |
| subset error occurs in this function |
| 15 |
{ dg-end-multiline-output "" } |
| 16 |
*/ |
| 17 |
} |
| 18 |
|
| 19 |
fn missing_subset_fixed<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a { |
| 20 |
y |
| 21 |
} |
| 22 |
|
| 23 |
fn complex_cfg_subset<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 { |
| 24 |
// { dg-error "subset error, some lifetime constraints need to be added" "" { target *-*-* } .-1 } |
| 25 |
if b { |
| 26 |
y //~ ERROR |
| 27 |
} else { |
| 28 |
x |
| 29 |
} |
| 30 |
/* |
| 31 |
{ dg-begin-multiline-output "" } |
| 32 |
NN | fn complex_cfg_subset<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 { |
| 33 |
| ^~ ~~ ~~ |
| 34 |
| | | | |
| 35 |
| | | lifetime defined here |
| 36 |
| | lifetime defined here |
| 37 |
| subset error occurs in this function |
| 38 |
{ dg-end-multiline-output "" } |
| 39 |
*/ |
| 40 |
} |
| 41 |
|
| 42 |
fn complex_cfg_subset_fixed<'a, 'b>(b: bool, x: &'a u32, y: &'b u32) -> &'a u32 where 'b: 'a { |
| 43 |
if b { |
| 44 |
x |
| 45 |
} else { |
| 46 |
y |
| 47 |
} |
| 48 |
} |