@@ -16,12 +16,12 @@ use rustc_middle::ty::TyCtxt;
16
16
use rustc_span:: Span ;
17
17
use rustc_span:: def_id:: { CrateNum , DefId } ;
18
18
use scoped_tls:: scoped_thread_local;
19
- use stable_mir:: Error ;
20
- use stable_mir:: abi:: Layout ;
21
- use stable_mir:: ty:: IndexedVal ;
22
19
23
20
use crate :: rustc_smir:: context:: TablesWrapper ;
24
21
use crate :: rustc_smir:: { Stable , Tables } ;
22
+ use crate :: stable_mir:: Error ;
23
+ use crate :: stable_mir:: abi:: Layout ;
24
+ use crate :: stable_mir:: ty:: IndexedVal ;
25
25
26
26
mod internal;
27
27
pub mod pretty;
@@ -60,126 +60,135 @@ where
60
60
with_tables ( |tables| item. internal ( tables, tcx) )
61
61
}
62
62
63
- impl < ' tcx > Index < stable_mir:: DefId > for Tables < ' tcx > {
63
+ impl < ' tcx > Index < crate :: stable_mir:: DefId > for Tables < ' tcx > {
64
64
type Output = DefId ;
65
65
66
66
#[ inline( always) ]
67
- fn index ( & self , index : stable_mir:: DefId ) -> & Self :: Output {
67
+ fn index ( & self , index : crate :: stable_mir:: DefId ) -> & Self :: Output {
68
68
& self . def_ids [ index]
69
69
}
70
70
}
71
71
72
- impl < ' tcx > Index < stable_mir:: ty:: Span > for Tables < ' tcx > {
72
+ impl < ' tcx > Index < crate :: stable_mir:: ty:: Span > for Tables < ' tcx > {
73
73
type Output = Span ;
74
74
75
75
#[ inline( always) ]
76
- fn index ( & self , index : stable_mir:: ty:: Span ) -> & Self :: Output {
76
+ fn index ( & self , index : crate :: stable_mir:: ty:: Span ) -> & Self :: Output {
77
77
& self . spans [ index]
78
78
}
79
79
}
80
80
81
81
impl < ' tcx > Tables < ' tcx > {
82
- pub fn crate_item ( & mut self , did : DefId ) -> stable_mir:: CrateItem {
83
- stable_mir:: CrateItem ( self . create_def_id ( did) )
82
+ pub fn crate_item ( & mut self , did : DefId ) -> crate :: stable_mir:: CrateItem {
83
+ crate :: stable_mir:: CrateItem ( self . create_def_id ( did) )
84
84
}
85
85
86
- pub fn adt_def ( & mut self , did : DefId ) -> stable_mir:: ty:: AdtDef {
87
- stable_mir:: ty:: AdtDef ( self . create_def_id ( did) )
86
+ pub fn adt_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: AdtDef {
87
+ crate :: stable_mir:: ty:: AdtDef ( self . create_def_id ( did) )
88
88
}
89
89
90
- pub fn foreign_module_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ForeignModuleDef {
91
- stable_mir:: ty:: ForeignModuleDef ( self . create_def_id ( did) )
90
+ pub fn foreign_module_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: ForeignModuleDef {
91
+ crate :: stable_mir:: ty:: ForeignModuleDef ( self . create_def_id ( did) )
92
92
}
93
93
94
- pub fn foreign_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ForeignDef {
95
- stable_mir:: ty:: ForeignDef ( self . create_def_id ( did) )
94
+ pub fn foreign_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: ForeignDef {
95
+ crate :: stable_mir:: ty:: ForeignDef ( self . create_def_id ( did) )
96
96
}
97
97
98
- pub fn fn_def ( & mut self , did : DefId ) -> stable_mir:: ty:: FnDef {
99
- stable_mir:: ty:: FnDef ( self . create_def_id ( did) )
98
+ pub fn fn_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: FnDef {
99
+ crate :: stable_mir:: ty:: FnDef ( self . create_def_id ( did) )
100
100
}
101
101
102
- pub fn closure_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ClosureDef {
103
- stable_mir:: ty:: ClosureDef ( self . create_def_id ( did) )
102
+ pub fn closure_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: ClosureDef {
103
+ crate :: stable_mir:: ty:: ClosureDef ( self . create_def_id ( did) )
104
104
}
105
105
106
- pub fn coroutine_def ( & mut self , did : DefId ) -> stable_mir:: ty:: CoroutineDef {
107
- stable_mir:: ty:: CoroutineDef ( self . create_def_id ( did) )
106
+ pub fn coroutine_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: CoroutineDef {
107
+ crate :: stable_mir:: ty:: CoroutineDef ( self . create_def_id ( did) )
108
108
}
109
109
110
- pub fn coroutine_closure_def ( & mut self , did : DefId ) -> stable_mir:: ty:: CoroutineClosureDef {
111
- stable_mir:: ty:: CoroutineClosureDef ( self . create_def_id ( did) )
110
+ pub fn coroutine_closure_def (
111
+ & mut self ,
112
+ did : DefId ,
113
+ ) -> crate :: stable_mir:: ty:: CoroutineClosureDef {
114
+ crate :: stable_mir:: ty:: CoroutineClosureDef ( self . create_def_id ( did) )
112
115
}
113
116
114
- pub fn alias_def ( & mut self , did : DefId ) -> stable_mir:: ty:: AliasDef {
115
- stable_mir:: ty:: AliasDef ( self . create_def_id ( did) )
117
+ pub fn alias_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: AliasDef {
118
+ crate :: stable_mir:: ty:: AliasDef ( self . create_def_id ( did) )
116
119
}
117
120
118
- pub fn param_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ParamDef {
119
- stable_mir:: ty:: ParamDef ( self . create_def_id ( did) )
121
+ pub fn param_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: ParamDef {
122
+ crate :: stable_mir:: ty:: ParamDef ( self . create_def_id ( did) )
120
123
}
121
124
122
- pub fn br_named_def ( & mut self , did : DefId ) -> stable_mir:: ty:: BrNamedDef {
123
- stable_mir:: ty:: BrNamedDef ( self . create_def_id ( did) )
125
+ pub fn br_named_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: BrNamedDef {
126
+ crate :: stable_mir:: ty:: BrNamedDef ( self . create_def_id ( did) )
124
127
}
125
128
126
- pub fn trait_def ( & mut self , did : DefId ) -> stable_mir:: ty:: TraitDef {
127
- stable_mir:: ty:: TraitDef ( self . create_def_id ( did) )
129
+ pub fn trait_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: TraitDef {
130
+ crate :: stable_mir:: ty:: TraitDef ( self . create_def_id ( did) )
128
131
}
129
132
130
- pub fn generic_def ( & mut self , did : DefId ) -> stable_mir:: ty:: GenericDef {
131
- stable_mir:: ty:: GenericDef ( self . create_def_id ( did) )
133
+ pub fn generic_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: GenericDef {
134
+ crate :: stable_mir:: ty:: GenericDef ( self . create_def_id ( did) )
132
135
}
133
136
134
- pub fn const_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ConstDef {
135
- stable_mir:: ty:: ConstDef ( self . create_def_id ( did) )
137
+ pub fn const_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: ConstDef {
138
+ crate :: stable_mir:: ty:: ConstDef ( self . create_def_id ( did) )
136
139
}
137
140
138
- pub fn impl_def ( & mut self , did : DefId ) -> stable_mir:: ty:: ImplDef {
139
- stable_mir:: ty:: ImplDef ( self . create_def_id ( did) )
141
+ pub fn impl_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: ImplDef {
142
+ crate :: stable_mir:: ty:: ImplDef ( self . create_def_id ( did) )
140
143
}
141
144
142
- pub fn region_def ( & mut self , did : DefId ) -> stable_mir:: ty:: RegionDef {
143
- stable_mir:: ty:: RegionDef ( self . create_def_id ( did) )
145
+ pub fn region_def ( & mut self , did : DefId ) -> crate :: stable_mir:: ty:: RegionDef {
146
+ crate :: stable_mir:: ty:: RegionDef ( self . create_def_id ( did) )
144
147
}
145
148
146
- pub fn coroutine_witness_def ( & mut self , did : DefId ) -> stable_mir:: ty:: CoroutineWitnessDef {
147
- stable_mir:: ty:: CoroutineWitnessDef ( self . create_def_id ( did) )
149
+ pub fn coroutine_witness_def (
150
+ & mut self ,
151
+ did : DefId ,
152
+ ) -> crate :: stable_mir:: ty:: CoroutineWitnessDef {
153
+ crate :: stable_mir:: ty:: CoroutineWitnessDef ( self . create_def_id ( did) )
148
154
}
149
155
150
- pub fn prov ( & mut self , aid : AllocId ) -> stable_mir:: ty:: Prov {
151
- stable_mir:: ty:: Prov ( self . create_alloc_id ( aid) )
156
+ pub fn prov ( & mut self , aid : AllocId ) -> crate :: stable_mir:: ty:: Prov {
157
+ crate :: stable_mir:: ty:: Prov ( self . create_alloc_id ( aid) )
152
158
}
153
159
154
- pub ( crate ) fn create_def_id ( & mut self , did : DefId ) -> stable_mir:: DefId {
160
+ pub ( crate ) fn create_def_id ( & mut self , did : DefId ) -> crate :: stable_mir:: DefId {
155
161
self . def_ids . create_or_fetch ( did)
156
162
}
157
163
158
- pub ( crate ) fn create_alloc_id ( & mut self , aid : AllocId ) -> stable_mir:: mir:: alloc:: AllocId {
164
+ pub ( crate ) fn create_alloc_id (
165
+ & mut self ,
166
+ aid : AllocId ,
167
+ ) -> crate :: stable_mir:: mir:: alloc:: AllocId {
159
168
self . alloc_ids . create_or_fetch ( aid)
160
169
}
161
170
162
- pub ( crate ) fn create_span ( & mut self , span : Span ) -> stable_mir:: ty:: Span {
171
+ pub ( crate ) fn create_span ( & mut self , span : Span ) -> crate :: stable_mir:: ty:: Span {
163
172
self . spans . create_or_fetch ( span)
164
173
}
165
174
166
175
pub ( crate ) fn instance_def (
167
176
& mut self ,
168
177
instance : ty:: Instance < ' tcx > ,
169
- ) -> stable_mir:: mir:: mono:: InstanceDef {
178
+ ) -> crate :: stable_mir:: mir:: mono:: InstanceDef {
170
179
self . instances . create_or_fetch ( instance)
171
180
}
172
181
173
- pub ( crate ) fn static_def ( & mut self , did : DefId ) -> stable_mir:: mir:: mono:: StaticDef {
174
- stable_mir:: mir:: mono:: StaticDef ( self . create_def_id ( did) )
182
+ pub ( crate ) fn static_def ( & mut self , did : DefId ) -> crate :: stable_mir:: mir:: mono:: StaticDef {
183
+ crate :: stable_mir:: mir:: mono:: StaticDef ( self . create_def_id ( did) )
175
184
}
176
185
177
186
pub ( crate ) fn layout_id ( & mut self , layout : rustc_abi:: Layout < ' tcx > ) -> Layout {
178
187
self . layouts . create_or_fetch ( layout)
179
188
}
180
189
}
181
190
182
- pub fn crate_num ( item : & stable_mir:: Crate ) -> CrateNum {
191
+ pub fn crate_num ( item : & crate :: stable_mir:: Crate ) -> CrateNum {
183
192
item. id . into ( )
184
193
}
185
194
@@ -224,7 +233,7 @@ where
224
233
mir_consts : IndexMap :: default ( ) ,
225
234
layouts : IndexMap :: default ( ) ,
226
235
} ) ) ;
227
- stable_mir:: compiler_interface:: run ( & tables, || init ( & tables, f) )
236
+ crate :: stable_mir:: compiler_interface:: run ( & tables, || init ( & tables, f) )
228
237
}
229
238
230
239
/// Instantiate and run the compiler with the provided arguments and callback.
@@ -241,7 +250,7 @@ where
241
250
/// #
242
251
/// # fn main() {
243
252
/// # use std::ops::ControlFlow;
244
- /// # use stable_mir::CompilerError;
253
+ /// # use crate:: stable_mir::CompilerError;
245
254
/// fn analyze_code() -> ControlFlow<(), ()> {
246
255
/// // Your code goes in here.
247
256
/// # ControlFlow::Continue(())
@@ -319,7 +328,7 @@ macro_rules! run_driver {
319
328
use rustc_driver:: { Callbacks , Compilation , run_compiler} ;
320
329
use rustc_middle:: ty:: TyCtxt ;
321
330
use rustc_interface:: interface;
322
- use stable_mir:: CompilerError ;
331
+ use crate :: stable_mir:: CompilerError ;
323
332
use std:: ops:: ControlFlow ;
324
333
325
334
pub struct StableMir <B = ( ) , C = ( ) , F = fn ( $( optional!( $with_tcx TyCtxt ) ) ?) -> ControlFlow <B , C >>
0 commit comments