3
3
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html
4
4
5
5
use std:: borrow:: Cow ;
6
- use std:: cell:: RefCell ;
7
- use std:: collections:: hash_map:: Entry ;
8
6
use std:: fmt:: { self , Debug , Formatter } ;
9
7
use std:: ops:: { Index , IndexMut } ;
10
8
use std:: { iter, mem} ;
@@ -26,7 +24,6 @@ use rustc_index::bit_set::BitSet;
26
24
use rustc_index:: { Idx , IndexSlice , IndexVec } ;
27
25
use rustc_macros:: { HashStable , TyDecodable , TyEncodable , TypeFoldable , TypeVisitable } ;
28
26
use rustc_serialize:: { Decodable , Encodable } ;
29
- use rustc_session:: Session ;
30
27
use rustc_span:: source_map:: Spanned ;
31
28
use rustc_span:: symbol:: Symbol ;
32
29
use rustc_span:: { Span , DUMMY_SP } ;
@@ -106,65 +103,6 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> {
106
103
}
107
104
}
108
105
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
-
168
106
impl MirPhase {
169
107
/// Gets the index of the current MirPhase within the set of all `MirPhase`s.
170
108
///
0 commit comments