1- use  crate :: ty:: { AdtDef ,  ClosureDef ,  Const ,  CoroutineDef ,  GenericArgs ,  Movability ,  Region } ; 
1+ use  crate :: ty:: { AdtDef ,  ClosureDef ,  Const ,  CoroutineDef ,  GenericArgs ,  Movability ,  Region ,   Ty } ; 
22use  crate :: Opaque ; 
3- use  crate :: { ty :: Ty ,   Span } ; 
3+ use  crate :: Span ; 
44
55/// The SMIR representation of a single function. 
66#[ derive( Clone ,  Debug ) ]  
@@ -12,10 +12,10 @@ pub struct Body {
1212    // The first local is the return value pointer, followed by `arg_count` 
1313    // locals for the function arguments, followed by any user-declared 
1414    // variables and temporaries. 
15-     locals :  LocalDecls , 
15+     pub ( super )   locals :  LocalDecls , 
1616
1717    // The number of arguments this function takes. 
18-     arg_count :  usize , 
18+     pub ( super )   arg_count :  usize , 
1919} 
2020
2121impl  Body  { 
@@ -35,7 +35,7 @@ impl Body {
3535
3636    /// Return local that holds this function's return value. 
3737     pub  fn  ret_local ( & self )  -> & LocalDecl  { 
38-         & self . locals [ 0 ] 
38+         & self . locals [ RETURN_LOCAL ] 
3939    } 
4040
4141    /// Locals in `self` that correspond to this function's arguments. 
@@ -60,7 +60,7 @@ impl Body {
6060
6161type  LocalDecls  = Vec < LocalDecl > ; 
6262
63- #[ derive( Clone ,  Debug ) ]  
63+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
6464pub  struct  LocalDecl  { 
6565    pub  ty :  Ty , 
6666    pub  span :  Span , 
@@ -72,13 +72,13 @@ pub struct BasicBlock {
7272    pub  terminator :  Terminator , 
7373} 
7474
75- #[ derive( Clone ,  Debug ) ]  
75+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
7676pub  struct  Terminator  { 
7777    pub  kind :  TerminatorKind , 
7878    pub  span :  Span , 
7979} 
8080
81- #[ derive( Clone ,  Debug ) ]  
81+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
8282pub  enum  TerminatorKind  { 
8383    Goto  { 
8484        target :  usize , 
@@ -122,7 +122,7 @@ pub enum TerminatorKind {
122122    } , 
123123} 
124124
125- #[ derive( Clone ,  Debug ) ]  
125+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
126126pub  struct  InlineAsmOperand  { 
127127    pub  in_value :  Option < Operand > , 
128128    pub  out_place :  Option < Place > , 
@@ -131,15 +131,15 @@ pub struct InlineAsmOperand {
131131    pub  raw_rpr :  String , 
132132} 
133133
134- #[ derive( Clone ,  Debug ) ]  
134+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
135135pub  enum  UnwindAction  { 
136136    Continue , 
137137    Unreachable , 
138138    Terminate , 
139139    Cleanup ( usize ) , 
140140} 
141141
142- #[ derive( Clone ,  Debug ) ]  
142+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
143143pub  enum  AssertMessage  { 
144144    BoundsCheck  {  len :  Operand ,  index :  Operand  } , 
145145    Overflow ( BinOp ,  Operand ,  Operand ) , 
@@ -151,7 +151,7 @@ pub enum AssertMessage {
151151    MisalignedPointerDereference  {  required :  Operand ,  found :  Operand  } , 
152152} 
153153
154- #[ derive( Clone ,  Debug ) ]  
154+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
155155pub  enum  BinOp  { 
156156    Add , 
157157    AddUnchecked , 
@@ -177,20 +177,20 @@ pub enum BinOp {
177177    Offset , 
178178} 
179179
180- #[ derive( Clone ,  Debug ) ]  
180+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
181181pub  enum  UnOp  { 
182182    Not , 
183183    Neg , 
184184} 
185185
186- #[ derive( Clone ,  Debug ) ]  
186+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
187187pub  enum  CoroutineKind  { 
188188    Async ( CoroutineSource ) , 
189189    Coroutine , 
190190    Gen ( CoroutineSource ) , 
191191} 
192192
193- #[ derive( Clone ,  Debug ) ]  
193+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
194194pub  enum  CoroutineSource  { 
195195    Block , 
196196    Closure , 
@@ -204,7 +204,7 @@ pub(crate) type LocalDefId = Opaque;
204204pub ( crate )  type  Coverage  = Opaque ; 
205205
206206/// The FakeReadCause describes the type of pattern why a FakeRead statement exists. 
207- #[ derive( Clone ,  Debug ) ]  
207+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
208208pub  enum  FakeReadCause  { 
209209    ForMatchGuard , 
210210    ForMatchedPlace ( LocalDefId ) , 
@@ -214,42 +214,42 @@ pub enum FakeReadCause {
214214} 
215215
216216/// Describes what kind of retag is to be performed 
217- #[ derive( Clone ,  Debug ) ]  
217+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ,   Hash ) ]  
218218pub  enum  RetagKind  { 
219219    FnEntry , 
220220    TwoPhase , 
221221    Raw , 
222222    Default , 
223223} 
224224
225- #[ derive( Clone ,  Debug ) ]  
225+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ,   Hash ) ]  
226226pub  enum  Variance  { 
227227    Covariant , 
228228    Invariant , 
229229    Contravariant , 
230230    Bivariant , 
231231} 
232232
233- #[ derive( Clone ,  Debug ) ]  
233+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
234234pub  struct  CopyNonOverlapping  { 
235235    pub  src :  Operand , 
236236    pub  dst :  Operand , 
237237    pub  count :  Operand , 
238238} 
239239
240- #[ derive( Clone ,  Debug ) ]  
240+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
241241pub  enum  NonDivergingIntrinsic  { 
242242    Assume ( Operand ) , 
243243    CopyNonOverlapping ( CopyNonOverlapping ) , 
244244} 
245245
246- #[ derive( Clone ,  Debug ) ]  
246+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
247247pub  struct  Statement  { 
248248    pub  kind :  StatementKind , 
249249    pub  span :  Span , 
250250} 
251251
252- #[ derive( Clone ,  Debug ) ]  
252+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
253253pub  enum  StatementKind  { 
254254    Assign ( Place ,  Rvalue ) , 
255255    FakeRead ( FakeReadCause ,  Place ) , 
@@ -266,7 +266,7 @@ pub enum StatementKind {
266266    Nop , 
267267} 
268268
269- #[ derive( Clone ,  Debug ) ]  
269+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
270270pub  enum  Rvalue  { 
271271    /// Creates a pointer with the indicated mutability to the place. 
272272     /// 
@@ -378,7 +378,7 @@ pub enum Rvalue {
378378     Use ( Operand ) , 
379379} 
380380
381- #[ derive( Clone ,  Debug ) ]  
381+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
382382pub  enum  AggregateKind  { 
383383    Array ( Ty ) , 
384384    Tuple , 
@@ -387,49 +387,51 @@ pub enum AggregateKind {
387387    Coroutine ( CoroutineDef ,  GenericArgs ,  Movability ) , 
388388} 
389389
390- #[ derive( Clone ,  Debug ) ]  
390+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
391391pub  enum  Operand  { 
392392    Copy ( Place ) , 
393393    Move ( Place ) , 
394394    Constant ( Constant ) , 
395395} 
396396
397- #[ derive( Clone ,  Debug ) ]  
397+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
398398pub  struct  Place  { 
399399    pub  local :  Local , 
400400    /// projection out of a place (access a field, deref a pointer, etc) 
401401     pub  projection :  String , 
402402} 
403403
404- #[ derive( Clone ,  Debug ) ]  
404+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
405405pub  struct  UserTypeProjection  { 
406406    pub  base :  UserTypeAnnotationIndex , 
407407    pub  projection :  String , 
408408} 
409409
410410pub  type  Local  = usize ; 
411411
412+ pub  const  RETURN_LOCAL :  Local  = 0 ; 
413+ 
412414type  FieldIdx  = usize ; 
413415
414416/// The source-order index of a variant in a type. 
415417pub  type  VariantIdx  = usize ; 
416418
417419type  UserTypeAnnotationIndex  = usize ; 
418420
419- #[ derive( Clone ,  Debug ) ]  
421+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
420422pub  struct  Constant  { 
421423    pub  span :  Span , 
422424    pub  user_ty :  Option < UserTypeAnnotationIndex > , 
423425    pub  literal :  Const , 
424426} 
425427
426- #[ derive( Clone ,  Debug ) ]  
428+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
427429pub  struct  SwitchTarget  { 
428430    pub  value :  u128 , 
429431    pub  target :  usize , 
430432} 
431433
432- #[ derive( Clone ,  Debug ) ]  
434+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
433435pub  enum  BorrowKind  { 
434436    /// Data must be immutable and is aliasable. 
435437     Shared , 
@@ -446,26 +448,26 @@ pub enum BorrowKind {
446448    } , 
447449} 
448450
449- #[ derive( Clone ,  Debug ) ]  
451+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
450452pub  enum  MutBorrowKind  { 
451453    Default , 
452454    TwoPhaseBorrow , 
453455    ClosureCapture , 
454456} 
455457
456- #[ derive( Clone ,  Debug ) ]  
458+ #[ derive( Clone ,  Debug ,   PartialEq ,   Eq ) ]  
457459pub  enum  Mutability  { 
458460    Not , 
459461    Mut , 
460462} 
461463
462- #[ derive( Copy ,  Clone ,  Debug ) ]  
464+ #[ derive( Copy ,  Clone ,  Debug ,   Eq ,   PartialEq ) ]  
463465pub  enum  Safety  { 
464466    Unsafe , 
465467    Normal , 
466468} 
467469
468- #[ derive( Clone ,  Debug ) ]  
470+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
469471pub  enum  PointerCoercion  { 
470472    /// Go from a fn-item type to a fn-pointer type. 
471473     ReifyFnPointer , 
@@ -492,7 +494,7 @@ pub enum PointerCoercion {
492494     Unsize , 
493495} 
494496
495- #[ derive( Clone ,  Debug ) ]  
497+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
496498pub  enum  CastKind  { 
497499    PointerExposeAddress , 
498500    PointerFromExposedAddress , 
@@ -507,7 +509,7 @@ pub enum CastKind {
507509    Transmute , 
508510} 
509511
510- #[ derive( Clone ,  Debug ) ]  
512+ #[ derive( Clone ,  Debug ,   Eq ,   PartialEq ) ]  
511513pub  enum  NullOp  { 
512514    /// Returns the size of a value of that type. 
513515     SizeOf , 
0 commit comments