@@ -18,9 +18,10 @@ use rustc_span::def_id::{CrateNum, DefId};
18
18
use scoped_tls:: scoped_thread_local;
19
19
use stable_mir:: Error ;
20
20
use stable_mir:: abi:: Layout ;
21
+ use stable_mir:: compiler_interface:: SmirInterface ;
21
22
use stable_mir:: ty:: IndexedVal ;
22
23
23
- use crate :: rustc_smir:: context:: TablesWrapper ;
24
+ use crate :: rustc_smir:: context:: Context ;
24
25
use crate :: rustc_smir:: { Stable , Tables } ;
25
26
use crate :: stable_mir;
26
27
@@ -196,12 +197,12 @@ pub fn crate_num(item: &stable_mir::Crate) -> CrateNum {
196
197
// datastructures and stable MIR datastructures
197
198
scoped_thread_local ! ( static TLV : Cell <* const ( ) >) ;
198
199
199
- pub ( crate ) fn init < ' tcx , F , T > ( tables : & TablesWrapper < ' tcx > , f : F ) -> T
200
+ pub ( crate ) fn init < ' tcx , F , T > ( cx : & Context < ' tcx > , f : F ) -> T
200
201
where
201
202
F : FnOnce ( ) -> T ,
202
203
{
203
204
assert ! ( !TLV . is_set( ) ) ;
204
- let ptr = tables as * const _ as * const ( ) ;
205
+ let ptr = cx as * const _ as * const ( ) ;
205
206
TLV . set ( & Cell :: new ( ptr) , || f ( ) )
206
207
}
207
208
@@ -212,8 +213,8 @@ pub(crate) fn with_tables<R>(f: impl for<'tcx> FnOnce(&mut Tables<'tcx>) -> R) -
212
213
TLV . with ( |tlv| {
213
214
let ptr = tlv. get ( ) ;
214
215
assert ! ( !ptr. is_null( ) ) ;
215
- let wrapper = ptr as * const TablesWrapper < ' _ > ;
216
- let mut tables = unsafe { ( * wrapper ) . 0 . borrow_mut ( ) } ;
216
+ let context = ptr as * const Context < ' _ > ;
217
+ let mut tables = unsafe { ( * context ) . 0 . borrow_mut ( ) } ;
217
218
f ( & mut * tables)
218
219
} )
219
220
}
@@ -222,7 +223,7 @@ pub fn run<F, T>(tcx: TyCtxt<'_>, f: F) -> Result<T, Error>
222
223
where
223
224
F : FnOnce ( ) -> T ,
224
225
{
225
- let tables = TablesWrapper ( RefCell :: new ( Tables {
226
+ let tables = Context ( RefCell :: new ( Tables {
226
227
tcx,
227
228
def_ids : IndexMap :: default ( ) ,
228
229
alloc_ids : IndexMap :: default ( ) ,
@@ -233,7 +234,12 @@ where
233
234
mir_consts : IndexMap :: default ( ) ,
234
235
layouts : IndexMap :: default ( ) ,
235
236
} ) ) ;
236
- stable_mir:: compiler_interface:: run ( & tables, || init ( & tables, f) )
237
+
238
+ let interface = SmirInterface { cx : tables } ;
239
+
240
+ // Pass the `SmirInterface` to compiler_interface::run
241
+ // and initialize the rustc-specific TLS with tables.
242
+ stable_mir:: compiler_interface:: run ( & interface, || init ( & interface. cx , f) )
237
243
}
238
244
239
245
/// Instantiate and run the compiler with the provided arguments and callback.
0 commit comments