@@ -13,6 +13,7 @@ use rustc::hir::def_id::{DefId, LOCAL_CRATE};
1313use rustc:: mir:: * ;
1414use rustc:: mir:: transform:: { MirSuite , MirPassIndex , MirSource } ;
1515use rustc:: ty:: TyCtxt ;
16+ use rustc:: ty:: item_path;
1617use rustc_data_structures:: fx:: FxHashMap ;
1718use rustc_data_structures:: indexed_vec:: { Idx } ;
1819use std:: fmt:: Display ;
@@ -48,7 +49,9 @@ pub fn dump_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
4849 return ;
4950 }
5051
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+ } ) ;
5255 dump_matched_mir_node ( tcx, pass_num, pass_name, & node_path,
5356 disambiguator, source, mir) ;
5457 for ( index, promoted_mir) in mir. promoted . iter_enumerated ( ) {
@@ -67,7 +70,9 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
6770 Some ( ref filters) => filters,
6871 } ;
6972 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+ } ) ;
7176 filters. split ( "&" )
7277 . any ( |filter| {
7378 filter == "all" ||
@@ -76,6 +81,10 @@ pub fn dump_enabled<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
7681 } )
7782}
7883
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+
7988fn dump_matched_mir_node < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
8089 pass_num : Option < ( MirSuite , MirPassIndex ) > ,
8190 pass_name : & str ,
0 commit comments