@@ -153,124 +153,3 @@ where
153153 . collect ( )
154154 }
155155}
156-
157- /// Build a stable mir crate from a given crate number.
158- pub ( crate ) fn smir_crate ( tcx : TyCtxt < ' _ > , crate_num : CrateNum ) -> stable_mir:: Crate {
159- let crate_name = tcx. crate_name ( crate_num) . to_string ( ) ;
160- let is_local = crate_num == LOCAL_CRATE ;
161- debug ! ( ?crate_name, ?crate_num, "smir_crate" ) ;
162- stable_mir:: Crate { id : crate_num. into ( ) , name : crate_name, is_local }
163- }
164-
165- pub ( crate ) fn new_item_kind ( kind : DefKind ) -> ItemKind {
166- match kind {
167- DefKind :: Mod
168- | DefKind :: Struct
169- | DefKind :: Union
170- | DefKind :: Enum
171- | DefKind :: Variant
172- | DefKind :: Trait
173- | DefKind :: TyAlias
174- | DefKind :: ForeignTy
175- | DefKind :: TraitAlias
176- | DefKind :: AssocTy
177- | DefKind :: TyParam
178- | DefKind :: ConstParam
179- | DefKind :: Macro ( _)
180- | DefKind :: ExternCrate
181- | DefKind :: Use
182- | DefKind :: ForeignMod
183- | DefKind :: OpaqueTy
184- | DefKind :: Field
185- | DefKind :: LifetimeParam
186- | DefKind :: Impl { .. }
187- | DefKind :: GlobalAsm => {
188- unreachable ! ( "Not a valid item kind: {kind:?}" ) ;
189- }
190- DefKind :: Closure | DefKind :: AssocFn | DefKind :: Fn | DefKind :: SyntheticCoroutineBody => {
191- ItemKind :: Fn
192- }
193- DefKind :: Const | DefKind :: InlineConst | DefKind :: AssocConst | DefKind :: AnonConst => {
194- ItemKind :: Const
195- }
196- DefKind :: Static { .. } => ItemKind :: Static ,
197- DefKind :: Ctor ( _, rustc_hir:: def:: CtorKind :: Const ) => ItemKind :: Ctor ( CtorKind :: Const ) ,
198- DefKind :: Ctor ( _, rustc_hir:: def:: CtorKind :: Fn ) => ItemKind :: Ctor ( CtorKind :: Fn ) ,
199- }
200- }
201-
202- /// Trait used to convert between an internal MIR type to a Stable MIR type.
203- pub trait Stable < ' cx > {
204- /// The stable representation of the type implementing Stable.
205- type T ;
206- /// Converts an object to the equivalent Stable MIR representation.
207- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T ;
208- }
209-
210- impl < ' tcx , T > Stable < ' tcx > for & T
211- where
212- T : Stable < ' tcx > ,
213- {
214- type T = T :: T ;
215-
216- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T {
217- ( * self ) . stable ( tables)
218- }
219- }
220-
221- impl < ' tcx , T > Stable < ' tcx > for Option < T >
222- where
223- T : Stable < ' tcx > ,
224- {
225- type T = Option < T :: T > ;
226-
227- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T {
228- self . as_ref ( ) . map ( |value| value. stable ( tables) )
229- }
230- }
231-
232- impl < ' tcx , T , E > Stable < ' tcx > for Result < T , E >
233- where
234- T : Stable < ' tcx > ,
235- E : Stable < ' tcx > ,
236- {
237- type T = Result < T :: T , E :: T > ;
238-
239- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T {
240- match self {
241- Ok ( val) => Ok ( val. stable ( tables) ) ,
242- Err ( error) => Err ( error. stable ( tables) ) ,
243- }
244- }
245- }
246-
247- impl < ' tcx , T > Stable < ' tcx > for & [ T ]
248- where
249- T : Stable < ' tcx > ,
250- {
251- type T = Vec < T :: T > ;
252- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T {
253- self . iter ( ) . map ( |e| e. stable ( tables) ) . collect ( )
254- }
255- }
256-
257- impl < ' tcx , T , U > Stable < ' tcx > for ( T , U )
258- where
259- T : Stable < ' tcx > ,
260- U : Stable < ' tcx > ,
261- {
262- type T = ( T :: T , U :: T ) ;
263- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T {
264- ( self . 0 . stable ( tables) , self . 1 . stable ( tables) )
265- }
266- }
267-
268- impl < ' tcx , T > Stable < ' tcx > for RangeInclusive < T >
269- where
270- T : Stable < ' tcx > ,
271- {
272- type T = RangeInclusive < T :: T > ;
273- fn stable ( & self , tables : & mut Tables < ' _ > ) -> Self :: T {
274- RangeInclusive :: new ( self . start ( ) . stable ( tables) , self . end ( ) . stable ( tables) )
275- }
276- }
0 commit comments