Skip to content

Commit 8fb888d

Browse files
committed
Add multiple borrow test.
1 parent 13fb079 commit 8fb888d

File tree

3 files changed

+89
-55
lines changed

3 files changed

+89
-55
lines changed

tests/debuginfo/reference-debuginfo.rs

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
// gdb-command:print *f64_ref
5353
// gdb-check:$14 = 3.5
5454

55+
// gdb-command:print *f64_double_ref
56+
// gdb-check:$15 = 3.5
57+
5558

5659
// === LLDB TESTS ==================================================================================
5760

@@ -112,6 +115,10 @@
112115
// lldbg-check:[...]$12 = 3.5
113116
// lldbr-check:(f64) *f64_ref = 3.5
114117

118+
// lldb-command:print *f64_double_ref
119+
// lldbg-check:[...]$13 = 3.5
120+
// lldbr-check:(f64) **f64_double_ref = 3.5
121+
115122
#![allow(unused_variables)]
116123
#![feature(omit_gdb_pretty_printer_section)]
117124
#![omit_gdb_pretty_printer_section]
@@ -158,6 +165,7 @@ fn main() {
158165

159166
let f64_val: f64 = 3.5;
160167
let f64_ref: &f64 = &f64_val;
168+
let f64_double_ref: &f64 = &f64_ref;
161169

162170
zzz(); // #break
163171
}

tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff

+79-55
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,50 @@
99
let _6: (); // in scope 0 at $DIR/reference_prop.rs:+9:5: +12:6
1010
let mut _7: std::option::Option<i32>; // in scope 0 at $DIR/reference_prop.rs:+9:11: +9:18
1111
let mut _8: isize; // in scope 0 at $DIR/reference_prop.rs:+10:9: +10:13
12-
let mut _10: &[i32]; // in scope 0 at $DIR/reference_prop.rs:+16:82: +16:94
13-
let _11: &[i32]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:94
14-
let mut _12: &[i32; 10]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:90
15-
let _13: [i32; 10]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:90
16-
let mut _14: std::ops::RangeFull; // in scope 0 at $DIR/reference_prop.rs:+16:91: +16:93
17-
let mut _15: usize; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79
12+
let _10: (); // in scope 0 at $DIR/reference_prop.rs:+16:5: +17:6
13+
let mut _11: &[i32]; // in scope 0 at $DIR/reference_prop.rs:+16:82: +16:94
14+
let _12: &[i32]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:94
15+
let mut _13: &[i32; 10]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:90
16+
let _14: [i32; 10]; // in scope 0 at $DIR/reference_prop.rs:+16:83: +16:90
17+
let mut _15: std::ops::RangeFull; // in scope 0 at $DIR/reference_prop.rs:+16:91: +16:93
1818
let mut _16: usize; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79
19-
let mut _17: bool; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79
19+
let mut _17: usize; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79
20+
let mut _18: bool; // in scope 0 at $DIR/reference_prop.rs:+16:12: +16:79
21+
let _23: &&mut u8; // in scope 0 at $DIR/reference_prop.rs:+19:28: +19:40
22+
let _24: &mut u8; // in scope 0 at $DIR/reference_prop.rs:+19:29: +19:40
23+
let mut _25: debuginfo::T; // in scope 0 at $DIR/reference_prop.rs:+19:34: +19:38
2024
scope 1 {
2125
- debug ref_mut_u8 => _1; // in scope 1 at $DIR/reference_prop.rs:+3:9: +3:19
2226
+ debug ref_mut_u8 => &_2; // in scope 1 at $DIR/reference_prop.rs:+3:9: +3:19
2327
let _3: &u8; // in scope 1 at $DIR/reference_prop.rs:+4:9: +4:14
24-
let mut _23: &debuginfo::T; // in scope 1 at $DIR/reference_prop.rs:+4:17: +4:24
28+
let mut _28: &debuginfo::T; // in scope 1 at $DIR/reference_prop.rs:+4:17: +4:24
2529
scope 2 {
2630
- debug field => _3; // in scope 2 at $DIR/reference_prop.rs:+4:9: +4:14
27-
+ debug field => &((*_23).0: u8); // in scope 2 at $DIR/reference_prop.rs:+4:9: +4:14
31+
+ debug field => &((*_28).0: u8); // in scope 2 at $DIR/reference_prop.rs:+4:9: +4:14
2832
let _5: &u8; // in scope 2 at $DIR/reference_prop.rs:+7:9: +7:17
2933
scope 3 {
3034
- debug reborrow => _5; // in scope 3 at $DIR/reference_prop.rs:+7:9: +7:17
3135
+ debug reborrow => &_2; // in scope 3 at $DIR/reference_prop.rs:+7:9: +7:17
3236
let _9: &i32; // in scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
33-
let mut _22: &std::option::Option<i32>; // in scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
37+
let _22: &&&mut u8; // in scope 3 at $DIR/reference_prop.rs:+19:9: +19:24
38+
let mut _27: &std::option::Option<i32>; // in scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
3439
scope 4 {
3540
- debug variant_field => _9; // in scope 4 at $DIR/reference_prop.rs:+11:14: +11:31
36-
+ debug variant_field => &(((*_22) as Some).0: i32); // in scope 4 at $DIR/reference_prop.rs:+11:14: +11:31
41+
+ debug variant_field => &(((*_27) as Some).0: i32); // in scope 4 at $DIR/reference_prop.rs:+11:14: +11:31
3742
}
3843
scope 5 {
39-
- debug constant_index => _18; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
40-
+ debug constant_index => &(*_10)[1 of 3]; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
41-
debug subslice => _19; // in scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
42-
debug constant_index_from_end => _20; // in scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
43-
let _18: &i32; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
44-
let _19: &[i32]; // in scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
45-
let _20: &i32; // in scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
46-
let mut _21: &[i32; 10]; // in scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
44+
- debug constant_index => _19; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
45+
+ debug constant_index => &(*_11)[1 of 3]; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
46+
debug subslice => _20; // in scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
47+
debug constant_index_from_end => _21; // in scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
48+
let _19: &i32; // in scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
49+
let _20: &[i32]; // in scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
50+
let _21: &i32; // in scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
51+
let mut _26: &[i32; 10]; // in scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
52+
}
53+
scope 6 {
54+
- debug multiple_borrow => _22; // in scope 6 at $DIR/reference_prop.rs:+19:9: +19:24
55+
+ debug multiple_borrow => &&&(_25.0: u8); // in scope 6 at $DIR/reference_prop.rs:+19:9: +19:24
4756
}
4857
}
4958
}
@@ -55,11 +64,11 @@
5564
_2 = const 5_u8; // scope 0 at $DIR/reference_prop.rs:+3:27: +3:31
5665
- _1 = &mut _2; // scope 0 at $DIR/reference_prop.rs:+3:22: +3:31
5766
- StorageLive(_3); // scope 1 at $DIR/reference_prop.rs:+4:9: +4:14
58-
_23 = const _; // scope 1 at $DIR/reference_prop.rs:+4:17: +4:24
67+
_28 = const _; // scope 1 at $DIR/reference_prop.rs:+4:17: +4:24
5968
// mir::Constant
6069
// + span: $DIR/reference_prop.rs:535:17: 535:24
6170
// + literal: Const { ty: &T, val: Unevaluated(debuginfo, [], Some(promoted[2])) }
62-
- _3 = &((*_23).0: u8); // scope 1 at $DIR/reference_prop.rs:+4:17: +4:24
71+
- _3 = &((*_28).0: u8); // scope 1 at $DIR/reference_prop.rs:+4:17: +4:24
6372
- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+7:9: +7:17
6473
- _5 = &(*_1); // scope 2 at $DIR/reference_prop.rs:+7:20: +7:32
6574
- StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+9:5: +12:6
@@ -71,11 +80,11 @@
7180

7281
bb1: {
7382
- StorageLive(_9); // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
74-
_22 = const _; // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
83+
_27 = const _; // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
7584
// mir::Constant
7685
// + span: $DIR/reference_prop.rs:542:14: 542:31
7786
// + literal: Const { ty: &Option<i32>, val: Unevaluated(debuginfo, [], Some(promoted[1])) }
78-
- _9 = &(((*_22) as Some).0: i32); // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
87+
- _9 = &(((*_27) as Some).0: i32); // scope 3 at $DIR/reference_prop.rs:+11:14: +11:31
7988
- _6 = const (); // scope 4 at $DIR/reference_prop.rs:+11:36: +11:38
8089
- StorageDead(_9); // scope 3 at $DIR/reference_prop.rs:+11:37: +11:38
8190
goto -> bb4; // scope 3 at $DIR/reference_prop.rs:+11:37: +11:38
@@ -93,59 +102,74 @@
93102
bb4: {
94103
StorageDead(_7); // scope 3 at $DIR/reference_prop.rs:+12:5: +12:6
95104
- StorageDead(_6); // scope 3 at $DIR/reference_prop.rs:+12:5: +12:6
96-
StorageLive(_10); // scope 5 at $DIR/reference_prop.rs:+16:82: +16:94
97-
StorageLive(_11); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:94
98-
StorageLive(_12); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
99-
_21 = const _; // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
105+
- StorageLive(_10); // scope 3 at $DIR/reference_prop.rs:+16:5: +17:6
106+
StorageLive(_11); // scope 5 at $DIR/reference_prop.rs:+16:82: +16:94
107+
StorageLive(_12); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:94
108+
StorageLive(_13); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
109+
_26 = const _; // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
100110
// mir::Constant
101111
// + span: $DIR/reference_prop.rs:547:83: 547:90
102112
// + literal: Const { ty: &[i32; 10], val: Unevaluated(debuginfo, [], Some(promoted[0])) }
103-
_12 = &(*_21); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
104-
StorageLive(_14); // scope 5 at $DIR/reference_prop.rs:+16:91: +16:93
105-
_14 = RangeFull; // scope 5 at $DIR/reference_prop.rs:+16:91: +16:93
106-
_11 = <[i32; 10] as Index<RangeFull>>::index(move _12, move _14) -> bb5; // scope 5 at $DIR/reference_prop.rs:+16:83: +16:94
113+
_13 = &(*_26); // scope 5 at $DIR/reference_prop.rs:+16:83: +16:90
114+
StorageLive(_15); // scope 5 at $DIR/reference_prop.rs:+16:91: +16:93
115+
_15 = RangeFull; // scope 5 at $DIR/reference_prop.rs:+16:91: +16:93
116+
_12 = <[i32; 10] as Index<RangeFull>>::index(move _13, move _15) -> bb5; // scope 5 at $DIR/reference_prop.rs:+16:83: +16:94
107117
// mir::Constant
108118
// + span: $DIR/reference_prop.rs:547:83: 547:94
109119
// + literal: Const { ty: for<'a> fn(&'a [i32; 10], RangeFull) -> &'a <[i32; 10] as Index<RangeFull>>::Output {<[i32; 10] as Index<RangeFull>>::index}, val: Value(<ZST>) }
110120
}
111121

112122
bb5: {
113-
StorageDead(_14); // scope 5 at $DIR/reference_prop.rs:+16:93: +16:94
114-
StorageDead(_12); // scope 5 at $DIR/reference_prop.rs:+16:93: +16:94
115-
_10 = &(*_11); // scope 5 at $DIR/reference_prop.rs:+16:82: +16:94
116-
_15 = Len((*_10)); // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
117-
_16 = const 3_usize; // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
118-
_17 = Ge(move _15, move _16); // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
119-
switchInt(move _17) -> [0: bb7, otherwise: bb6]; // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
123+
StorageDead(_15); // scope 5 at $DIR/reference_prop.rs:+16:93: +16:94
124+
StorageDead(_13); // scope 5 at $DIR/reference_prop.rs:+16:93: +16:94
125+
_11 = &(*_12); // scope 5 at $DIR/reference_prop.rs:+16:82: +16:94
126+
_16 = Len((*_11)); // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
127+
_17 = const 3_usize; // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
128+
_18 = Ge(move _16, move _17); // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
129+
switchInt(move _18) -> [0: bb7, otherwise: bb6]; // scope 5 at $DIR/reference_prop.rs:+16:12: +16:79
120130
}
121131

122132
bb6: {
123-
- StorageLive(_18); // scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
124-
- _18 = &(*_10)[1 of 3]; // scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
125-
StorageLive(_19); // scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
126-
_19 = &(*_10)[2:-1]; // scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
127-
StorageLive(_20); // scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
128-
_20 = &(*_10)[-1 of 3]; // scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
129-
_0 = const (); // scope 5 at $DIR/reference_prop.rs:+16:95: +17:6
133+
- StorageLive(_19); // scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
134+
- _19 = &(*_11)[1 of 3]; // scope 5 at $DIR/reference_prop.rs:+16:16: +16:34
135+
StorageLive(_20); // scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
136+
_20 = &(*_11)[2:-1]; // scope 5 at $DIR/reference_prop.rs:+16:36: +16:44
137+
StorageLive(_21); // scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
138+
_21 = &(*_11)[-1 of 3]; // scope 5 at $DIR/reference_prop.rs:+16:51: +16:78
139+
- _10 = const (); // scope 5 at $DIR/reference_prop.rs:+16:95: +17:6
140+
StorageDead(_21); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
130141
StorageDead(_20); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
131-
StorageDead(_19); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
132-
- StorageDead(_18); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
142+
- StorageDead(_19); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
133143
goto -> bb8; // scope 3 at $DIR/reference_prop.rs:+16:5: +17:6
134144
}
135145

136146
bb7: {
137-
_0 = const (); // scope 3 at $DIR/reference_prop.rs:+17:6: +17:6
147+
- _10 = const (); // scope 3 at $DIR/reference_prop.rs:+17:6: +17:6
138148
goto -> bb8; // scope 3 at $DIR/reference_prop.rs:+16:5: +17:6
139149
}
140150

141151
bb8: {
142-
- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+18:1: +18:2
143-
- StorageDead(_3); // scope 1 at $DIR/reference_prop.rs:+18:1: +18:2
144-
StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+18:1: +18:2
145-
- StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+18:1: +18:2
146-
StorageDead(_11); // scope 0 at $DIR/reference_prop.rs:+18:1: +18:2
147-
StorageDead(_10); // scope 0 at $DIR/reference_prop.rs:+18:1: +18:2
148-
return; // scope 0 at $DIR/reference_prop.rs:+18:2: +18:2
152+
StorageDead(_12); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
153+
StorageDead(_11); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
154+
- StorageDead(_10); // scope 3 at $DIR/reference_prop.rs:+17:5: +17:6
155+
- StorageLive(_22); // scope 3 at $DIR/reference_prop.rs:+19:9: +19:24
156+
- StorageLive(_23); // scope 3 at $DIR/reference_prop.rs:+19:28: +19:40
157+
- StorageLive(_24); // scope 3 at $DIR/reference_prop.rs:+19:29: +19:40
158+
StorageLive(_25); // scope 3 at $DIR/reference_prop.rs:+19:34: +19:38
159+
_25 = T(const 6_u8); // scope 3 at $DIR/reference_prop.rs:+19:34: +19:38
160+
- _24 = &mut (_25.0: u8); // scope 3 at $DIR/reference_prop.rs:+19:29: +19:40
161+
- _23 = &_24; // scope 3 at $DIR/reference_prop.rs:+19:28: +19:40
162+
- _22 = &_23; // scope 3 at $DIR/reference_prop.rs:+19:27: +19:40
163+
_0 = const (); // scope 0 at $DIR/reference_prop.rs:+0:16: +20:2
164+
StorageDead(_25); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2
165+
- StorageDead(_24); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2
166+
- StorageDead(_23); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2
167+
- StorageDead(_22); // scope 3 at $DIR/reference_prop.rs:+20:1: +20:2
168+
- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+20:1: +20:2
169+
- StorageDead(_3); // scope 1 at $DIR/reference_prop.rs:+20:1: +20:2
170+
StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+20:1: +20:2
171+
- StorageDead(_1); // scope 0 at $DIR/reference_prop.rs:+20:1: +20:2
172+
return; // scope 0 at $DIR/reference_prop.rs:+20:2: +20:2
149173
}
150174
}
151175

tests/mir-opt/reference_prop.rs

+2
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ fn debuginfo() {
546546
// on the slice length.
547547
if let [_, ref constant_index, subslice @ .., ref constant_index_from_end] = &[6; 10][..] {
548548
}
549+
550+
let multiple_borrow = &&&mut T(6).0;
549551
}
550552

551553
fn many_debuginfo() {

0 commit comments

Comments
 (0)