@@ -180,6 +180,27 @@ impl<'tcx> Mir<'tcx> {
180
180
Some ( Local :: new ( idx) )
181
181
}
182
182
183
+ pub fn from_local_index_to_temp ( & self , local : Local ) -> Option < Temp > {
184
+ let num_args_and_vars = self . arg_decls . len ( ) + self . var_decls . len ( ) ;
185
+ if local. index ( ) < num_args_and_vars {
186
+ None
187
+ } else if local. index ( ) >= num_args_and_vars + self . temp_decls . len ( ) {
188
+ None
189
+ } else {
190
+ Some ( Temp :: new ( local. index ( ) - num_args_and_vars) )
191
+ }
192
+ }
193
+ pub fn from_local_index_to_var ( & self , local : Local ) -> Option < Var > {
194
+ let num_args = self . arg_decls . len ( ) ;
195
+ if local. index ( ) < num_args {
196
+ None
197
+ } else if local. index ( ) >= num_args + self . var_decls . len ( ) {
198
+ None
199
+ } else {
200
+ Some ( Var :: new ( local. index ( ) - num_args) )
201
+ }
202
+ }
203
+
183
204
/// Counts the number of locals, such that that local_index
184
205
/// will always return an index smaller than this count.
185
206
pub fn count_locals ( & self ) -> usize {
@@ -680,13 +701,13 @@ pub enum AssertMessage<'tcx> {
680
701
///////////////////////////////////////////////////////////////////////////
681
702
// Statements
682
703
683
- #[ derive( Clone , RustcEncodable , RustcDecodable ) ]
704
+ #[ derive( Clone , RustcEncodable , RustcDecodable , Eq , PartialEq ) ]
684
705
pub struct Statement < ' tcx > {
685
706
pub source_info : SourceInfo ,
686
707
pub kind : StatementKind < ' tcx > ,
687
708
}
688
709
689
- #[ derive( Clone , Debug , RustcEncodable , RustcDecodable ) ]
710
+ #[ derive( Clone , Debug , RustcEncodable , RustcDecodable , Eq , PartialEq ) ]
690
711
pub enum StatementKind < ' tcx > {
691
712
Assign ( Lvalue < ' tcx > , Rvalue < ' tcx > ) ,
692
713
}
@@ -710,7 +731,7 @@ newtype_index!(Local, "local");
710
731
711
732
/// A path to a value; something that can be evaluated without
712
733
/// changing or disturbing program state.
713
- #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable ) ]
734
+ #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable , Eq , Hash ) ]
714
735
pub enum Lvalue < ' tcx > {
715
736
/// local variable declared by the user
716
737
Var ( Var ) ,
@@ -868,7 +889,7 @@ pub struct VisibilityScopeData {
868
889
/// These are values that can appear inside an rvalue (or an index
869
890
/// lvalue). They are intentionally limited to prevent rvalues from
870
891
/// being nested in one another.
871
- #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable ) ]
892
+ #[ derive( Clone , PartialEq , RustcEncodable , RustcDecodable , Eq , Hash ) ]
872
893
pub enum Operand < ' tcx > {
873
894
Consume ( Lvalue < ' tcx > ) ,
874
895
Constant ( Constant < ' tcx > ) ,
@@ -887,7 +908,7 @@ impl<'tcx> Debug for Operand<'tcx> {
887
908
///////////////////////////////////////////////////////////////////////////
888
909
/// Rvalues
889
910
890
- #[ derive( Clone , RustcEncodable , RustcDecodable ) ]
911
+ #[ derive( Clone , RustcEncodable , RustcDecodable , Eq , PartialEq ) ]
891
912
pub enum Rvalue < ' tcx > {
892
913
/// x (either a move or copy, depending on type of x)
893
914
Use ( Operand < ' tcx > ) ,
@@ -1113,7 +1134,7 @@ pub struct Constant<'tcx> {
1113
1134
pub literal : Literal < ' tcx > ,
1114
1135
}
1115
1136
1116
- #[ derive( Clone , RustcEncodable , RustcDecodable ) ]
1137
+ #[ derive( Clone , RustcEncodable , RustcDecodable , Eq , PartialEq ) ]
1117
1138
pub struct TypedConstVal < ' tcx > {
1118
1139
pub ty : Ty < ' tcx > ,
1119
1140
pub span : Span ,
0 commit comments