11use std:: borrow:: Cow ;
22use std:: fmt:: Display ;
3+ use std:: hash:: Hash ;
34
45use rustc_data_structures:: fx:: FxIndexSet ;
56use rustc_data_structures:: stable_hasher:: {
@@ -10,7 +11,7 @@ use rustc_hir_id::{HirId, ItemLocalId};
1011use rustc_macros:: { Decodable , Encodable , HashStable_Generic } ;
1112use rustc_span:: def_id:: DefPathHash ;
1213pub use rustc_span:: edition:: Edition ;
13- use rustc_span:: { AttrId , HashStableContext , Ident , Span , Symbol , sym} ;
14+ use rustc_span:: { HashStableContext , Ident , Span , Symbol , sym} ;
1415use serde:: { Deserialize , Serialize } ;
1516
1617pub use self :: Level :: * ;
@@ -105,12 +106,12 @@ pub enum Applicability {
105106pub enum LintExpectationId {
106107 /// Used for lints emitted during the `EarlyLintPass`. This id is not
107108 /// hash stable and should not be cached.
108- Unstable { attr_id : AttrId , lint_index : u16 } ,
109+ Unstable { target_span : Span , lint_index : u16 , attr_index : u16 } ,
109110 /// The [`HirId`] that the lint expectation is attached to. This id is
110111 /// stable and can be cached. The additional index ensures that nodes with
111112 /// several expectations can correctly match diagnostics to the individual
112113 /// expectation.
113- Stable { hir_id : HirId , attr_id : AttrId , attr_index : u16 , lint_index : u16 } ,
114+ Stable { hir_id : HirId , attr_index : u16 , lint_index : u16 , target_span : Span } ,
114115}
115116
116117impl LintExpectationId {
@@ -140,12 +141,13 @@ impl<Hcx: HashStableContext> HashStable<Hcx> for LintExpectationId {
140141 #[ inline]
141142 fn hash_stable ( & self , hcx : & mut Hcx , hasher : & mut StableHasher ) {
142143 match self {
143- LintExpectationId :: Stable { hir_id, attr_index, lint_index, .. } => {
144+ LintExpectationId :: Stable { hir_id, target_span , attr_index, lint_index, .. } => {
144145 hir_id. hash_stable ( hcx, hasher) ;
146+ target_span. hash_stable ( hcx, hasher) ;
145147 attr_index. hash_stable ( hcx, hasher) ;
146148 lint_index. hash_stable ( hcx, hasher) ;
147149 }
148- _ => {
150+ LintExpectationId :: Unstable { .. } => {
149151 unreachable ! (
150152 "HashStable should only be called for filled and stable `LintExpectationId`"
151153 )
@@ -155,16 +157,16 @@ impl<Hcx: HashStableContext> HashStable<Hcx> for LintExpectationId {
155157}
156158
157159impl < Hcx : HashStableContext > ToStableHashKey < Hcx > for LintExpectationId {
158- type KeyType = ( DefPathHash , ItemLocalId , u16 , u16 ) ;
160+ type KeyType = ( DefPathHash , ItemLocalId , Span , u16 , u16 ) ;
159161
160162 #[ inline]
161163 fn to_stable_hash_key ( & self , hcx : & mut Hcx ) -> Self :: KeyType {
162164 match self {
163- LintExpectationId :: Stable { hir_id, attr_index, lint_index, .. } => {
165+ LintExpectationId :: Stable { hir_id, attr_index, lint_index, target_span , .. } => {
164166 let ( def_path_hash, lint_idx) = hir_id. to_stable_hash_key ( hcx) ;
165- ( def_path_hash, lint_idx, * attr_index, * lint_index)
167+ ( def_path_hash, lint_idx, * target_span , * attr_index, * lint_index)
166168 }
167- _ => {
169+ LintExpectationId :: Unstable { .. } => {
168170 unreachable ! ( "HashStable should only be called for a filled `LintExpectationId`" )
169171 }
170172 }
0 commit comments