@@ -21,6 +21,7 @@ use std::fmt::{Debug, Formatter, Error};
2121use std:: u32;
2222
2323/// Lowered representation of a single function.
24+ #[ derive( RustcEncodable , RustcDecodable ) ]
2425pub struct Mir < ' tcx > {
2526 /// List of basic blocks. References to basic block use a newtyped index type `BasicBlock`
2627 /// that indexes into this vector.
@@ -71,13 +72,13 @@ impl<'tcx> Mir<'tcx> {
7172///////////////////////////////////////////////////////////////////////////
7273// Mutability and borrow kinds
7374
74- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
75+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
7576pub enum Mutability {
7677 Mut ,
7778 Not ,
7879}
7980
80- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
81+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
8182pub enum BorrowKind {
8283 /// Data must be immutable and is aliasable.
8384 Shared ,
@@ -128,6 +129,7 @@ pub enum BorrowKind {
128129
129130// A "variable" is a binding declared by the user as part of the fn
130131// decl, a let, etc.
132+ #[ derive( RustcEncodable , RustcDecodable ) ]
131133pub struct VarDecl < ' tcx > {
132134 pub mutability : Mutability ,
133135 pub name : Name ,
@@ -136,6 +138,7 @@ pub struct VarDecl<'tcx> {
136138
137139// A "temp" is a temporary that we place on the stack. They are
138140// anonymous, always mutable, and have only a type.
141+ #[ derive( RustcEncodable , RustcDecodable ) ]
139142pub struct TempDecl < ' tcx > {
140143 pub ty : Ty < ' tcx > ,
141144}
@@ -151,6 +154,7 @@ pub struct TempDecl<'tcx> {
151154//
152155// there is only one argument, of type `(i32, u32)`, but two bindings
153156// (`x` and `y`).
157+ #[ derive( RustcEncodable , RustcDecodable ) ]
154158pub struct ArgDecl < ' tcx > {
155159 pub ty : Ty < ' tcx > ,
156160}
@@ -162,7 +166,7 @@ pub struct ArgDecl<'tcx> {
162166/// list of the `Mir`.
163167///
164168/// (We use a `u32` internally just to save memory.)
165- #[ derive( Copy , Clone , PartialEq , Eq ) ]
169+ #[ derive( Copy , Clone , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
166170pub struct BasicBlock ( u32 ) ;
167171
168172impl BasicBlock {
@@ -186,12 +190,13 @@ impl Debug for BasicBlock {
186190///////////////////////////////////////////////////////////////////////////
187191// BasicBlock and Terminator
188192
189- #[ derive( Debug ) ]
193+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
190194pub struct BasicBlockData < ' tcx > {
191195 pub statements : Vec < Statement < ' tcx > > ,
192196 pub terminator : Terminator < ' tcx > ,
193197}
194198
199+ #[ derive( RustcEncodable , RustcDecodable ) ]
195200pub enum Terminator < ' tcx > {
196201 /// block should have one successor in the graph; we jump there
197202 Goto {
@@ -289,7 +294,7 @@ impl<'tcx> Terminator<'tcx> {
289294 }
290295}
291296
292- #[ derive( Debug ) ]
297+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
293298pub struct CallData < ' tcx > {
294299 /// where the return value is written to
295300 pub destination : Lvalue < ' tcx > ,
@@ -346,18 +351,19 @@ impl<'tcx> Debug for Terminator<'tcx> {
346351///////////////////////////////////////////////////////////////////////////
347352// Statements
348353
354+ #[ derive( RustcEncodable , RustcDecodable ) ]
349355pub struct Statement < ' tcx > {
350356 pub span : Span ,
351357 pub kind : StatementKind < ' tcx > ,
352358}
353359
354- #[ derive( Debug ) ]
360+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
355361pub enum StatementKind < ' tcx > {
356362 Assign ( Lvalue < ' tcx > , Rvalue < ' tcx > ) ,
357363 Drop ( DropKind , Lvalue < ' tcx > ) ,
358364}
359365
360- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
366+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
361367pub enum DropKind {
362368 Free , // free a partially constructed box, should go away eventually
363369 Deep
@@ -378,7 +384,7 @@ impl<'tcx> Debug for Statement<'tcx> {
378384
379385/// A path to a value; something that can be evaluated without
380386/// changing or disturbing program state.
381- #[ derive( Clone , PartialEq ) ]
387+ #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable ) ]
382388pub enum Lvalue < ' tcx > {
383389 /// local variable declared by the user
384390 Var ( u32 ) ,
@@ -404,13 +410,13 @@ pub enum Lvalue<'tcx> {
404410/// or `*B` or `B[index]`. Note that it is parameterized because it is
405411/// shared between `Constant` and `Lvalue`. See the aliases
406412/// `LvalueProjection` etc below.
407- #[ derive( Clone , Debug , PartialEq ) ]
413+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
408414pub struct Projection < ' tcx , B , V > {
409415 pub base : B ,
410416 pub elem : ProjectionElem < ' tcx , V > ,
411417}
412418
413- #[ derive( Clone , Debug , PartialEq ) ]
419+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
414420pub enum ProjectionElem < ' tcx , V > {
415421 Deref ,
416422 Field ( Field ) ,
@@ -448,7 +454,7 @@ pub type LvalueElem<'tcx> =
448454 ProjectionElem < ' tcx , Operand < ' tcx > > ;
449455
450456/// Index into the list of fields found in a `VariantDef`
451- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
457+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
452458pub struct Field ( u32 ) ;
453459
454460impl Field {
@@ -524,7 +530,7 @@ impl<'tcx> Debug for Lvalue<'tcx> {
524530// lvalue). They are intentionally limited to prevent rvalues from
525531// being nested in one another.
526532
527- #[ derive( Clone , PartialEq ) ]
533+ #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable ) ]
528534pub enum Operand < ' tcx > {
529535 Consume ( Lvalue < ' tcx > ) ,
530536 Constant ( Constant < ' tcx > ) ,
@@ -543,7 +549,7 @@ impl<'tcx> Debug for Operand<'tcx> {
543549///////////////////////////////////////////////////////////////////////////
544550// Rvalues
545551
546- #[ derive( Clone ) ]
552+ #[ derive( Clone , RustcEncodable , RustcDecodable ) ]
547553pub enum Rvalue < ' tcx > {
548554 // x (either a move or copy, depending on type of x)
549555 Use ( Operand < ' tcx > ) ,
@@ -587,7 +593,7 @@ pub enum Rvalue<'tcx> {
587593 InlineAsm ( InlineAsm ) ,
588594}
589595
590- #[ derive( Clone , Debug , PartialEq , Eq ) ]
596+ #[ derive( Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
591597pub enum CastKind {
592598 Misc ,
593599
@@ -605,15 +611,15 @@ pub enum CastKind {
605611 Unsize ,
606612}
607613
608- #[ derive( Clone , Debug , PartialEq , Eq ) ]
614+ #[ derive( Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
609615pub enum AggregateKind < ' tcx > {
610616 Vec ,
611617 Tuple ,
612618 Adt ( AdtDef < ' tcx > , usize , & ' tcx Substs < ' tcx > ) ,
613619 Closure ( DefId , & ' tcx ClosureSubsts < ' tcx > ) ,
614620}
615621
616- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
622+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
617623pub enum BinOp {
618624 /// The `+` operator (addition)
619625 Add ,
@@ -649,7 +655,7 @@ pub enum BinOp {
649655 Gt ,
650656}
651657
652- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
658+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
653659pub enum UnOp {
654660 /// The `!` operator for logical inversion
655661 Not ,
@@ -685,14 +691,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
685691// this does not necessarily mean that they are "==" in Rust -- in
686692// particular one must be wary of `NaN`!
687693
688- #[ derive( Clone , Debug , PartialEq ) ]
694+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
689695pub struct Constant < ' tcx > {
690696 pub span : Span ,
691697 pub ty : Ty < ' tcx > ,
692698 pub literal : Literal < ' tcx > ,
693699}
694700
695- #[ derive( Clone , Debug , PartialEq ) ]
701+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
696702pub enum Literal < ' tcx > {
697703 Item {
698704 def_id : DefId ,
0 commit comments