@@ -9,6 +9,7 @@ use polonius_engine::{Algorithm, Output};
9
9
use rustc_data_structures:: fx:: FxIndexMap ;
10
10
use rustc_hir:: def_id:: LocalDefId ;
11
11
use rustc_index:: IndexSlice ;
12
+ use rustc_middle:: mir:: pretty:: { dump_mir_with_options, PrettyPrintMirOptions } ;
12
13
use rustc_middle:: mir:: {
13
14
create_dump_file, dump_enabled, dump_mir, Body , ClosureOutlivesSubject ,
14
15
ClosureRegionRequirements , PassWhere , Promoted ,
@@ -19,6 +20,7 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
19
20
use rustc_mir_dataflow:: move_paths:: MoveData ;
20
21
use rustc_mir_dataflow:: points:: DenseLocationMap ;
21
22
use rustc_mir_dataflow:: ResultsCursor ;
23
+ use rustc_session:: config:: MirIncludeSpans ;
22
24
use rustc_span:: symbol:: sym;
23
25
24
26
use crate :: borrow_set:: BorrowSet ;
@@ -218,32 +220,49 @@ pub(super) fn dump_mir_results<'tcx>(
218
220
return ;
219
221
}
220
222
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) ?;
235
243
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
+ }
236
254
}
237
- }
238
255
239
- PassWhere :: BeforeLocation ( _) => { }
256
+ PassWhere :: BeforeLocation ( _) => { }
240
257
241
- PassWhere :: AfterTerminator ( _) => { }
258
+ PassWhere :: AfterTerminator ( _) => { }
242
259
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
+ ) ;
247
266
248
267
// Also dump the inference graph constraints as a graphviz file.
249
268
let _: io:: Result < ( ) > = try {
0 commit comments