@@ -13,7 +13,7 @@ use hir;
1313use hir:: map:: DefPathData ;
1414use hir:: def_id:: DefId ;
1515use mir:: mir_map:: MirMap ;
16- use mir:: repr:: Mir ;
16+ use mir:: repr:: { Mir , Promoted } ;
1717use ty:: TyCtxt ;
1818use syntax:: ast:: NodeId ;
1919
@@ -32,7 +32,7 @@ pub enum MirSource {
3232 Static ( NodeId , hir:: Mutability ) ,
3333
3434 /// Promoted rvalues within a function.
35- Promoted ( NodeId , usize )
35+ Promoted ( NodeId , Promoted )
3636}
3737
3838impl < ' a , ' tcx > MirSource {
@@ -77,7 +77,12 @@ pub trait Pass {
7777 DepNode :: MirPass ( def_id)
7878 }
7979 fn name ( & self ) -> & str {
80- unsafe { :: std:: intrinsics:: type_name :: < Self > ( ) }
80+ let name = unsafe { :: std:: intrinsics:: type_name :: < Self > ( ) } ;
81+ if let Some ( tail) = name. rfind ( ":" ) {
82+ & name[ tail+1 ..]
83+ } else {
84+ name
85+ }
8186 }
8287 fn disambiguator < ' a > ( & ' a self ) -> Option < Box < fmt:: Display +' a > > { None }
8388}
@@ -104,11 +109,6 @@ pub trait MirPassHook<'tcx>: Pass {
104109
105110/// A pass which inspects Mir of functions in isolation.
106111pub trait MirPass < ' tcx > : Pass {
107- fn run_pass_on_promoted < ' a > ( & mut self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
108- item_id : NodeId , index : usize ,
109- mir : & mut Mir < ' tcx > ) {
110- self . run_pass ( tcx, MirSource :: Promoted ( item_id, index) , mir) ;
111- }
112112 fn run_pass < ' a > ( & mut self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
113113 src : MirSource , mir : & mut Mir < ' tcx > ) ;
114114}
@@ -133,11 +133,12 @@ impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T {
133133 hook. on_mir_pass ( tcx, src, mir, self , true ) ;
134134 }
135135
136- for ( i, mir) in mir. promoted . iter_mut ( ) . enumerate ( ) {
136+ for ( i, mir) in mir. promoted . iter_enumerated_mut ( ) {
137+ let src = MirSource :: Promoted ( id, i) ;
137138 for hook in & mut * hooks {
138139 hook. on_mir_pass ( tcx, src, mir, self , false ) ;
139140 }
140- self . run_pass_on_promoted ( tcx , id , i , mir) ;
141+ MirPass :: run_pass ( self , tcx , src , mir) ;
141142 for hook in & mut * hooks {
142143 hook. on_mir_pass ( tcx, src, mir, self , true ) ;
143144 }
0 commit comments