@@ -16,12 +16,12 @@ use rustc_middle::ty::TyCtxt;
1616use rustc_span:: Span ;
1717use rustc_span:: def_id:: { CrateNum , DefId } ;
1818use scoped_tls:: scoped_thread_local;
19- use stable_mir:: Error ;
20- use stable_mir:: abi:: Layout ;
21- use stable_mir:: ty:: IndexedVal ;
2219
2320use crate :: rustc_smir:: context:: TablesWrapper ;
2421use 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 ;
2525
2626mod internal;
2727pub mod pretty;
@@ -60,126 +60,135 @@ where
6060 with_tables ( |tables| item. internal ( tables, tcx) )
6161}
6262
63- impl < ' tcx > Index < stable_mir:: DefId > for Tables < ' tcx > {
63+ impl < ' tcx > Index < crate :: stable_mir:: DefId > for Tables < ' tcx > {
6464 type Output = DefId ;
6565
6666 #[ inline( always) ]
67- fn index ( & self , index : stable_mir:: DefId ) -> & Self :: Output {
67+ fn index ( & self , index : crate :: stable_mir:: DefId ) -> & Self :: Output {
6868 & self . def_ids [ index]
6969 }
7070}
7171
72- impl < ' tcx > Index < stable_mir:: ty:: Span > for Tables < ' tcx > {
72+ impl < ' tcx > Index < crate :: stable_mir:: ty:: Span > for Tables < ' tcx > {
7373 type Output = Span ;
7474
7575 #[ 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 {
7777 & self . spans [ index]
7878 }
7979}
8080
8181impl < ' 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) )
8484 }
8585
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) )
8888 }
8989
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) )
9292 }
9393
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) )
9696 }
9797
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) )
100100 }
101101
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) )
104104 }
105105
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) )
108108 }
109109
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) )
112115 }
113116
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) )
116119 }
117120
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) )
120123 }
121124
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) )
124127 }
125128
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) )
128131 }
129132
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) )
132135 }
133136
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) )
136139 }
137140
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) )
140143 }
141144
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) )
144147 }
145148
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) )
148154 }
149155
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) )
152158 }
153159
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 {
155161 self . def_ids . create_or_fetch ( did)
156162 }
157163
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 {
159168 self . alloc_ids . create_or_fetch ( aid)
160169 }
161170
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 {
163172 self . spans . create_or_fetch ( span)
164173 }
165174
166175 pub ( crate ) fn instance_def (
167176 & mut self ,
168177 instance : ty:: Instance < ' tcx > ,
169- ) -> stable_mir:: mir:: mono:: InstanceDef {
178+ ) -> crate :: stable_mir:: mir:: mono:: InstanceDef {
170179 self . instances . create_or_fetch ( instance)
171180 }
172181
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) )
175184 }
176185
177186 pub ( crate ) fn layout_id ( & mut self , layout : rustc_abi:: Layout < ' tcx > ) -> Layout {
178187 self . layouts . create_or_fetch ( layout)
179188 }
180189}
181190
182- pub fn crate_num ( item : & stable_mir:: Crate ) -> CrateNum {
191+ pub fn crate_num ( item : & crate :: stable_mir:: Crate ) -> CrateNum {
183192 item. id . into ( )
184193}
185194
@@ -224,7 +233,7 @@ where
224233 mir_consts : IndexMap :: default ( ) ,
225234 layouts : IndexMap :: default ( ) ,
226235 } ) ) ;
227- stable_mir:: compiler_interface:: run ( & tables, || init ( & tables, f) )
236+ crate :: stable_mir:: compiler_interface:: run ( & tables, || init ( & tables, f) )
228237}
229238
230239/// Instantiate and run the compiler with the provided arguments and callback.
@@ -237,11 +246,11 @@ where
237246/// # extern crate rustc_interface;
238247/// # #[macro_use]
239248/// # extern crate rustc_smir;
240- /// # extern crate stable_mir;
249+ /// # extern crate crate:: stable_mir;
241250/// #
242251/// # fn main() {
243252/// # use std::ops::ControlFlow;
244- /// # use stable_mir::CompilerError;
253+ /// # use crate:: stable_mir::CompilerError;
245254/// fn analyze_code() -> ControlFlow<(), ()> {
246255/// // Your code goes in here.
247256/// # ControlFlow::Continue(())
@@ -257,11 +266,11 @@ where
257266/// # extern crate rustc_interface;
258267/// # #[macro_use]
259268/// # extern crate rustc_smir;
260- /// # extern crate stable_mir;
269+ /// # extern crate crate:: stable_mir;
261270/// #
262271/// # fn main() {
263272/// # use std::ops::ControlFlow;
264- /// # use stable_mir::CompilerError;
273+ /// # use crate:: stable_mir::CompilerError;
265274/// fn analyze_code(extra_args: Vec<String>) -> ControlFlow<(), ()> {
266275/// # let _ = extra_args;
267276/// // Your code goes in here.
@@ -319,7 +328,7 @@ macro_rules! run_driver {
319328 use rustc_driver:: { Callbacks , Compilation , run_compiler} ;
320329 use rustc_middle:: ty:: TyCtxt ;
321330 use rustc_interface:: interface;
322- use stable_mir:: CompilerError ;
331+ use crate :: stable_mir:: CompilerError ;
323332 use std:: ops:: ControlFlow ;
324333
325334 pub struct StableMir <B = ( ) , C = ( ) , F = fn ( $( optional!( $with_tcx TyCtxt ) ) ?) -> ControlFlow <B , C >>
0 commit comments