aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/borrowck/position_dependant_outlives.rs
blob: 7856934a6b3600872b5d8e9d302d068ba3d99ca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
// { dg-additional-options "-frust-compile-until=compilation -frust-borrowcheck" }

pub fn position_dependent_outlives<'a>(x: &'a mut i32, cond: bool) -> &'a mut i32 {
    let y = &mut *x;
    if cond {
        return y;
    } else {
        *x = 0;
        return x;
    }
}