@@ -15,7 +15,7 @@ use rustc_middle::mir::interpret::{alloc_range, AllocId};
15
15
use rustc_middle:: ty:: { self , Ty , TyCtxt , Variance } ;
16
16
use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
17
17
use rustc_target:: abi:: FieldIdx ;
18
- use stable_mir:: mir:: { CopyNonOverlapping , UserTypeProjection , VariantIdx } ;
18
+ use stable_mir:: mir:: { CopyNonOverlapping , Statement , UserTypeProjection , VariantIdx } ;
19
19
use stable_mir:: ty:: { FloatTy , GenericParamDef , IntTy , Movability , RigidTy , Span , TyKind , UintTy } ;
20
20
use stable_mir:: { self , opaque, Context } ;
21
21
use tracing:: debug;
@@ -231,40 +231,71 @@ impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
231
231
type T = stable_mir:: mir:: Statement ;
232
232
fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
233
233
use rustc_middle:: mir:: StatementKind :: * ;
234
+ let span = self . source_info . span . stable ( tables) ;
234
235
match & self . kind {
235
- Assign ( assign) => {
236
- stable_mir:: mir:: Statement :: Assign ( assign. 0 . stable ( tables) , assign. 1 . stable ( tables) )
237
- }
238
- FakeRead ( fake_read_place) => stable_mir:: mir:: Statement :: FakeRead (
239
- fake_read_place. 0 . stable ( tables) ,
240
- fake_read_place. 1 . stable ( tables) ,
241
- ) ,
242
- SetDiscriminant { place : plc, variant_index : idx } => {
243
- stable_mir:: mir:: Statement :: SetDiscriminant {
236
+ Assign ( assign) => Statement {
237
+ kind : stable_mir:: mir:: StatementKind :: Assign (
238
+ assign. 0 . stable ( tables) ,
239
+ assign. 1 . stable ( tables) ,
240
+ ) ,
241
+ span,
242
+ } ,
243
+ FakeRead ( fake_read_place) => Statement {
244
+ kind : stable_mir:: mir:: StatementKind :: FakeRead (
245
+ fake_read_place. 0 . stable ( tables) ,
246
+ fake_read_place. 1 . stable ( tables) ,
247
+ ) ,
248
+ span,
249
+ } ,
250
+ SetDiscriminant { place : plc, variant_index : idx } => Statement {
251
+ kind : stable_mir:: mir:: StatementKind :: SetDiscriminant {
244
252
place : plc. as_ref ( ) . stable ( tables) ,
245
253
variant_index : idx. stable ( tables) ,
246
- }
247
- }
248
- Deinit ( place) => stable_mir:: mir:: Statement :: Deinit ( place. stable ( tables) ) ,
249
- StorageLive ( place) => stable_mir:: mir:: Statement :: StorageLive ( place. stable ( tables) ) ,
250
- StorageDead ( place) => stable_mir:: mir:: Statement :: StorageDead ( place. stable ( tables) ) ,
251
- Retag ( retag, place) => {
252
- stable_mir:: mir:: Statement :: Retag ( retag. stable ( tables) , place. stable ( tables) )
253
- }
254
- PlaceMention ( place) => stable_mir:: mir:: Statement :: PlaceMention ( place. stable ( tables) ) ,
255
- AscribeUserType ( place_projection, variance) => {
256
- stable_mir:: mir:: Statement :: AscribeUserType {
254
+ } ,
255
+ span,
256
+ } ,
257
+ Deinit ( place) => Statement {
258
+ kind : stable_mir:: mir:: StatementKind :: Deinit ( place. stable ( tables) ) ,
259
+ span,
260
+ } ,
261
+ StorageLive ( place) => Statement {
262
+ kind : stable_mir:: mir:: StatementKind :: StorageLive ( place. stable ( tables) ) ,
263
+ span,
264
+ } ,
265
+ StorageDead ( place) => Statement {
266
+ kind : stable_mir:: mir:: StatementKind :: StorageDead ( place. stable ( tables) ) ,
267
+ span,
268
+ } ,
269
+ Retag ( retag, place) => Statement {
270
+ kind : stable_mir:: mir:: StatementKind :: Retag (
271
+ retag. stable ( tables) ,
272
+ place. stable ( tables) ,
273
+ ) ,
274
+ span,
275
+ } ,
276
+ PlaceMention ( place) => Statement {
277
+ kind : stable_mir:: mir:: StatementKind :: PlaceMention ( place. stable ( tables) ) ,
278
+ span,
279
+ } ,
280
+ AscribeUserType ( place_projection, variance) => Statement {
281
+ kind : stable_mir:: mir:: StatementKind :: AscribeUserType {
257
282
place : place_projection. as_ref ( ) . 0 . stable ( tables) ,
258
283
projections : place_projection. as_ref ( ) . 1 . stable ( tables) ,
259
284
variance : variance. stable ( tables) ,
260
- }
285
+ } ,
286
+ span,
287
+ } ,
288
+ Coverage ( coverage) => {
289
+ Statement { kind : stable_mir:: mir:: StatementKind :: Coverage ( opaque ( coverage) ) , span }
261
290
}
262
- Coverage ( coverage) => stable_mir:: mir:: Statement :: Coverage ( opaque ( coverage) ) ,
263
- Intrinsic ( intrinstic) => {
264
- stable_mir:: mir:: Statement :: Intrinsic ( intrinstic. stable ( tables) )
291
+ Intrinsic ( intrinstic) => Statement {
292
+ kind : stable_mir:: mir:: StatementKind :: Intrinsic ( intrinstic. stable ( tables) ) ,
293
+ span,
294
+ } ,
295
+ ConstEvalCounter => {
296
+ Statement { kind : stable_mir:: mir:: StatementKind :: ConstEvalCounter , span }
265
297
}
266
- ConstEvalCounter => stable_mir:: mir:: Statement :: ConstEvalCounter ,
267
- Nop => stable_mir:: mir:: Statement :: Nop ,
298
+ Nop => Statement { kind : stable_mir:: mir:: StatementKind :: Nop , span } ,
268
299
}
269
300
}
270
301
}
@@ -816,11 +847,11 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
816
847
use rustc_middle:: mir:: TerminatorKind :: * ;
817
848
use stable_mir:: mir:: Terminator ;
818
849
use stable_mir:: mir:: TerminatorKind ;
850
+ let span = self . source_info . span . stable ( tables) ;
819
851
match & self . kind {
820
- Goto { target } => Terminator {
821
- kind : TerminatorKind :: Goto { target : target. as_usize ( ) } ,
822
- span : self . source_info . span . stable ( tables) ,
823
- } ,
852
+ Goto { target } => {
853
+ Terminator { kind : TerminatorKind :: Goto { target : target. as_usize ( ) } , span }
854
+ }
824
855
SwitchInt { discr, targets } => Terminator {
825
856
kind : TerminatorKind :: SwitchInt {
826
857
discr : discr. stable ( tables) ,
@@ -833,31 +864,19 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
833
864
. collect ( ) ,
834
865
otherwise : targets. otherwise ( ) . as_usize ( ) ,
835
866
} ,
836
- span : self . source_info . span . stable ( tables) ,
837
- } ,
838
- UnwindResume => Terminator {
839
- kind : TerminatorKind :: Resume ,
840
- span : self . source_info . span . stable ( tables) ,
841
- } ,
842
- UnwindTerminate ( _) => Terminator {
843
- kind : TerminatorKind :: Abort ,
844
- span : self . source_info . span . stable ( tables) ,
845
- } ,
846
- Return => Terminator {
847
- kind : TerminatorKind :: Return ,
848
- span : self . source_info . span . stable ( tables) ,
849
- } ,
850
- Unreachable => Terminator {
851
- kind : TerminatorKind :: Unreachable ,
852
- span : self . source_info . span . stable ( tables) ,
867
+ span,
853
868
} ,
869
+ UnwindResume => Terminator { kind : TerminatorKind :: Resume , span } ,
870
+ UnwindTerminate ( _) => Terminator { kind : TerminatorKind :: Abort , span } ,
871
+ Return => Terminator { kind : TerminatorKind :: Return , span } ,
872
+ Unreachable => Terminator { kind : TerminatorKind :: Unreachable , span } ,
854
873
Drop { place, target, unwind, replace : _ } => Terminator {
855
874
kind : TerminatorKind :: Drop {
856
875
place : place. stable ( tables) ,
857
876
target : target. as_usize ( ) ,
858
877
unwind : unwind. stable ( tables) ,
859
878
} ,
860
- span : self . source_info . span . stable ( tables ) ,
879
+ span,
861
880
} ,
862
881
Call { func, args, destination, target, unwind, call_source : _, fn_span : _ } => {
863
882
Terminator {
@@ -868,7 +887,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
868
887
target : target. map ( |t| t. as_usize ( ) ) ,
869
888
unwind : unwind. stable ( tables) ,
870
889
} ,
871
- span : self . source_info . span . stable ( tables ) ,
890
+ span,
872
891
}
873
892
}
874
893
Assert { cond, expected, msg, target, unwind } => Terminator {
@@ -879,7 +898,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
879
898
target : target. as_usize ( ) ,
880
899
unwind : unwind. stable ( tables) ,
881
900
} ,
882
- span : self . source_info . span . stable ( tables ) ,
901
+ span,
883
902
} ,
884
903
InlineAsm { template, operands, options, line_spans, destination, unwind } => {
885
904
Terminator {
@@ -891,7 +910,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
891
910
destination : destination. map ( |d| d. as_usize ( ) ) ,
892
911
unwind : unwind. stable ( tables) ,
893
912
} ,
894
- span : self . source_info . span . stable ( tables ) ,
913
+ span,
895
914
}
896
915
}
897
916
Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable ! ( ) ,
0 commit comments