@@ -13,7 +13,7 @@ use hir;
13
13
use hir:: map:: DefPathData ;
14
14
use hir:: def_id:: DefId ;
15
15
use mir:: mir_map:: MirMap ;
16
- use mir:: repr:: Mir ;
16
+ use mir:: repr:: { Mir , Promoted } ;
17
17
use ty:: TyCtxt ;
18
18
use syntax:: ast:: NodeId ;
19
19
@@ -32,7 +32,7 @@ pub enum MirSource {
32
32
Static ( NodeId , hir:: Mutability ) ,
33
33
34
34
/// Promoted rvalues within a function.
35
- Promoted ( NodeId , usize )
35
+ Promoted ( NodeId , Promoted )
36
36
}
37
37
38
38
impl < ' a , ' tcx > MirSource {
@@ -77,7 +77,12 @@ pub trait Pass {
77
77
DepNode :: MirPass ( def_id)
78
78
}
79
79
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
+ }
81
86
}
82
87
fn disambiguator < ' a > ( & ' a self ) -> Option < Box < fmt:: Display +' a > > { None }
83
88
}
@@ -104,11 +109,6 @@ pub trait MirPassHook<'tcx>: Pass {
104
109
105
110
/// A pass which inspects Mir of functions in isolation.
106
111
pub 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
- }
112
112
fn run_pass < ' a > ( & mut self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
113
113
src : MirSource , mir : & mut Mir < ' tcx > ) ;
114
114
}
@@ -133,11 +133,12 @@ impl<'tcx, T: MirPass<'tcx>> MirMapPass<'tcx> for T {
133
133
hook. on_mir_pass ( tcx, src, mir, self , true ) ;
134
134
}
135
135
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) ;
137
138
for hook in & mut * hooks {
138
139
hook. on_mir_pass ( tcx, src, mir, self , false ) ;
139
140
}
140
- self . run_pass_on_promoted ( tcx , id , i , mir) ;
141
+ MirPass :: run_pass ( self , tcx , src , mir) ;
141
142
for hook in & mut * hooks {
142
143
hook. on_mir_pass ( tcx, src, mir, self , true ) ;
143
144
}
0 commit comments