@@ -5,6 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
5
5
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6
6
use rustc_errors:: { DiagnosticBuilder , DiagnosticId } ;
7
7
use rustc_hir:: HirId ;
8
+ use rustc_index:: vec:: IndexVec ;
8
9
use rustc_session:: lint:: {
9
10
builtin:: { self , FORBIDDEN_LINT_GROUPS } ,
10
11
FutureIncompatibilityReason , Level , Lint , LintId ,
@@ -53,10 +54,17 @@ pub type LevelAndSource = (Level, LintLevelSource);
53
54
54
55
#[ derive( Debug , HashStable ) ]
55
56
pub struct LintLevelSets {
56
- pub list : Vec < LintSet > ,
57
+ pub list : IndexVec < LintStackIndex , LintSet > ,
57
58
pub lint_cap : Level ,
58
59
}
59
60
61
+ rustc_index:: newtype_index! {
62
+ #[ derive( HashStable ) ]
63
+ pub struct LintStackIndex {
64
+ const COMMAND_LINE = 0 ,
65
+ }
66
+ }
67
+
60
68
#[ derive( Debug , HashStable ) ]
61
69
pub enum LintSet {
62
70
CommandLine {
@@ -67,19 +75,19 @@ pub enum LintSet {
67
75
68
76
Node {
69
77
specs : FxHashMap < LintId , LevelAndSource > ,
70
- parent : u32 ,
78
+ parent : LintStackIndex ,
71
79
} ,
72
80
}
73
81
74
82
impl LintLevelSets {
75
83
pub fn new ( ) -> Self {
76
- LintLevelSets { list : Vec :: new ( ) , lint_cap : Level :: Forbid }
84
+ LintLevelSets { list : IndexVec :: new ( ) , lint_cap : Level :: Forbid }
77
85
}
78
86
79
87
pub fn get_lint_level (
80
88
& self ,
81
89
lint : & ' static Lint ,
82
- idx : u32 ,
90
+ idx : LintStackIndex ,
83
91
aux : Option < & FxHashMap < LintId , LevelAndSource > > ,
84
92
sess : & Session ,
85
93
) -> LevelAndSource {
@@ -122,7 +130,7 @@ impl LintLevelSets {
122
130
pub fn get_lint_id_level (
123
131
& self ,
124
132
id : LintId ,
125
- mut idx : u32 ,
133
+ mut idx : LintStackIndex ,
126
134
aux : Option < & FxHashMap < LintId , LevelAndSource > > ,
127
135
) -> ( Option < Level > , LintLevelSource ) {
128
136
if let Some ( specs) = aux {
@@ -131,7 +139,7 @@ impl LintLevelSets {
131
139
}
132
140
}
133
141
loop {
134
- match self . list [ idx as usize ] {
142
+ match self . list [ idx] {
135
143
LintSet :: CommandLine { ref specs } => {
136
144
if let Some ( & ( level, src) ) = specs. get ( & id) {
137
145
return ( Some ( level) , src) ;
@@ -152,7 +160,7 @@ impl LintLevelSets {
152
160
#[ derive( Debug ) ]
153
161
pub struct LintLevelMap {
154
162
pub sets : LintLevelSets ,
155
- pub id_to_set : FxHashMap < HirId , u32 > ,
163
+ pub id_to_set : FxHashMap < HirId , LintStackIndex > ,
156
164
}
157
165
158
166
impl LintLevelMap {
0 commit comments