33//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html
44
55use std:: borrow:: Cow ;
6- use std:: cell:: RefCell ;
7- use std:: collections:: hash_map:: Entry ;
86use std:: fmt:: { self , Debug , Formatter } ;
97use std:: ops:: { Index , IndexMut } ;
108use std:: { iter, mem} ;
@@ -26,7 +24,6 @@ use rustc_index::bit_set::BitSet;
2624use rustc_index:: { Idx , IndexSlice , IndexVec } ;
2725use rustc_macros:: { HashStable , TyDecodable , TyEncodable , TypeFoldable , TypeVisitable } ;
2826use rustc_serialize:: { Decodable , Encodable } ;
29- use rustc_session:: Session ;
3027use rustc_span:: source_map:: Spanned ;
3128use rustc_span:: symbol:: Symbol ;
3229use rustc_span:: { Span , DUMMY_SP } ;
@@ -106,65 +103,6 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
106103 }
107104}
108105
109- thread_local ! {
110- static PASS_NAMES : RefCell <FxHashMap <& ' static str , & ' static str >> = {
111- RefCell :: new( FxHashMap :: default ( ) )
112- } ;
113- }
114-
115- /// Converts a MIR pass name into a snake case form to match the profiling naming style.
116- fn to_profiler_name ( type_name : & ' static str ) -> & ' static str {
117- PASS_NAMES . with ( |names| match names. borrow_mut ( ) . entry ( type_name) {
118- Entry :: Occupied ( e) => * e. get ( ) ,
119- Entry :: Vacant ( e) => {
120- let snake_case: String = type_name
121- . chars ( )
122- . flat_map ( |c| {
123- if c. is_ascii_uppercase ( ) {
124- vec ! [ '_' , c. to_ascii_lowercase( ) ]
125- } else if c == '-' {
126- vec ! [ '_' ]
127- } else {
128- vec ! [ c]
129- }
130- } )
131- . collect ( ) ;
132- let result = & * String :: leak ( format ! ( "mir_pass{}" , snake_case) ) ;
133- e. insert ( result) ;
134- result
135- }
136- } )
137- }
138-
139- /// A streamlined trait that you can implement to create a pass; the
140- /// pass will be named after the type, and it will consist of a main
141- /// loop that goes over each available MIR and applies `run_pass`.
142- pub trait MirPass < ' tcx > {
143- fn name ( & self ) -> & ' static str {
144- // FIXME Simplify the implementation once more `str` methods get const-stable.
145- // See copypaste in `MirLint`
146- const {
147- let name = std:: any:: type_name :: < Self > ( ) ;
148- crate :: util:: common:: c_name ( name)
149- }
150- }
151-
152- fn profiler_name ( & self ) -> & ' static str {
153- to_profiler_name ( self . name ( ) )
154- }
155-
156- /// Returns `true` if this pass is enabled with the current combination of compiler flags.
157- fn is_enabled ( & self , _sess : & Session ) -> bool {
158- true
159- }
160-
161- fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) ;
162-
163- fn is_mir_dump_enabled ( & self ) -> bool {
164- true
165- }
166- }
167-
168106impl MirPhase {
169107 /// Gets the index of the current MirPhase within the set of all `MirPhase`s.
170108 ///
0 commit comments