@@ -48,27 +48,27 @@ pub enum Constant {
4848impl PartialEq for Constant {
4949 fn eq ( & self , other : & Self ) -> bool {
5050 match ( self , other) {
51- ( & Constant :: Str ( ref ls) , & Constant :: Str ( ref rs) ) => ls == rs,
52- ( & Constant :: Binary ( ref l) , & Constant :: Binary ( ref r) ) => l == r,
53- ( & Constant :: Char ( l) , & Constant :: Char ( r) ) => l == r,
54- ( & Constant :: Int ( l) , & Constant :: Int ( r) ) => l == r,
55- ( & Constant :: F64 ( l) , & Constant :: F64 ( r) ) => {
51+ ( & Self :: Str ( ref ls) , & Self :: Str ( ref rs) ) => ls == rs,
52+ ( & Self :: Binary ( ref l) , & Self :: Binary ( ref r) ) => l == r,
53+ ( & Self :: Char ( l) , & Self :: Char ( r) ) => l == r,
54+ ( & Self :: Int ( l) , & Self :: Int ( r) ) => l == r,
55+ ( & Self :: F64 ( l) , & Self :: F64 ( r) ) => {
5656 // We want `Fw32 == FwAny` and `FwAny == Fw64`, and by transitivity we must have
5757 // `Fw32 == Fw64`, so don’t compare them.
5858 // `to_bits` is required to catch non-matching 0.0, -0.0, and NaNs.
5959 l. to_bits ( ) == r. to_bits ( )
6060 } ,
61- ( & Constant :: F32 ( l) , & Constant :: F32 ( r) ) => {
61+ ( & Self :: F32 ( l) , & Self :: F32 ( r) ) => {
6262 // We want `Fw32 == FwAny` and `FwAny == Fw64`, and by transitivity we must have
6363 // `Fw32 == Fw64`, so don’t compare them.
6464 // `to_bits` is required to catch non-matching 0.0, -0.0, and NaNs.
6565 f64:: from ( l) . to_bits ( ) == f64:: from ( r) . to_bits ( )
6666 } ,
67- ( & Constant :: Bool ( l) , & Constant :: Bool ( r) ) => l == r,
68- ( & Constant :: Vec ( ref l) , & Constant :: Vec ( ref r) ) | ( & Constant :: Tuple ( ref l) , & Constant :: Tuple ( ref r) ) => {
67+ ( & Self :: Bool ( l) , & Self :: Bool ( r) ) => l == r,
68+ ( & Self :: Vec ( ref l) , & Self :: Vec ( ref r) ) | ( & Self :: Tuple ( ref l) , & Self :: Tuple ( ref r) ) => {
6969 l == r
7070 } ,
71- ( & Constant :: Repeat ( ref lv, ref ls) , & Constant :: Repeat ( ref rv, ref rs) ) => ls == rs && lv == rv,
71+ ( & Self :: Repeat ( ref lv, ref ls) , & Self :: Repeat ( ref rv, ref rs) ) => ls == rs && lv == rv,
7272 // TODO: are there inter-type equalities?
7373 _ => false ,
7474 }
@@ -82,38 +82,38 @@ impl Hash for Constant {
8282 {
8383 std:: mem:: discriminant ( self ) . hash ( state) ;
8484 match * self {
85- Constant :: Str ( ref s) => {
85+ Self :: Str ( ref s) => {
8686 s. hash ( state) ;
8787 } ,
88- Constant :: Binary ( ref b) => {
88+ Self :: Binary ( ref b) => {
8989 b. hash ( state) ;
9090 } ,
91- Constant :: Char ( c) => {
91+ Self :: Char ( c) => {
9292 c. hash ( state) ;
9393 } ,
94- Constant :: Int ( i) => {
94+ Self :: Int ( i) => {
9595 i. hash ( state) ;
9696 } ,
97- Constant :: F32 ( f) => {
97+ Self :: F32 ( f) => {
9898 f64:: from ( f) . to_bits ( ) . hash ( state) ;
9999 } ,
100- Constant :: F64 ( f) => {
100+ Self :: F64 ( f) => {
101101 f. to_bits ( ) . hash ( state) ;
102102 } ,
103- Constant :: Bool ( b) => {
103+ Self :: Bool ( b) => {
104104 b. hash ( state) ;
105105 } ,
106- Constant :: Vec ( ref v) | Constant :: Tuple ( ref v) => {
106+ Self :: Vec ( ref v) | Self :: Tuple ( ref v) => {
107107 v. hash ( state) ;
108108 } ,
109- Constant :: Repeat ( ref c, l) => {
109+ Self :: Repeat ( ref c, l) => {
110110 c. hash ( state) ;
111111 l. hash ( state) ;
112112 } ,
113- Constant :: RawPtr ( u) => {
113+ Self :: RawPtr ( u) => {
114114 u. hash ( state) ;
115115 } ,
116- Constant :: Err ( ref s) => {
116+ Self :: Err ( ref s) => {
117117 s. hash ( state) ;
118118 } ,
119119 }
@@ -123,25 +123,25 @@ impl Hash for Constant {
123123impl Constant {
124124 pub fn partial_cmp ( tcx : TyCtxt < ' _ > , cmp_type : Ty < ' _ > , left : & Self , right : & Self ) -> Option < Ordering > {
125125 match ( left, right) {
126- ( & Constant :: Str ( ref ls) , & Constant :: Str ( ref rs) ) => Some ( ls. cmp ( rs) ) ,
127- ( & Constant :: Char ( ref l) , & Constant :: Char ( ref r) ) => Some ( l. cmp ( r) ) ,
128- ( & Constant :: Int ( l) , & Constant :: Int ( r) ) => {
126+ ( & Self :: Str ( ref ls) , & Self :: Str ( ref rs) ) => Some ( ls. cmp ( rs) ) ,
127+ ( & Self :: Char ( ref l) , & Self :: Char ( ref r) ) => Some ( l. cmp ( r) ) ,
128+ ( & Self :: Int ( l) , & Self :: Int ( r) ) => {
129129 if let ty:: Int ( int_ty) = cmp_type. sty {
130130 Some ( sext ( tcx, l, int_ty) . cmp ( & sext ( tcx, r, int_ty) ) )
131131 } else {
132132 Some ( l. cmp ( & r) )
133133 }
134134 } ,
135- ( & Constant :: F64 ( l) , & Constant :: F64 ( r) ) => l. partial_cmp ( & r) ,
136- ( & Constant :: F32 ( l) , & Constant :: F32 ( r) ) => l. partial_cmp ( & r) ,
137- ( & Constant :: Bool ( ref l) , & Constant :: Bool ( ref r) ) => Some ( l. cmp ( r) ) ,
138- ( & Constant :: Tuple ( ref l) , & Constant :: Tuple ( ref r) ) | ( & Constant :: Vec ( ref l) , & Constant :: Vec ( ref r) ) => l
135+ ( & Self :: F64 ( l) , & Self :: F64 ( r) ) => l. partial_cmp ( & r) ,
136+ ( & Self :: F32 ( l) , & Self :: F32 ( r) ) => l. partial_cmp ( & r) ,
137+ ( & Self :: Bool ( ref l) , & Self :: Bool ( ref r) ) => Some ( l. cmp ( r) ) ,
138+ ( & Self :: Tuple ( ref l) , & Self :: Tuple ( ref r) ) | ( & Self :: Vec ( ref l) , & Self :: Vec ( ref r) ) => l
139139 . iter ( )
140140 . zip ( r. iter ( ) )
141141 . map ( |( li, ri) | Self :: partial_cmp ( tcx, cmp_type, li, ri) )
142142 . find ( |r| r. map_or ( true , |o| o != Ordering :: Equal ) )
143143 . unwrap_or_else ( || Some ( l. len ( ) . cmp ( & r. len ( ) ) ) ) ,
144- ( & Constant :: Repeat ( ref lv, ref ls) , & Constant :: Repeat ( ref rv, ref rs) ) => {
144+ ( & Self :: Repeat ( ref lv, ref ls) , & Self :: Repeat ( ref rv, ref rs) ) => {
145145 match Self :: partial_cmp ( tcx, cmp_type, lv, rv) {
146146 Some ( Equal ) => Some ( ls. cmp ( rs) ) ,
147147 x => x,
0 commit comments