about summary refs log tree commit diff
path: root/tests/ui/nll/polonius/nll-problem-case-3-issue-58787.rs
blob: 75552e24219a09f523f8f7b5df9259811149e521 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#![crate_type = "lib"]

// This is part of a collection of regression tests related to the NLL problem case 3 that was
// deferred from the implementation of the NLL RFC, and left to be implemented by polonius. They are
// from open issues, e.g. tagged fixed-by-polonius, to ensure that the polonius alpha analysis does
// handle them, as does the datalog implementation.

//@ ignore-compare-mode-polonius (explicit revisions)
//@ revisions: nll polonius legacy
//@ [nll] known-bug: #58787
//@ [polonius] check-pass
//@ [polonius] compile-flags: -Z polonius=next
//@ [legacy] check-pass
//@ [legacy] compile-flags: -Z polonius=legacy

struct Node {
    rest: List,
}

struct List(Option<Box<Node>>);

fn issue_58787(arg: &mut List) {
    let mut list = arg;

    match list.0 {
        Some(ref mut d) => {
            if true {
                list = &mut d.rest;
            }
        }
        None => (),
    }

    match list.0 {
        Some(ref mut d) => {
            list = &mut d.rest;
        }
        None => (),
    }

    match list {
        List(Some(d)) => {
            if true {
                list = &mut d.rest;
            }
        }
        List(None) => (),
    }

    match list {
        List(Some(d)) => {
            list = &mut d.rest;
        }
        List(None) => (),
    }

    match &mut list.0 {
        Some(d) => {
            if true {
                list = &mut d.rest;
            }
        }
        None => (),
    }

    match &mut list.0 {
        Some(d) => {
            list = &mut d.rest;
        }
        None => (),
    }

    list.0 = None;
}