@@ -13,6 +13,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
13
13
use rustc:: mir:: * ;
14
14
use rustc:: mir:: transform:: { MirSuite , MirPassIndex , MirSource } ;
15
15
use rustc:: ty:: TyCtxt ;
16
+ use rustc:: ty:: item_path;
16
17
use rustc_data_structures:: fx:: FxHashMap ;
17
18
use rustc_data_structures:: indexed_vec:: { Idx } ;
18
19
use std:: fmt:: Display ;
@@ -48,7 +49,9 @@ pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
48
49
return ;
49
50
}
50
51
51
- let node_path = tcx. item_path_str ( tcx. hir . local_def_id ( source. item_id ( ) ) ) ;
52
+ let node_path = item_path:: with_forced_impl_filename_line ( || { // see notes on #41697 below
53
+ tcx. item_path_str ( tcx. hir . local_def_id ( source. item_id ( ) ) )
54
+ } ) ;
52
55
dump_matched_mir_node ( tcx, pass_num, pass_name, & node_path,
53
56
disambiguator, source, mir) ;
54
57
for ( index, promoted_mir) in mir. promoted . iter_enumerated ( ) {
@@ -67,7 +70,9 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
67
70
Some ( ref filters) => filters,
68
71
} ;
69
72
let node_id = source. item_id ( ) ;
70
- let node_path = tcx. item_path_str ( tcx. hir . local_def_id ( node_id) ) ;
73
+ let node_path = item_path:: with_forced_impl_filename_line ( || { // see notes on #41697 below
74
+ tcx. item_path_str ( tcx. hir . local_def_id ( node_id) )
75
+ } ) ;
71
76
filters. split ( "&" )
72
77
. any ( |filter| {
73
78
filter == "all" ||
@@ -76,6 +81,10 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
76
81
} )
77
82
}
78
83
84
+ // #41697 -- we use `with_forced_impl_filename_line()` because
85
+ // `item_path_str()` would otherwise trigger `type_of`, and this can
86
+ // run while we are already attempting to evaluate `type_of`.
87
+
79
88
fn dump_matched_mir_node < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
80
89
pass_num : Option < ( MirSuite , MirPassIndex ) > ,
81
90
pass_name : & str ,
0 commit comments