@@ -15,7 +15,7 @@ use rustc_middle::mir::interpret::{alloc_range, AllocId};
1515use rustc_middle:: ty:: { self , Ty , TyCtxt , Variance } ;
1616use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
1717use rustc_target:: abi:: FieldIdx ;
18- use stable_mir:: mir:: { CopyNonOverlapping , UserTypeProjection , VariantIdx } ;
18+ use stable_mir:: mir:: { CopyNonOverlapping , Statement , UserTypeProjection , VariantIdx } ;
1919use stable_mir:: ty:: { FloatTy , GenericParamDef , IntTy , Movability , RigidTy , Span , TyKind , UintTy } ;
2020use stable_mir:: { self , opaque, Context } ;
2121use tracing:: debug;
@@ -231,40 +231,71 @@ impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
231231 type T = stable_mir:: mir:: Statement ;
232232 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
233233 use rustc_middle:: mir:: StatementKind :: * ;
234+ let span = self . source_info . span . stable ( tables) ;
234235 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 {
244252 place : plc. as_ref ( ) . stable ( tables) ,
245253 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 {
257282 place : place_projection. as_ref ( ) . 0 . stable ( tables) ,
258283 projections : place_projection. as_ref ( ) . 1 . stable ( tables) ,
259284 variance : variance. stable ( tables) ,
260- }
285+ } ,
286+ span,
287+ } ,
288+ Coverage ( coverage) => {
289+ Statement { kind : stable_mir:: mir:: StatementKind :: Coverage ( opaque ( coverage) ) , span }
261290 }
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 }
265297 }
266- ConstEvalCounter => stable_mir:: mir:: Statement :: ConstEvalCounter ,
267- Nop => stable_mir:: mir:: Statement :: Nop ,
298+ Nop => Statement { kind : stable_mir:: mir:: StatementKind :: Nop , span } ,
268299 }
269300 }
270301}
@@ -816,11 +847,11 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
816847 use rustc_middle:: mir:: TerminatorKind :: * ;
817848 use stable_mir:: mir:: Terminator ;
818849 use stable_mir:: mir:: TerminatorKind ;
850+ let span = self . source_info . span . stable ( tables) ;
819851 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+ }
824855 SwitchInt { discr, targets } => Terminator {
825856 kind : TerminatorKind :: SwitchInt {
826857 discr : discr. stable ( tables) ,
@@ -833,31 +864,19 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
833864 . collect ( ) ,
834865 otherwise : targets. otherwise ( ) . as_usize ( ) ,
835866 } ,
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,
853868 } ,
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 } ,
854873 Drop { place, target, unwind, replace : _ } => Terminator {
855874 kind : TerminatorKind :: Drop {
856875 place : place. stable ( tables) ,
857876 target : target. as_usize ( ) ,
858877 unwind : unwind. stable ( tables) ,
859878 } ,
860- span : self . source_info . span . stable ( tables ) ,
879+ span,
861880 } ,
862881 Call { func, args, destination, target, unwind, call_source : _, fn_span : _ } => {
863882 Terminator {
@@ -868,7 +887,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
868887 target : target. map ( |t| t. as_usize ( ) ) ,
869888 unwind : unwind. stable ( tables) ,
870889 } ,
871- span : self . source_info . span . stable ( tables ) ,
890+ span,
872891 }
873892 }
874893 Assert { cond, expected, msg, target, unwind } => Terminator {
@@ -879,7 +898,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
879898 target : target. as_usize ( ) ,
880899 unwind : unwind. stable ( tables) ,
881900 } ,
882- span : self . source_info . span . stable ( tables ) ,
901+ span,
883902 } ,
884903 InlineAsm { template, operands, options, line_spans, destination, unwind } => {
885904 Terminator {
@@ -891,7 +910,7 @@ impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
891910 destination : destination. map ( |d| d. as_usize ( ) ) ,
892911 unwind : unwind. stable ( tables) ,
893912 } ,
894- span : self . source_info . span . stable ( tables ) ,
913+ span,
895914 }
896915 }
897916 Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable ! ( ) ,
0 commit comments