@@ -33,7 +33,6 @@ use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
33
33
use rustc_span:: source_map:: { respan, Spanned } ;
34
34
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
35
35
use rustc_span:: { Span , DUMMY_SP } ;
36
- use std:: cmp:: Ordering ;
37
36
use std:: convert:: TryFrom ;
38
37
use std:: fmt;
39
38
use std:: mem;
@@ -324,46 +323,17 @@ pub type GenericBounds = Vec<GenericBound>;
324
323
/// Specifies the enforced ordering for generic parameters. In the future,
325
324
/// if we wanted to relax this order, we could override `PartialEq` and
326
325
/// `PartialOrd`, to allow the kinds to be unordered.
327
- #[ derive( Hash , Clone , Copy ) ]
326
+ #[ derive( Hash , Clone , Copy , PartialEq , Eq , PartialOrd , Ord ) ]
328
327
pub enum ParamKindOrd {
329
328
Lifetime ,
330
- Type ,
331
- Const ,
332
- // `Infer` is not actually constructed directly from the AST, but is implicitly constructed
333
- // during HIR lowering, and `ParamKindOrd` will implicitly order inferred variables last.
334
- Infer ,
335
- }
336
-
337
- impl Ord for ParamKindOrd {
338
- fn cmp ( & self , other : & Self ) -> Ordering {
339
- use ParamKindOrd :: * ;
340
- let to_int = |v| match v {
341
- Lifetime => 0 ,
342
- Infer | Type | Const => 1 ,
343
- } ;
344
-
345
- to_int ( * self ) . cmp ( & to_int ( * other) )
346
- }
347
- }
348
- impl PartialOrd for ParamKindOrd {
349
- fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
350
- Some ( self . cmp ( other) )
351
- }
352
- }
353
- impl PartialEq for ParamKindOrd {
354
- fn eq ( & self , other : & Self ) -> bool {
355
- self . cmp ( other) == Ordering :: Equal
356
- }
329
+ TypeOrConst ,
357
330
}
358
- impl Eq for ParamKindOrd { }
359
331
360
332
impl fmt:: Display for ParamKindOrd {
361
333
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
362
334
match self {
363
335
ParamKindOrd :: Lifetime => "lifetime" . fmt ( f) ,
364
- ParamKindOrd :: Type => "type" . fmt ( f) ,
365
- ParamKindOrd :: Const { .. } => "const" . fmt ( f) ,
366
- ParamKindOrd :: Infer => "infer" . fmt ( f) ,
336
+ ParamKindOrd :: TypeOrConst => "type and const" . fmt ( f) ,
367
337
}
368
338
}
369
339
}
0 commit comments