]> git.proxmox.com Git - rustc.git/blob - src/test/debuginfo/mutable-locs.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / test / debuginfo / mutable-locs.rs
1 // Testing the display of Cell, RefCell, and RefMut in cdb.
2
3 // cdb-only
4 // min-cdb-version: 10.0.18317.1001
5 // compile-flags:-g
6
7 // === CDB TESTS ==================================================================================
8
9 // cdb-command: g
10
11 // cdb-command:dx static_c,d
12 // cdb-check:static_c,d : 10 [Type: core::cell::Cell<i32>]
13 // cdb-check: [<Raw View>] [Type: core::cell::Cell<i32>]
14
15 // cdb-command: dx static_c.value,d
16 // cdb-check:static_c.value,d : 10 [Type: core::cell::UnsafeCell<i32>]
17 // cdb-check: [<Raw View>] [Type: core::cell::UnsafeCell<i32>]
18
19 // cdb-command: dx dynamic_c,d
20 // cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
21 // cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
22 // cdb-check: [Borrow state] : Unborrowed
23
24 // cdb-command: dx dynamic_c.value,d
25 // cdb-check:dynamic_c.value,d : 15 [Type: core::cell::UnsafeCell<i32>]
26 // cdb-check: [<Raw View>] [Type: core::cell::UnsafeCell<i32>]
27
28 // cdb-command: dx b,d
29 // cdb-check:b,d : 42 [Type: core::cell::RefMut<i32>]
30 // cdb-check: [<Raw View>] [Type: core::cell::RefMut<i32>]
31 // cdb-check: 42 [Type: int]
32
33 // cdb-command: g
34
35 // cdb-command: dx dynamic_c,d
36 // cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
37 // cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
38 // cdb-check: [Borrow state] : Immutably borrowed
39
40 // cdb-command: dx r_borrow,d
41 // cdb-check:r_borrow,d : 15 [Type: core::cell::Ref<i32>]
42 // cdb-check: [<Raw View>] [Type: core::cell::Ref<i32>]
43 // cdb-check: 15 [Type: int]
44
45 // cdb-command: g
46
47 // cdb-command: dx dynamic_c,d
48 // cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
49 // cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
50 // cdb-check: [Borrow state] : Unborrowed
51
52 // cdb-command: g
53
54 // cdb-command: dx dynamic_c,d
55 // cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
56 // cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
57 // cdb-check: [Borrow state] : Mutably borrowed
58
59 // cdb-command: dx r_borrow_mut,d
60 // cdb-check:r_borrow_mut,d : 15 [Type: core::cell::RefMut<i32>]
61 // cdb-check: [<Raw View>] [Type: core::cell::RefMut<i32>]
62 // cdb-check: 15 [Type: int]
63
64 // cdb-command: g
65
66 // cdb-command: dx dynamic_c,d
67 // cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell<i32>]
68 // cdb-check: [<Raw View>] [Type: core::cell::RefCell<i32>]
69 // cdb-check: [Borrow state] : Unborrowed
70
71 #![allow(unused_variables)]
72
73 use std::cell::{Cell, RefCell};
74
75 fn main() {
76 let static_c = Cell::new(5);
77 static_c.set(10);
78
79 let dynamic_c = RefCell::new(5);
80 dynamic_c.replace(15);
81
82 let dynamic_c_0 = RefCell::new(15);
83 let mut b = dynamic_c_0.borrow_mut();
84 *b = 42;
85
86 zzz(); // #break
87
88 // Check that `RefCell`'s borrow state visualizes correctly
89 {
90 let r_borrow = dynamic_c.borrow();
91 zzz(); // #break
92 }
93
94 zzz(); // #break
95
96 {
97 let r_borrow_mut = dynamic_c.borrow_mut();
98 zzz(); // #break
99 }
100
101 zzz(); // #break
102 }
103
104 fn zzz() {()}