@@ -64,16 +64,20 @@ pub enum Applicability {
64
64
///
65
65
/// Each lint inside the `expect` attribute is tracked individually, the `lint_index`
66
66
/// identifies the lint inside the attribute and ensures that the IDs are unique.
67
+ ///
68
+ /// The index values have a type of `u16` to reduce the size of the `LintExpectationId`.
69
+ /// It's reasonable to assume that no user will define 2^16 attributes on one node or
70
+ /// have that amount of lints listed. `u16` values should therefore suffice.
67
71
#[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash , Encodable , Decodable ) ]
68
72
pub enum LintExpectationId {
69
73
/// Used for lints emitted during the `EarlyLintPass`. This id is not
70
74
/// has stable and should not be cached.
71
- Unstable { attr_id : AttrId , lint_index : Option < usize > } ,
75
+ Unstable { attr_id : AttrId , lint_index : Option < u16 > } ,
72
76
/// The [`HirId`] that the lint expectation is attached to. This id is
73
77
/// stable and can be cached. The additional index ensures that nodes with
74
78
/// several expectations can correctly match diagnostics to the individual
75
79
/// expectation.
76
- Stable { hir_id : HirId , attr_index : usize , lint_index : Option < usize > } ,
80
+ Stable { hir_id : HirId , attr_index : u16 , lint_index : Option < u16 > } ,
77
81
}
78
82
79
83
impl LintExpectationId {
@@ -84,14 +88,14 @@ impl LintExpectationId {
84
88
}
85
89
}
86
90
87
- pub fn get_lint_index ( & self ) -> Option < usize > {
91
+ pub fn get_lint_index ( & self ) -> Option < u16 > {
88
92
let ( LintExpectationId :: Unstable { lint_index, .. }
89
93
| LintExpectationId :: Stable { lint_index, .. } ) = self ;
90
94
91
95
* lint_index
92
96
}
93
97
94
- pub fn set_lint_index ( & mut self , new_lint_index : Option < usize > ) {
98
+ pub fn set_lint_index ( & mut self , new_lint_index : Option < u16 > ) {
95
99
let ( LintExpectationId :: Unstable { ref mut lint_index, .. }
96
100
| LintExpectationId :: Stable { ref mut lint_index, .. } ) = self ;
97
101
@@ -116,7 +120,7 @@ impl<HCX: rustc_hir::HashStableContext> HashStable<HCX> for LintExpectationId {
116
120
}
117
121
118
122
impl < HCX : rustc_hir:: HashStableContext > ToStableHashKey < HCX > for LintExpectationId {
119
- type KeyType = ( HirId , usize , usize ) ;
123
+ type KeyType = ( HirId , u16 , u16 ) ;
120
124
121
125
#[ inline]
122
126
fn to_stable_hash_key ( & self , _: & HCX ) -> Self :: KeyType {
0 commit comments