@@ -15,8 +15,6 @@ use hir::def_id::DefId;
15
15
use hir:: map:: DefPathData ;
16
16
use mir:: { Mir , Promoted } ;
17
17
use ty:: TyCtxt ;
18
- use ty:: maps:: Multi ;
19
- use ty:: steal:: Steal ;
20
18
use std:: cell:: Ref ;
21
19
use std:: rc:: Rc ;
22
20
use syntax:: ast:: NodeId ;
@@ -135,19 +133,6 @@ pub trait PassHook {
135
133
/// application of a pass to a def-id.
136
134
pub type PassId = ( MirSuite , MirPassIndex , DefId ) ;
137
135
138
- /// The most generic sort of MIR pass. You only want to implement this
139
- /// rather general trait if you are doing an interprocedural pass that
140
- /// may inspect and affect the MIR of many def-ids. Otherwise, prefer
141
- /// the more steamlined `DefIdPass` or `MirPass`.
142
- pub trait Pass {
143
- fn name < ' a > ( & ' a self ) -> Cow < ' a , str > {
144
- default_name :: < Self > ( )
145
- }
146
-
147
- fn run_pass < ' a , ' tcx : ' a > ( & self , mir_cx : & MirCtxt < ' a , ' tcx > )
148
- -> Multi < PassId , & ' tcx Steal < Mir < ' tcx > > > ;
149
- }
150
-
151
136
/// A streamlined trait that you can implement to create an
152
137
/// intraprocedural pass; the pass will be invoked to process the MIR
153
138
/// with the given `def_id`. This lets you do things before we fetch
@@ -160,17 +145,6 @@ pub trait DefIdPass {
160
145
fn run_pass < ' a , ' tcx : ' a > ( & self , mir_cx : & MirCtxt < ' a , ' tcx > ) -> Mir < ' tcx > ;
161
146
}
162
147
163
- impl < T : DefIdPass > Pass for T {
164
- fn name < ' a > ( & ' a self ) -> Cow < ' a , str > {
165
- DefIdPass :: name ( self )
166
- }
167
-
168
- fn run_pass < ' a , ' tcx : ' a > ( & self , mir_cx : & MirCtxt < ' a , ' tcx > )
169
- -> Multi < PassId , & ' tcx Steal < Mir < ' tcx > > > {
170
- Multi :: from ( mir_cx. tcx ( ) . alloc_steal_mir ( DefIdPass :: run_pass ( self , mir_cx) ) )
171
- }
172
- }
173
-
174
148
/// A streamlined trait that you can implement to create a pass; the
175
149
/// pass will be named after the type, and it will consist of a main
176
150
/// loop that goes over each available MIR and applies `run_pass`.
@@ -210,7 +184,7 @@ impl<T: MirPass> DefIdPass for T {
210
184
#[ derive( Clone ) ]
211
185
pub struct Passes {
212
186
pass_hooks : Vec < Rc < PassHook > > ,
213
- suites : Vec < Vec < Rc < Pass > > > ,
187
+ suites : Vec < Vec < Rc < DefIdPass > > > ,
214
188
}
215
189
216
190
/// The number of "pass suites" that we have:
@@ -238,7 +212,7 @@ impl<'a, 'tcx> Passes {
238
212
}
239
213
240
214
/// Pushes a built-in pass.
241
- pub fn push_pass < T : Pass + ' static > ( & mut self , suite : MirSuite , pass : T ) {
215
+ pub fn push_pass < T : DefIdPass + ' static > ( & mut self , suite : MirSuite , pass : T ) {
242
216
self . suites [ suite. 0 ] . push ( Rc :: new ( pass) ) ;
243
217
}
244
218
@@ -251,7 +225,7 @@ impl<'a, 'tcx> Passes {
251
225
self . suites [ suite. 0 ] . len ( )
252
226
}
253
227
254
- pub fn pass ( & self , suite : MirSuite , pass : MirPassIndex ) -> & Pass {
228
+ pub fn pass ( & self , suite : MirSuite , pass : MirPassIndex ) -> & DefIdPass {
255
229
& * self . suites [ suite. 0 ] [ pass. 0 ]
256
230
}
257
231
0 commit comments