@@ -18,7 +18,10 @@ use rustc_middle::ty::{self, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, Variance
1818use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
1919use rustc_target:: abi:: FieldIdx ;
2020use stable_mir:: mir:: mono:: InstanceDef ;
21- use stable_mir:: mir:: { Body , CopyNonOverlapping , Statement , UserTypeProjection , VariantIdx } ;
21+ use stable_mir:: mir:: {
22+ Body , ConstOperand , CopyNonOverlapping , Statement , UserTypeProjection , VarDebugInfoFragment ,
23+ VariantIdx ,
24+ } ;
2225use stable_mir:: ty:: {
2326 AdtDef , AdtKind , ClosureDef , ClosureKind , Const , ConstId , ConstantKind , EarlyParamRegion ,
2427 FloatTy , FnDef , GenericArgs , GenericParamDef , IntTy , LineInfo , Movability , RigidTy , Span ,
@@ -69,15 +72,13 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
6972
7073 fn get_filename ( & self , span : & Span ) -> Filename {
7174 let tables = self . 0 . borrow ( ) ;
72- opaque (
73- & tables
74- . tcx
75- . sess
76- . source_map ( )
77- . span_to_filename ( tables[ * span] )
78- . display ( rustc_span:: FileNameDisplayPreference :: Local )
79- . to_string ( ) ,
80- )
75+ tables
76+ . tcx
77+ . sess
78+ . source_map ( )
79+ . span_to_filename ( tables[ * span] )
80+ . display ( rustc_span:: FileNameDisplayPreference :: Local )
81+ . to_string ( )
8182 }
8283
8384 fn get_lines ( & self , span : & Span ) -> LineInfo {
@@ -444,17 +445,67 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
444445 } )
445446 . collect ( ) ,
446447 self . arg_count ,
448+ self . var_debug_info . iter ( ) . map ( |info| info. stable ( tables) ) . collect ( ) ,
447449 )
448450 }
449451}
450452
453+ impl < ' tcx > Stable < ' tcx > for mir:: VarDebugInfo < ' tcx > {
454+ type T = stable_mir:: mir:: VarDebugInfo ;
455+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
456+ stable_mir:: mir:: VarDebugInfo {
457+ name : self . name . to_string ( ) ,
458+ source_info : self . source_info . stable ( tables) ,
459+ composite : self . composite . as_ref ( ) . map ( |composite| composite. stable ( tables) ) ,
460+ value : self . value . stable ( tables) ,
461+ argument_index : self . argument_index ,
462+ }
463+ }
464+ }
465+
451466impl < ' tcx > Stable < ' tcx > for mir:: Statement < ' tcx > {
452467 type T = stable_mir:: mir:: Statement ;
453468 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
454469 Statement { kind : self . kind . stable ( tables) , span : self . source_info . span . stable ( tables) }
455470 }
456471}
457472
473+ impl < ' tcx > Stable < ' tcx > for mir:: SourceInfo {
474+ type T = stable_mir:: mir:: SourceInfo ;
475+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
476+ stable_mir:: mir:: SourceInfo { span : self . span . stable ( tables) , scope : self . scope . into ( ) }
477+ }
478+ }
479+
480+ impl < ' tcx > Stable < ' tcx > for mir:: VarDebugInfoFragment < ' tcx > {
481+ type T = stable_mir:: mir:: VarDebugInfoFragment ;
482+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
483+ VarDebugInfoFragment {
484+ ty : self . ty . stable ( tables) ,
485+ projection : self . projection . iter ( ) . map ( |e| e. stable ( tables) ) . collect ( ) ,
486+ }
487+ }
488+ }
489+
490+ impl < ' tcx > Stable < ' tcx > for mir:: VarDebugInfoContents < ' tcx > {
491+ type T = stable_mir:: mir:: VarDebugInfoContents ;
492+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
493+ match self {
494+ mir:: VarDebugInfoContents :: Place ( place) => {
495+ stable_mir:: mir:: VarDebugInfoContents :: Place ( place. stable ( tables) )
496+ }
497+ mir:: VarDebugInfoContents :: Const ( const_operand) => {
498+ let op = ConstOperand {
499+ span : const_operand. span . stable ( tables) ,
500+ user_ty : const_operand. user_ty . map ( |index| index. as_usize ( ) ) ,
501+ const_ : const_operand. const_ . stable ( tables) ,
502+ } ;
503+ stable_mir:: mir:: VarDebugInfoContents :: Const ( op)
504+ }
505+ }
506+ }
507+ }
508+
458509impl < ' tcx > Stable < ' tcx > for mir:: StatementKind < ' tcx > {
459510 type T = stable_mir:: mir:: StatementKind ;
460511 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
0 commit comments