@@ -213,8 +213,8 @@ fn cs_op(less: bool,
213
213
Ident :: from_str ( "partial_cmp" ) ,
214
214
vec ! [ cx. expr_addr_of( span, other_f. clone( ) ) ] ) ;
215
215
216
- let default = ordering_path ( cx, if less { "Greater" } else { "Less" } ) ;
217
- // `_.unwrap_or(Ordering::Greater/Less )`
216
+ let default = ordering_path ( cx, "Equal" ) ;
217
+ // `_.unwrap_or(Ordering::Equal )`
218
218
cx. expr_method_call ( span, cmp, Ident :: from_str ( "unwrap_or" ) , vec ! [ default ] )
219
219
} ;
220
220
@@ -225,28 +225,28 @@ fn cs_op(less: bool,
225
225
// `ast::lt`
226
226
//
227
227
// ```
228
- // self.f1.partial_cmp(other.f1).unwrap_or(Ordering::Greater )
229
- // .then_with(|| self.f2.partial_cmp(other.f2).unwrap_or(Ordering::Greater ))
228
+ // self.f1.partial_cmp(other.f1).unwrap_or(Ordering::Equal )
229
+ // .then_with(|| self.f2.partial_cmp(other.f2).unwrap_or(Ordering::Equal ))
230
230
// == Ordering::Less
231
231
// ```
232
232
//
233
233
// and for op ==
234
234
// `ast::le`
235
235
//
236
236
// ```
237
- // self.f1.partial_cmp(other.f1).unwrap_or(Ordering::Greater )
238
- // .then_with(|| self.f2.partial_cmp(other.f2).unwrap_or(Ordering::Greater ))
237
+ // self.f1.partial_cmp(other.f1).unwrap_or(Ordering::Equal )
238
+ // .then_with(|| self.f2.partial_cmp(other.f2).unwrap_or(Ordering::Equal ))
239
239
// != Ordering::Greater
240
240
// ```
241
241
//
242
242
// The optimiser should remove the redundancy. We explicitly
243
243
// get use the binops to avoid auto-deref dereferencing too many
244
244
// layers of pointers, if the type includes pointers.
245
245
246
- // `self.fi.partial_cmp(other.fi).unwrap_or(Ordering::Greater/Less )`
246
+ // `self.fi.partial_cmp(other.fi).unwrap_or(Ordering::Equal )`
247
247
let par_cmp = par_cmp ( cx, span, self_f, other_fs) ;
248
248
249
- // `self.fi.partial_cmp(other.fi).unwrap_or(Ordering::Greater/Less ).then_with(...)`
249
+ // `self.fi.partial_cmp(other.fi).unwrap_or(Ordering::Equal ).then_with(...)`
250
250
cx. expr_method_call ( span,
251
251
par_cmp,
252
252
Ident :: from_str ( "then_with" ) ,
@@ -255,7 +255,7 @@ fn cs_op(less: bool,
255
255
|cx, args| {
256
256
match args {
257
257
Some ( ( span, self_f, other_fs) ) => par_cmp ( cx, span, self_f, other_fs) ,
258
- None => ordering_path ( cx , if less { "Less" } else { "Equal" } )
258
+ None => cx . expr_bool ( span , inclusive )
259
259
}
260
260
} ,
261
261
Box :: new ( |cx, span, ( self_args, tag_tuple) , _non_self_args| {
@@ -276,8 +276,8 @@ fn cs_op(less: bool,
276
276
substr) ;
277
277
278
278
match * substr. fields {
279
- EnumMatching ( ..) |
280
- Struct ( ..) => {
279
+ EnumMatching ( .., ref all_fields ) |
280
+ Struct ( .., ref all_fields ) if !all_fields . is_empty ( ) => {
281
281
let ordering = ordering_path ( cx, if less ^ inclusive { "Less" } else { "Greater" } ) ;
282
282
let comp_op = if inclusive { BinOpKind :: Ne } else { BinOpKind :: Eq } ;
283
283
0 commit comments