3
3
#[ macro_use]
4
4
extern crate rustc_macros;
5
5
6
+ use std:: cmp:: Ordering ;
7
+
6
8
pub use self :: Level :: * ;
7
9
use rustc_ast:: node_id:: { NodeId , NodeMap } ;
8
10
use rustc_ast:: { AttrId , Attribute } ;
@@ -80,7 +82,7 @@ pub enum Applicability {
80
82
/// The index values have a type of `u16` to reduce the size of the `LintExpectationId`.
81
83
/// It's reasonable to assume that no user will define 2^16 attributes on one node or
82
84
/// have that amount of lints listed. `u16` values should therefore suffice.
83
- #[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash , Encodable , Decodable ) ]
85
+ #[ derive( Clone , Copy , PartialEq , Eq , Debug , Hash , Encodable , Decodable ) ]
84
86
pub enum LintExpectationId {
85
87
/// Used for lints emitted during the `EarlyLintPass`. This id is not
86
88
/// hash stable and should not be cached.
@@ -134,13 +136,14 @@ impl<HCX: rustc_hir::HashStableContext> HashStable<HCX> for LintExpectationId {
134
136
}
135
137
136
138
impl < HCX : rustc_hir:: HashStableContext > ToStableHashKey < HCX > for LintExpectationId {
137
- type KeyType = ( HirId , u16 , u16 ) ;
139
+ type KeyType = ( rustc_hir :: def_id :: DefPathHash , rustc_hir :: hir_id :: ItemLocalId , u16 , u16 ) ;
138
140
139
141
#[ inline]
140
- fn to_stable_hash_key ( & self , _ : & HCX ) -> Self :: KeyType {
142
+ fn to_stable_hash_key ( & self , hcx : & HCX ) -> Self :: KeyType {
141
143
match self {
142
144
LintExpectationId :: Stable { hir_id, attr_index, lint_index : Some ( lint_index) } => {
143
- ( * hir_id, * attr_index, * lint_index)
145
+ let ( def_path_hash, lint_idx) = hir_id. to_stable_hash_key ( hcx) ;
146
+ ( def_path_hash, lint_idx, * attr_index, * lint_index)
144
147
}
145
148
_ => {
146
149
unreachable ! ( "HashStable should only be called for a filled `LintExpectationId`" )
@@ -152,7 +155,7 @@ impl<HCX: rustc_hir::HashStableContext> ToStableHashKey<HCX> for LintExpectation
152
155
/// Setting for how to handle a lint.
153
156
///
154
157
/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
155
- #[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash , HashStable_Generic ) ]
158
+ #[ derive( Clone , Copy , PartialEq , Eq , Debug , Hash ) ]
156
159
pub enum Level {
157
160
/// The `allow` level will not issue any message.
158
161
Allow ,
@@ -186,6 +189,14 @@ pub enum Level {
186
189
Forbid ,
187
190
}
188
191
192
+ impl PartialOrd for Level {
193
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
194
+ std:: mem:: discriminant ( self ) . partial_cmp ( std:: mem:: discriminant ( other) )
195
+ }
196
+ }
197
+
198
+ rustc_data_structures:: impl_stable_hash_via_hash!( Level ) ;
199
+
189
200
impl Level {
190
201
/// Converts a level to a lower-case string.
191
202
pub fn as_str ( self ) -> & ' static str {
0 commit comments