Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 42b1450

Browse files
committed
add borrows to NLL MIR dumps
explicitly disable `-Zmir-include-spans` in mir-opt tests This will override the NLL default of true, and keep the blessed dumps easier to work with.
1 parent 925a99f commit 42b1450

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

‎compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn do_mir_borrowck<'tcx>(
229229

230230
// Dump MIR results into a file, if that is enabled. This let us
231231
// write unit-tests, as well as helping with debugging.
232-
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req);
232+
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req,&borrow_set);
233233

234234
// We also have a `#[rustc_regions]` annotation that causes us to dump
235235
// information.

‎compiler/rustc_borrowck/src/nll.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ pub(super) fn dump_nll_mir<'tcx>(
224224
body: &Body<'tcx>,
225225
regioncx: &RegionInferenceContext<'tcx>,
226226
closure_region_requirements: &Option<ClosureRegionRequirements<'tcx>>,
227+
borrow_set: &BorrowSet<'tcx>,
227228
) {
228229
let tcx = infcx.tcx;
229230
if !dump_enabled(tcx, "nll", body.source.def_id()) {
@@ -259,6 +260,18 @@ pub(super) fn dump_nll_mir<'tcx>(
259260
})?;
260261
writeln!(out, "|")?;
261262
}
263+
264+
if borrow_set.len() > 0 {
265+
writeln!(out, "| Borrows")?;
266+
for (borrow_idx, borrow_data) in borrow_set.iter_enumerated() {
267+
writeln!(
268+
out,
269+
"| {:?}: issued at {:?} in {:?}",
270+
borrow_idx, borrow_data.reserve_location, borrow_data.region
271+
)?;
272+
}
273+
writeln!(out, "|")?;
274+
}
262275
}
263276

264277
PassWhere::BeforeLocation(_) => {}

‎src/tools/compiletest/src/runtest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,7 @@ impl<'test> TestCx<'test> {
21752175
"-Zvalidate-mir",
21762176
"-Zlint-mir",
21772177
"-Zdump-mir-exclude-pass-number",
2178+
"-Zmir-include-spans=false", // remove span comments from NLL MIR dumps
21782179
"--crate-type=rlib",
21792180
]);
21802181
if let Some(pass) = &self.props.mir_unit_test {

‎tests/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:19:13: 19:18 (#0)
2121
| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:20:13: 20:14 (#0)
2222
|
23+
| Borrows
24+
| bw0: issued at bb1[0] in '?2
25+
|
2326
fn main() -> () {
2427
let mut _0: ();
2528
let mut _1: [usize; ValTree(Leaf(0x00000003): usize)];

‎tests/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
| '?2: '?3 due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:19:13: 19:18 (#0)
2121
| '?3: '?4 due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:20:13: 20:14 (#0)
2222
|
23+
| Borrows
24+
| bw0: issued at bb1[0] in '?2
25+
|
2326
fn main() -> () {
2427
let mut _0: ();
2528
let mut _1: [usize; ValTree(Leaf(0x0000000000000003): usize)];

‎tests/mir-opt/storage_ranges.main.nll.0.mir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
| '?3 live at {bb0[11]}
1818
| '?2: '?3 due to Assignment at Single(bb0[10]) ($DIR/storage_ranges.rs:7:17: 7:25 (#0)
1919
|
20+
| Borrows
21+
| bw0: issued at bb0[10] in '?2
22+
|
2023
fn main() -> () {
2124
let mut _0: ();
2225
let _1: i32;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /