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 15c146f

Browse files
committed
enable extra comments in NLL MIR dumps
1 parent 6bfe236 commit 15c146f

File tree

1 file changed

+40
-21
lines changed
  • compiler/rustc_borrowck/src

1 file changed

+40
-21
lines changed

‎compiler/rustc_borrowck/src/nll.rs

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use polonius_engine::{Algorithm, Output};
99
use rustc_data_structures::fx::FxIndexMap;
1010
use rustc_hir::def_id::LocalDefId;
1111
use rustc_index::IndexSlice;
12+
use rustc_middle::mir::pretty::{dump_mir_with_options, PrettyPrintMirOptions};
1213
use rustc_middle::mir::{
1314
create_dump_file, dump_enabled, dump_mir, Body, ClosureOutlivesSubject,
1415
ClosureRegionRequirements, PassWhere, Promoted,
@@ -19,6 +20,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
1920
use rustc_mir_dataflow::move_paths::MoveData;
2021
use rustc_mir_dataflow::points::DenseLocationMap;
2122
use rustc_mir_dataflow::ResultsCursor;
23+
use rustc_session::config::MirIncludeSpans;
2224
use rustc_span::symbol::sym;
2325

2426
use crate::borrow_set::BorrowSet;
@@ -218,32 +220,49 @@ pub(super) fn dump_mir_results<'tcx>(
218220
return;
219221
}
220222

221-
dump_mir(infcx.tcx, false, "nll", &0, body, |pass_where, out| {
222-
match pass_where {
223-
// Before the CFG, dump out the values for each region variable.
224-
PassWhere::BeforeCFG => {
225-
regioncx.dump_mir(infcx.tcx, out)?;
226-
writeln!(out, "|")?;
227-
228-
if let Some(closure_region_requirements) = closure_region_requirements {
229-
writeln!(out, "| Free Region Constraints")?;
230-
for_each_region_constraint(
231-
infcx.tcx,
232-
closure_region_requirements,
233-
&mut |msg| writeln!(out, "| {msg}"),
234-
)?;
223+
// We want the NLL extra comments printed by default in NLL MIR dumps (they were removed in
224+
// #112346). Specifying `-Z mir-include-spans` on the CLI still has priority: for example,
225+
// they're always disabled in mir-opt tests to make working with blessed dumps easier.
226+
let options = PrettyPrintMirOptions {
227+
include_extra_comments: matches!(
228+
infcx.tcx.sess.opts.unstable_opts.mir_include_spans,
229+
MirIncludeSpans::On | MirIncludeSpans::Nll
230+
),
231+
};
232+
dump_mir_with_options(
233+
infcx.tcx,
234+
false,
235+
"nll",
236+
&0,
237+
body,
238+
|pass_where, out| {
239+
match pass_where {
240+
// Before the CFG, dump out the values for each region variable.
241+
PassWhere::BeforeCFG => {
242+
regioncx.dump_mir(infcx.tcx, out)?;
235243
writeln!(out, "|")?;
244+
245+
if let Some(closure_region_requirements) = closure_region_requirements {
246+
writeln!(out, "| Free Region Constraints")?;
247+
for_each_region_constraint(
248+
infcx.tcx,
249+
closure_region_requirements,
250+
&mut |msg| writeln!(out, "| {msg}"),
251+
)?;
252+
writeln!(out, "|")?;
253+
}
236254
}
237-
}
238255

239-
PassWhere::BeforeLocation(_) => {}
256+
PassWhere::BeforeLocation(_) => {}
240257

241-
PassWhere::AfterTerminator(_) => {}
258+
PassWhere::AfterTerminator(_) => {}
242259

243-
PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
244-
}
245-
Ok(())
246-
});
260+
PassWhere::BeforeBlock(_) | PassWhere::AfterLocation(_) | PassWhere::AfterCFG => {}
261+
}
262+
Ok(())
263+
},
264+
options,
265+
);
247266

248267
// Also dump the inference graph constraints as a graphviz file.
249268
let _: io::Result<()> = try {

0 commit comments

Comments
(0)

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