1+ use derive_where:: derive_where;
12use rustc_abi:: ExternAbi ;
23use rustc_ast:: AttrId ;
34use rustc_ast:: attr:: AttributeExt ;
@@ -8,7 +9,8 @@ use rustc_data_structures::stable_hasher::{
89} ;
910use rustc_error_messages:: { DiagMessage , MultiSpan } ;
1011use rustc_hir:: def:: Namespace ;
11- use rustc_hir:: { HashStableContext , HirId , MissingLifetimeKind } ;
12+ use rustc_hir:: def_id:: DefPathHash ;
13+ use rustc_hir:: { HashStableContext , HirId , ItemLocalId , MissingLifetimeKind } ;
1214use rustc_macros:: { Decodable , Encodable , HashStable_Generic } ;
1315pub use rustc_span:: edition:: Edition ;
1416use rustc_span:: { Ident , MacroRulesNormalizedIdent , Span , Symbol , sym} ;
@@ -102,7 +104,7 @@ pub enum Applicability {
102104/// The index values have a type of `u16` to reduce the size of the `LintExpectationId`.
103105/// It's reasonable to assume that no user will define 2^16 attributes on one node or
104106/// have that amount of lints listed. `u16` values should therefore suffice.
105- #[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash , Encodable , Decodable ) ]
107+ #[ derive( Clone , Copy , PartialEq , Eq , Debug , Hash , Encodable , Decodable ) ]
106108pub enum LintExpectationId {
107109 /// Used for lints emitted during the `EarlyLintPass`. This id is not
108110 /// hash stable and should not be cached.
@@ -156,13 +158,14 @@ impl<HCX: rustc_hir::HashStableContext> HashStable<HCX> for LintExpectationId {
156158}
157159
158160impl < HCX : rustc_hir:: HashStableContext > ToStableHashKey < HCX > for LintExpectationId {
159- type KeyType = ( HirId , u16 , u16 ) ;
161+ type KeyType = ( DefPathHash , ItemLocalId , u16 , u16 ) ;
160162
161163 #[ inline]
162- fn to_stable_hash_key ( & self , _ : & HCX ) -> Self :: KeyType {
164+ fn to_stable_hash_key ( & self , hcx : & HCX ) -> Self :: KeyType {
163165 match self {
164166 LintExpectationId :: Stable { hir_id, attr_index, lint_index : Some ( lint_index) } => {
165- ( * hir_id, * attr_index, * lint_index)
167+ let ( def_path_hash, lint_idx) = hir_id. to_stable_hash_key ( hcx) ;
168+ ( def_path_hash, lint_idx, * attr_index, * lint_index)
166169 }
167170 _ => {
168171 unreachable ! ( "HashStable should only be called for a filled `LintExpectationId`" )
@@ -174,19 +177,8 @@ impl<HCX: rustc_hir::HashStableContext> ToStableHashKey<HCX> for LintExpectation
174177/// Setting for how to handle a lint.
175178///
176179/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
177- #[ derive(
178- Clone ,
179- Copy ,
180- PartialEq ,
181- PartialOrd ,
182- Eq ,
183- Ord ,
184- Debug ,
185- Hash ,
186- Encodable ,
187- Decodable ,
188- HashStable_Generic
189- ) ]
180+ #[ derive( Clone , Copy , PartialEq , Eq , Debug , Hash , Encodable , Decodable , HashStable_Generic ) ]
181+ #[ derive_where( PartialOrd ) ]
190182pub enum Level {
191183 /// The `allow` level will not issue any message.
192184 Allow ,
@@ -201,7 +193,7 @@ pub enum Level {
201193 ///
202194 /// The [`LintExpectationId`] is used to later link a lint emission to the actual
203195 /// expectation. It can be ignored in most cases.
204- Expect ( LintExpectationId ) ,
196+ Expect ( # [ derive_where ( skip ) ] LintExpectationId ) ,
205197 /// The `warn` level will produce a warning if the lint was violated, however the
206198 /// compiler will continue with its execution.
207199 Warn ,
@@ -211,7 +203,7 @@ pub enum Level {
211203 ///
212204 /// The [`LintExpectationId`] is intended to fulfill expectations marked via the
213205 /// `#[expect]` attribute, that will still be suppressed due to the level.
214- ForceWarn ( Option < LintExpectationId > ) ,
206+ ForceWarn ( # [ derive_where ( skip ) ] Option < LintExpectationId > ) ,
215207 /// The `deny` level will produce an error and stop further execution after the lint
216208 /// pass is complete.
217209 Deny ,
@@ -294,6 +286,10 @@ impl Level {
294286 _ => None ,
295287 }
296288 }
289+
290+ pub fn min ( self , other : Self ) -> Self {
291+ if self < other { self } else { other }
292+ }
297293}
298294
299295/// Specification of a single lint.
0 commit comments