@@ -21,6 +21,7 @@ use std::fmt::{Debug, Formatter, Error};
21
21
use std:: u32;
22
22
23
23
/// Lowered representation of a single function.
24
+ #[ derive( RustcEncodable , RustcDecodable ) ]
24
25
pub struct Mir < ' tcx > {
25
26
/// List of basic blocks. References to basic block use a newtyped index type `BasicBlock`
26
27
/// that indexes into this vector.
@@ -71,13 +72,13 @@ impl<'tcx> Mir<'tcx> {
71
72
///////////////////////////////////////////////////////////////////////////
72
73
// Mutability and borrow kinds
73
74
74
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
75
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
75
76
pub enum Mutability {
76
77
Mut ,
77
78
Not ,
78
79
}
79
80
80
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
81
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
81
82
pub enum BorrowKind {
82
83
/// Data must be immutable and is aliasable.
83
84
Shared ,
@@ -128,6 +129,7 @@ pub enum BorrowKind {
128
129
129
130
// A "variable" is a binding declared by the user as part of the fn
130
131
// decl, a let, etc.
132
+ #[ derive( RustcEncodable , RustcDecodable ) ]
131
133
pub struct VarDecl < ' tcx > {
132
134
pub mutability : Mutability ,
133
135
pub name : Name ,
@@ -136,6 +138,7 @@ pub struct VarDecl<'tcx> {
136
138
137
139
// A "temp" is a temporary that we place on the stack. They are
138
140
// anonymous, always mutable, and have only a type.
141
+ #[ derive( RustcEncodable , RustcDecodable ) ]
139
142
pub struct TempDecl < ' tcx > {
140
143
pub ty : Ty < ' tcx > ,
141
144
}
@@ -151,6 +154,7 @@ pub struct TempDecl<'tcx> {
151
154
//
152
155
// there is only one argument, of type `(i32, u32)`, but two bindings
153
156
// (`x` and `y`).
157
+ #[ derive( RustcEncodable , RustcDecodable ) ]
154
158
pub struct ArgDecl < ' tcx > {
155
159
pub ty : Ty < ' tcx > ,
156
160
}
@@ -162,7 +166,7 @@ pub struct ArgDecl<'tcx> {
162
166
/// list of the `Mir`.
163
167
///
164
168
/// (We use a `u32` internally just to save memory.)
165
- #[ derive( Copy , Clone , PartialEq , Eq ) ]
169
+ #[ derive( Copy , Clone , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
166
170
pub struct BasicBlock ( u32 ) ;
167
171
168
172
impl BasicBlock {
@@ -186,12 +190,13 @@ impl Debug for BasicBlock {
186
190
///////////////////////////////////////////////////////////////////////////
187
191
// BasicBlock and Terminator
188
192
189
- #[ derive( Debug ) ]
193
+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
190
194
pub struct BasicBlockData < ' tcx > {
191
195
pub statements : Vec < Statement < ' tcx > > ,
192
196
pub terminator : Terminator < ' tcx > ,
193
197
}
194
198
199
+ #[ derive( RustcEncodable , RustcDecodable ) ]
195
200
pub enum Terminator < ' tcx > {
196
201
/// block should have one successor in the graph; we jump there
197
202
Goto {
@@ -289,7 +294,7 @@ impl<'tcx> Terminator<'tcx> {
289
294
}
290
295
}
291
296
292
- #[ derive( Debug ) ]
297
+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
293
298
pub struct CallData < ' tcx > {
294
299
/// where the return value is written to
295
300
pub destination : Lvalue < ' tcx > ,
@@ -346,18 +351,19 @@ impl<'tcx> Debug for Terminator<'tcx> {
346
351
///////////////////////////////////////////////////////////////////////////
347
352
// Statements
348
353
354
+ #[ derive( RustcEncodable , RustcDecodable ) ]
349
355
pub struct Statement < ' tcx > {
350
356
pub span : Span ,
351
357
pub kind : StatementKind < ' tcx > ,
352
358
}
353
359
354
- #[ derive( Debug ) ]
360
+ #[ derive( Debug , RustcEncodable , RustcDecodable ) ]
355
361
pub enum StatementKind < ' tcx > {
356
362
Assign ( Lvalue < ' tcx > , Rvalue < ' tcx > ) ,
357
363
Drop ( DropKind , Lvalue < ' tcx > ) ,
358
364
}
359
365
360
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
366
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
361
367
pub enum DropKind {
362
368
Free , // free a partially constructed box, should go away eventually
363
369
Deep
@@ -378,7 +384,7 @@ impl<'tcx> Debug for Statement<'tcx> {
378
384
379
385
/// A path to a value; something that can be evaluated without
380
386
/// changing or disturbing program state.
381
- #[ derive( Clone , PartialEq ) ]
387
+ #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable ) ]
382
388
pub enum Lvalue < ' tcx > {
383
389
/// local variable declared by the user
384
390
Var ( u32 ) ,
@@ -404,13 +410,13 @@ pub enum Lvalue<'tcx> {
404
410
/// or `*B` or `B[index]`. Note that it is parameterized because it is
405
411
/// shared between `Constant` and `Lvalue`. See the aliases
406
412
/// `LvalueProjection` etc below.
407
- #[ derive( Clone , Debug , PartialEq ) ]
413
+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
408
414
pub struct Projection < ' tcx , B , V > {
409
415
pub base : B ,
410
416
pub elem : ProjectionElem < ' tcx , V > ,
411
417
}
412
418
413
- #[ derive( Clone , Debug , PartialEq ) ]
419
+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
414
420
pub enum ProjectionElem < ' tcx , V > {
415
421
Deref ,
416
422
Field ( Field ) ,
@@ -448,7 +454,7 @@ pub type LvalueElem<'tcx> =
448
454
ProjectionElem < ' tcx , Operand < ' tcx > > ;
449
455
450
456
/// 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 ) ]
452
458
pub struct Field ( u32 ) ;
453
459
454
460
impl Field {
@@ -524,7 +530,7 @@ impl<'tcx> Debug for Lvalue<'tcx> {
524
530
// lvalue). They are intentionally limited to prevent rvalues from
525
531
// being nested in one another.
526
532
527
- #[ derive( Clone , PartialEq ) ]
533
+ #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable ) ]
528
534
pub enum Operand < ' tcx > {
529
535
Consume ( Lvalue < ' tcx > ) ,
530
536
Constant ( Constant < ' tcx > ) ,
@@ -543,7 +549,7 @@ impl<'tcx> Debug for Operand<'tcx> {
543
549
///////////////////////////////////////////////////////////////////////////
544
550
// Rvalues
545
551
546
- #[ derive( Clone ) ]
552
+ #[ derive( Clone , RustcEncodable , RustcDecodable ) ]
547
553
pub enum Rvalue < ' tcx > {
548
554
// x (either a move or copy, depending on type of x)
549
555
Use ( Operand < ' tcx > ) ,
@@ -587,7 +593,7 @@ pub enum Rvalue<'tcx> {
587
593
InlineAsm ( InlineAsm ) ,
588
594
}
589
595
590
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
596
+ #[ derive( Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
591
597
pub enum CastKind {
592
598
Misc ,
593
599
@@ -605,15 +611,15 @@ pub enum CastKind {
605
611
Unsize ,
606
612
}
607
613
608
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
614
+ #[ derive( Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
609
615
pub enum AggregateKind < ' tcx > {
610
616
Vec ,
611
617
Tuple ,
612
618
Adt ( AdtDef < ' tcx > , usize , & ' tcx Substs < ' tcx > ) ,
613
619
Closure ( DefId , & ' tcx ClosureSubsts < ' tcx > ) ,
614
620
}
615
621
616
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
622
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
617
623
pub enum BinOp {
618
624
/// The `+` operator (addition)
619
625
Add ,
@@ -649,7 +655,7 @@ pub enum BinOp {
649
655
Gt ,
650
656
}
651
657
652
- #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
658
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , RustcEncodable , RustcDecodable ) ]
653
659
pub enum UnOp {
654
660
/// The `!` operator for logical inversion
655
661
Not ,
@@ -685,14 +691,14 @@ impl<'tcx> Debug for Rvalue<'tcx> {
685
691
// this does not necessarily mean that they are "==" in Rust -- in
686
692
// particular one must be wary of `NaN`!
687
693
688
- #[ derive( Clone , Debug , PartialEq ) ]
694
+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
689
695
pub struct Constant < ' tcx > {
690
696
pub span : Span ,
691
697
pub ty : Ty < ' tcx > ,
692
698
pub literal : Literal < ' tcx > ,
693
699
}
694
700
695
- #[ derive( Clone , Debug , PartialEq ) ]
701
+ #[ derive( Clone , Debug , PartialEq , RustcEncodable , RustcDecodable ) ]
696
702
pub enum Literal < ' tcx > {
697
703
Item {
698
704
def_id : DefId ,
0 commit comments