@@ -84,7 +84,7 @@ impl<'s> LintLevelsBuilder<'s> {
84
84
}
85
85
86
86
fn process_command_line ( & mut self , sess : & Session , store : & LintStore ) {
87
- let mut specs = FxHashMap :: default ( ) ;
87
+ self . sets . list . push ( LintSet :: CommandLine { specs : FxHashMap :: default ( ) } ) ;
88
88
self . sets . lint_cap = sess. opts . lint_cap . unwrap_or ( Level :: Forbid ) ;
89
89
90
90
for & ( ref lint_name, level) in & sess. opts . lint_opts {
@@ -105,7 +105,17 @@ impl<'s> LintLevelsBuilder<'s> {
105
105
for id in ids {
106
106
self . check_gated_lint ( id, DUMMY_SP ) ;
107
107
let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
108
- specs. insert ( id, ( level, src) ) ;
108
+ let specs = match self . sets . list . last ( ) . unwrap ( ) {
109
+ LintSet :: CommandLine { ref specs } => specs,
110
+ _ => unreachable ! ( ) ,
111
+ } ;
112
+ if self . check_before_insert_spec ( specs, id, ( level, src) ) {
113
+ let specs = match self . sets . list . last_mut ( ) . unwrap ( ) {
114
+ LintSet :: CommandLine { ref mut specs } => specs,
115
+ _ => unreachable ! ( ) ,
116
+ } ;
117
+ specs. insert ( id, ( level, src) ) ;
118
+ }
109
119
}
110
120
}
111
121
@@ -122,15 +132,12 @@ impl<'s> LintLevelsBuilder<'s> {
122
132
self . sets . list . push ( LintSet :: CommandLine { specs } ) ;
123
133
}
124
134
125
- /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
126
- /// (e.g. if a forbid was already inserted on the same scope), then emits a
127
- /// diagnostic with no change to `specs`.
128
- fn insert_spec (
129
- & mut self ,
130
- specs : & mut FxHashMap < LintId , LevelAndSource > ,
135
+ fn check_before_insert_spec (
136
+ & self ,
137
+ specs : & FxHashMap < LintId , LevelAndSource > ,
131
138
id : LintId ,
132
139
( level, src) : LevelAndSource ,
133
- ) {
140
+ ) -> bool {
134
141
// Setting to a non-forbid level is an error if the lint previously had
135
142
// a forbid level. Note that this is not necessarily true even with a
136
143
// `#[forbid(..)]` attribute present, as that is overriden by `--cap-lints`.
@@ -212,11 +219,25 @@ impl<'s> LintLevelsBuilder<'s> {
212
219
// issuing a FCW. In the FCW case, we want to
213
220
// respect the new setting.
214
221
if !fcw_warning {
215
- return ;
222
+ return false ;
216
223
}
217
224
}
218
225
}
219
- specs. insert ( id, ( level, src) ) ;
226
+ true
227
+ }
228
+
229
+ /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
230
+ /// (e.g. if a forbid was already inserted on the same scope), then emits a
231
+ /// diagnostic with no change to `specs`.
232
+ fn insert_spec (
233
+ & mut self ,
234
+ specs : & mut FxHashMap < LintId , LevelAndSource > ,
235
+ id : LintId ,
236
+ ( level, src) : LevelAndSource ,
237
+ ) {
238
+ if self . check_before_insert_spec ( specs, id, ( level, src) ) {
239
+ specs. insert ( id, ( level, src) ) ;
240
+ }
220
241
}
221
242
222
243
/// Pushes a list of AST lint attributes onto this context.
0 commit comments