@@ -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 ,
@@ -218,32 +219,44 @@ pub(super) fn dump_mir_results<'tcx>(
218
219
return ;
219
220
}
220
221
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
- ) ?;
222
+ // We want the NLL extra comments printed by default in NLL MIR dumps (they were removed in
223
+ // #112346). Specifying `-Z mir-include-spans` on the CLI still has priority: for example,
224
+ // they're always disabled in mir-opt tests to make working with blessed dumps easier.
225
+ let options = PrettyPrintMirOptions :: from_cli_with_default ( infcx. tcx , true ) ;
226
+ dump_mir_with_options (
227
+ infcx. tcx ,
228
+ false ,
229
+ "nll" ,
230
+ & 0 ,
231
+ body,
232
+ |pass_where, out| {
233
+ match pass_where {
234
+ // Before the CFG, dump out the values for each region variable.
235
+ PassWhere :: BeforeCFG => {
236
+ regioncx. dump_mir ( infcx. tcx , out) ?;
235
237
writeln ! ( out, "|" ) ?;
238
+
239
+ if let Some ( closure_region_requirements) = closure_region_requirements {
240
+ writeln ! ( out, "| Free Region Constraints" ) ?;
241
+ for_each_region_constraint (
242
+ infcx. tcx ,
243
+ closure_region_requirements,
244
+ & mut |msg| writeln ! ( out, "| {msg}" ) ,
245
+ ) ?;
246
+ writeln ! ( out, "|" ) ?;
247
+ }
236
248
}
237
- }
238
249
239
- PassWhere :: BeforeLocation ( _) => { }
250
+ PassWhere :: BeforeLocation ( _) => { }
240
251
241
- PassWhere :: AfterTerminator ( _) => { }
252
+ PassWhere :: AfterTerminator ( _) => { }
242
253
243
- PassWhere :: BeforeBlock ( _) | PassWhere :: AfterLocation ( _) | PassWhere :: AfterCFG => { }
244
- }
245
- Ok ( ( ) )
246
- } ) ;
254
+ PassWhere :: BeforeBlock ( _) | PassWhere :: AfterLocation ( _) | PassWhere :: AfterCFG => { }
255
+ }
256
+ Ok ( ( ) )
257
+ } ,
258
+ options,
259
+ ) ;
247
260
248
261
// Also dump the inference graph constraints as a graphviz file.
249
262
let _: io:: Result < ( ) > = try {
0 commit comments