@@ -18,7 +18,10 @@ use rustc_middle::ty::{self, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, Variance
18
18
use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
19
19
use rustc_target:: abi:: FieldIdx ;
20
20
use 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
+ } ;
22
25
use stable_mir:: ty:: {
23
26
AdtDef , AdtKind , ClosureDef , ClosureKind , Const , ConstId , ConstantKind , EarlyParamRegion ,
24
27
FloatTy , FnDef , GenericArgs , GenericParamDef , IntTy , LineInfo , Movability , RigidTy , Span ,
@@ -69,15 +72,13 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
69
72
70
73
fn get_filename ( & self , span : & Span ) -> Filename {
71
74
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 ( )
81
82
}
82
83
83
84
fn get_lines ( & self , span : & Span ) -> LineInfo {
@@ -444,17 +445,67 @@ impl<'tcx> Stable<'tcx> for mir::Body<'tcx> {
444
445
} )
445
446
. collect ( ) ,
446
447
self . arg_count ,
448
+ self . var_debug_info . iter ( ) . map ( |info| info. stable ( tables) ) . collect ( ) ,
447
449
)
448
450
}
449
451
}
450
452
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
+
451
466
impl < ' tcx > Stable < ' tcx > for mir:: Statement < ' tcx > {
452
467
type T = stable_mir:: mir:: Statement ;
453
468
fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
454
469
Statement { kind : self . kind . stable ( tables) , span : self . source_info . span . stable ( tables) }
455
470
}
456
471
}
457
472
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
+
458
509
impl < ' tcx > Stable < ' tcx > for mir:: StatementKind < ' tcx > {
459
510
type T = stable_mir:: mir:: StatementKind ;
460
511
fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
0 commit comments