summaryrefslogtreecommitdiffstats
path: root/tests/debuginfo/mutable-locs.rs
blob: 688483e43e4dbdbf6e0e90895bce185fc90bcc66 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Testing the display of Cell, RefCell, and RefMut in cdb.

// cdb-only
// min-cdb-version: 10.0.18317.1001
// compile-flags:-g

// === CDB TESTS ==================================================================================

// cdb-command: g

// cdb-command:dx static_c,d
// cdb-check:static_c,d       : 10 [Type: core::cell::Cell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::Cell<i32>]

// cdb-command: dx static_c.value,d
// cdb-check:static_c.value,d : 10 [Type: core::cell::UnsafeCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::UnsafeCell<i32>]

// cdb-command:  dx dynamic_c,d
// cdb-check:dynamic_c,d      : 15 [Type: core::cell::RefCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefCell<i32>]
// cdb-check:    [Borrow state]   : Unborrowed

// cdb-command: dx dynamic_c.value,d
// cdb-check:dynamic_c.value,d : 15 [Type: core::cell::UnsafeCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::UnsafeCell<i32>]

// cdb-command: dx b,d
// cdb-check:b,d              : 42 [Type: core::cell::RefMut<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefMut<i32>]
// cdb-check:    42 [Type: int]

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d      : 15 [Type: core::cell::RefCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefCell<i32>]
// cdb-check:    [Borrow state]   : Immutably borrowed

// cdb-command: dx r_borrow,d
// cdb-check:r_borrow,d       : 15 [Type: core::cell::Ref<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::Ref<i32>]
// cdb-check:    15 [Type: int]

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d      : 15 [Type: core::cell::RefCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefCell<i32>]
// cdb-check:    [Borrow state]   : Unborrowed

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d      : 15 [Type: core::cell::RefCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefCell<i32>]
// cdb-check:    [Borrow state]   : Mutably borrowed

// cdb-command: dx r_borrow_mut,d
// cdb-check:r_borrow_mut,d   : 15 [Type: core::cell::RefMut<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefMut<i32>]
// cdb-check:    15 [Type: int]

// cdb-command: g

// cdb-command: dx dynamic_c,d
// cdb-check:dynamic_c,d      : 15 [Type: core::cell::RefCell<i32>]
// cdb-check:    [<Raw View>]     [Type: core::cell::RefCell<i32>]
// cdb-check:    [Borrow state]   : Unborrowed

#![allow(unused_variables)]

use std::cell::{Cell, RefCell};

fn main() {
    let static_c = Cell::new(5);
    static_c.set(10);

    let dynamic_c = RefCell::new(5);
    dynamic_c.replace(15);

    let dynamic_c_0 = RefCell::new(15);
    let mut b = dynamic_c_0.borrow_mut();
    *b = 42;

    zzz(); // #break

    // Check that `RefCell`'s borrow state visualizes correctly
    {
        let r_borrow = dynamic_c.borrow();
        zzz(); // #break
    }

    zzz(); // #break

    {
        let r_borrow_mut = dynamic_c.borrow_mut();
        zzz(); // #break
    }

    zzz(); // #break
}

fn zzz() {()}