@@ -230,72 +230,64 @@ pub(crate) trait Stable<'tcx> {
230230impl < ' tcx > Stable < ' tcx > for mir:: Statement < ' tcx > {
231231 type T = stable_mir:: mir:: Statement ;
232232 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
233- use rustc_middle:: mir:: StatementKind :: * ;
234- let span = self . source_info . span . stable ( tables) ;
235- match & self . kind {
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 (
233+ Statement { kind : self . kind . stable ( tables) , span : self . source_info . span . stable ( tables) }
234+ }
235+ }
236+
237+ impl < ' tcx > Stable < ' tcx > for mir:: StatementKind < ' tcx > {
238+ type T = stable_mir:: mir:: StatementKind ;
239+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
240+ match self {
241+ mir:: StatementKind :: Assign ( assign) => stable_mir:: mir:: StatementKind :: Assign (
242+ assign. 0 . stable ( tables) ,
243+ assign. 1 . stable ( tables) ,
244+ ) ,
245+ mir:: StatementKind :: FakeRead ( fake_read_place) => {
246+ stable_mir:: mir:: StatementKind :: FakeRead (
245247 fake_read_place. 0 . stable ( tables) ,
246248 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 {
252- place : plc. as_ref ( ) . stable ( tables) ,
253- variant_index : idx. stable ( tables) ,
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 {
249+ )
250+ }
251+ mir:: StatementKind :: SetDiscriminant { place, variant_index } => {
252+ stable_mir:: mir:: StatementKind :: SetDiscriminant {
253+ place : place. as_ref ( ) . stable ( tables) ,
254+ variant_index : variant_index. stable ( tables) ,
255+ }
256+ }
257+ mir:: StatementKind :: Deinit ( place) => {
258+ stable_mir:: mir:: StatementKind :: Deinit ( place. stable ( tables) )
259+ }
260+
261+ mir:: StatementKind :: StorageLive ( place) => {
262+ stable_mir:: mir:: StatementKind :: StorageLive ( place. stable ( tables) )
263+ }
264+
265+ mir:: StatementKind :: StorageDead ( place) => {
266+ stable_mir:: mir:: StatementKind :: StorageDead ( place. stable ( tables) )
267+ }
268+ mir:: StatementKind :: Retag ( retag, place) => {
269+ stable_mir:: mir:: StatementKind :: Retag ( retag. stable ( tables) , place. stable ( tables) )
270+ }
271+ mir:: StatementKind :: PlaceMention ( place) => {
272+ stable_mir:: mir:: StatementKind :: PlaceMention ( place. stable ( tables) )
273+ }
274+ mir:: StatementKind :: AscribeUserType ( place_projection, variance) => {
275+ stable_mir:: mir:: StatementKind :: AscribeUserType {
282276 place : place_projection. as_ref ( ) . 0 . stable ( tables) ,
283277 projections : place_projection. as_ref ( ) . 1 . stable ( tables) ,
284278 variance : variance. stable ( tables) ,
285- } ,
286- span,
287- } ,
288- Coverage ( coverage) => {
289- Statement { kind : stable_mir:: mir:: StatementKind :: Coverage ( opaque ( coverage) ) , span }
279+ }
290280 }
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 }
281+ mir:: StatementKind :: Coverage ( coverage) => {
282+ stable_mir:: mir:: StatementKind :: Coverage ( opaque ( coverage) )
283+ }
284+ mir:: StatementKind :: Intrinsic ( intrinstic) => {
285+ stable_mir:: mir:: StatementKind :: Intrinsic ( intrinstic. stable ( tables) )
286+ }
287+ mir:: StatementKind :: ConstEvalCounter => {
288+ stable_mir:: mir:: StatementKind :: ConstEvalCounter
297289 }
298- Nop => Statement { kind : stable_mir:: mir:: StatementKind :: Nop , span } ,
290+ mir :: StatementKind :: Nop => stable_mir:: mir:: StatementKind :: Nop ,
299291 }
300292 }
301293}
@@ -844,76 +836,84 @@ impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> {
844836impl < ' tcx > Stable < ' tcx > for mir:: Terminator < ' tcx > {
845837 type T = stable_mir:: mir:: Terminator ;
846838 fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
847- use rustc_middle:: mir:: TerminatorKind :: * ;
848839 use stable_mir:: mir:: Terminator ;
840+ Terminator { kind : self . kind . stable ( tables) , span : self . source_info . span . stable ( tables) }
841+ }
842+ }
843+
844+ impl < ' tcx > Stable < ' tcx > for mir:: TerminatorKind < ' tcx > {
845+ type T = stable_mir:: mir:: TerminatorKind ;
846+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
849847 use stable_mir:: mir:: TerminatorKind ;
850- let span = self . source_info . span . stable ( tables) ;
851- match & self . kind {
852- Goto { target } => {
853- Terminator { kind : TerminatorKind :: Goto { target : target. as_usize ( ) } , span }
854- }
855- SwitchInt { discr, targets } => Terminator {
856- kind : TerminatorKind :: SwitchInt {
857- discr : discr. stable ( tables) ,
858- targets : targets
859- . iter ( )
860- . map ( |( value, target) | stable_mir:: mir:: SwitchTarget {
861- value,
862- target : target. as_usize ( ) ,
863- } )
864- . collect ( ) ,
865- otherwise : targets. otherwise ( ) . as_usize ( ) ,
866- } ,
867- span,
848+ match self {
849+ mir:: TerminatorKind :: Goto { target } => {
850+ TerminatorKind :: Goto { target : target. as_usize ( ) }
851+ }
852+ mir:: TerminatorKind :: SwitchInt { discr, targets } => TerminatorKind :: SwitchInt {
853+ discr : discr. stable ( tables) ,
854+ targets : targets
855+ . iter ( )
856+ . map ( |( value, target) | stable_mir:: mir:: SwitchTarget {
857+ value,
858+ target : target. as_usize ( ) ,
859+ } )
860+ . collect ( ) ,
861+ otherwise : targets. otherwise ( ) . as_usize ( ) ,
868862 } ,
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 } ,
873- Drop { place, target, unwind, replace : _ } => Terminator {
874- kind : TerminatorKind :: Drop {
863+ mir :: TerminatorKind :: UnwindResume => TerminatorKind :: Resume ,
864+ mir :: TerminatorKind :: UnwindTerminate ( _) => TerminatorKind :: Abort ,
865+ mir :: TerminatorKind :: Return => TerminatorKind :: Return ,
866+ mir :: TerminatorKind :: Unreachable => TerminatorKind :: Unreachable ,
867+ mir :: TerminatorKind :: Drop { place, target, unwind, replace : _ } => {
868+ TerminatorKind :: Drop {
875869 place : place. stable ( tables) ,
876870 target : target. as_usize ( ) ,
877871 unwind : unwind. stable ( tables) ,
878- } ,
879- span,
880- } ,
881- Call { func, args, destination, target, unwind, call_source : _, fn_span : _ } => {
882- Terminator {
883- kind : TerminatorKind :: Call {
884- func : func. stable ( tables) ,
885- args : args. iter ( ) . map ( |arg| arg. stable ( tables) ) . collect ( ) ,
886- destination : destination. stable ( tables) ,
887- target : target. map ( |t| t. as_usize ( ) ) ,
888- unwind : unwind. stable ( tables) ,
889- } ,
890- span,
891872 }
892873 }
893- Assert { cond, expected, msg, target, unwind } => Terminator {
894- kind : TerminatorKind :: Assert {
874+ mir:: TerminatorKind :: Call {
875+ func,
876+ args,
877+ destination,
878+ target,
879+ unwind,
880+ call_source : _,
881+ fn_span : _,
882+ } => TerminatorKind :: Call {
883+ func : func. stable ( tables) ,
884+ args : args. iter ( ) . map ( |arg| arg. stable ( tables) ) . collect ( ) ,
885+ destination : destination. stable ( tables) ,
886+ target : target. map ( |t| t. as_usize ( ) ) ,
887+ unwind : unwind. stable ( tables) ,
888+ } ,
889+ mir:: TerminatorKind :: Assert { cond, expected, msg, target, unwind } => {
890+ TerminatorKind :: Assert {
895891 cond : cond. stable ( tables) ,
896892 expected : * expected,
897893 msg : msg. stable ( tables) ,
898894 target : target. as_usize ( ) ,
899895 unwind : unwind. stable ( tables) ,
900- } ,
901- span,
902- } ,
903- InlineAsm { template, operands, options, line_spans, destination, unwind } => {
904- Terminator {
905- kind : TerminatorKind :: InlineAsm {
906- template : format ! ( "{template:?}" ) ,
907- operands : operands. iter ( ) . map ( |operand| operand. stable ( tables) ) . collect ( ) ,
908- options : format ! ( "{options:?}" ) ,
909- line_spans : format ! ( "{line_spans:?}" ) ,
910- destination : destination. map ( |d| d. as_usize ( ) ) ,
911- unwind : unwind. stable ( tables) ,
912- } ,
913- span,
914896 }
915897 }
916- Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable ! ( ) ,
898+ mir:: TerminatorKind :: InlineAsm {
899+ template,
900+ operands,
901+ options,
902+ line_spans,
903+ destination,
904+ unwind,
905+ } => TerminatorKind :: InlineAsm {
906+ template : format ! ( "{template:?}" ) ,
907+ operands : operands. iter ( ) . map ( |operand| operand. stable ( tables) ) . collect ( ) ,
908+ options : format ! ( "{options:?}" ) ,
909+ line_spans : format ! ( "{line_spans:?}" ) ,
910+ destination : destination. map ( |d| d. as_usize ( ) ) ,
911+ unwind : unwind. stable ( tables) ,
912+ } ,
913+ mir:: TerminatorKind :: Yield { .. }
914+ | mir:: TerminatorKind :: GeneratorDrop
915+ | mir:: TerminatorKind :: FalseEdge { .. }
916+ | mir:: TerminatorKind :: FalseUnwind { .. } => unreachable ! ( ) ,
917917 }
918918 }
919919}
0 commit comments