@@ -64,16 +64,20 @@ pub enum Applicability {
6464///
6565/// Each lint inside the `expect` attribute is tracked individually, the `lint_index`
6666/// 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.
6771#[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash , Encodable , Decodable ) ]
6872pub enum LintExpectationId {
6973 /// Used for lints emitted during the `EarlyLintPass`. This id is not
7074 /// 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 > } ,
7276 /// The [`HirId`] that the lint expectation is attached to. This id is
7377 /// stable and can be cached. The additional index ensures that nodes with
7478 /// several expectations can correctly match diagnostics to the individual
7579 /// 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 > } ,
7781}
7882
7983impl LintExpectationId {
@@ -84,14 +88,14 @@ impl LintExpectationId {
8488 }
8589 }
8690
87- pub fn get_lint_index ( & self ) -> Option < usize > {
91+ pub fn get_lint_index ( & self ) -> Option < u16 > {
8892 let ( LintExpectationId :: Unstable { lint_index, .. }
8993 | LintExpectationId :: Stable { lint_index, .. } ) = self ;
9094
9195 * lint_index
9296 }
9397
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 > ) {
9599 let ( LintExpectationId :: Unstable { ref mut lint_index, .. }
96100 | LintExpectationId :: Stable { ref mut lint_index, .. } ) = self ;
97101
@@ -116,7 +120,7 @@ impl<HCX: rustc_hir::HashStableContext> HashStable<HCX> for LintExpectationId {
116120}
117121
118122impl < HCX : rustc_hir:: HashStableContext > ToStableHashKey < HCX > for LintExpectationId {
119- type KeyType = ( HirId , usize , usize ) ;
123+ type KeyType = ( HirId , u16 , u16 ) ;
120124
121125 #[ inline]
122126 fn to_stable_hash_key ( & self , _: & HCX ) -> Self :: KeyType {
0 commit comments