33#[ macro_use]
44extern crate rustc_macros;
55
6+ use std:: cmp:: Ordering ;
7+
68pub use self :: Level :: * ;
79use rustc_ast:: node_id:: { NodeId , NodeMap } ;
810use rustc_ast:: { AttrId , Attribute } ;
@@ -80,7 +82,7 @@ pub enum Applicability {
8082/// The index values have a type of `u16` to reduce the size of the `LintExpectationId`.
8183/// It's reasonable to assume that no user will define 2^16 attributes on one node or
8284/// 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 ) ]
8486pub enum LintExpectationId {
8587 /// Used for lints emitted during the `EarlyLintPass`. This id is not
8688 /// hash stable and should not be cached.
@@ -134,13 +136,14 @@ impl<HCX: rustc_hir::HashStableContext> HashStable<HCX> for LintExpectationId {
134136}
135137
136138impl < 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 ) ;
138140
139141 #[ inline]
140- fn to_stable_hash_key ( & self , _ : & HCX ) -> Self :: KeyType {
142+ fn to_stable_hash_key ( & self , hcx : & HCX ) -> Self :: KeyType {
141143 match self {
142144 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)
144147 }
145148 _ => {
146149 unreachable ! ( "HashStable should only be called for a filled `LintExpectationId`" )
@@ -152,7 +155,7 @@ impl<HCX: rustc_hir::HashStableContext> ToStableHashKey<HCX> for LintExpectation
152155/// Setting for how to handle a lint.
153156///
154157/// 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 ) ]
156159pub enum Level {
157160 /// The `allow` level will not issue any message.
158161 Allow ,
@@ -186,6 +189,14 @@ pub enum Level {
186189 Forbid ,
187190}
188191
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+
189200impl Level {
190201 /// Converts a level to a lower-case string.
191202 pub fn as_str ( self ) -> & ' static str {
0 commit comments