@@ -174,7 +174,7 @@ pub struct TopDown {
174
174
175
175
pub trait LintLevelsProvider {
176
176
fn current_specs ( & self ) -> & FxHashMap < LintId , LevelAndSource > ;
177
- fn current_specs_mut ( & mut self ) -> & mut FxHashMap < LintId , LevelAndSource > ;
177
+ fn insert ( & mut self , id : LintId , lvl : LevelAndSource ) ;
178
178
fn get_lint_level ( & self , lint : & ' static Lint , sess : & Session ) -> LevelAndSource ;
179
179
fn push_expectation ( & mut self , _id : LintExpectationId , _expectation : LintExpectation ) { }
180
180
}
@@ -184,8 +184,8 @@ impl LintLevelsProvider for TopDown {
184
184
& self . sets . list [ self . cur ] . specs
185
185
}
186
186
187
- fn current_specs_mut ( & mut self ) -> & mut FxHashMap < LintId , LevelAndSource > {
188
- & mut self . sets . list [ self . cur ] . specs
187
+ fn insert ( & mut self , id : LintId , lvl : LevelAndSource ) {
188
+ self . sets . list [ self . cur ] . specs . insert ( id , lvl ) ;
189
189
}
190
190
191
191
fn get_lint_level ( & self , lint : & ' static Lint , sess : & Session ) -> LevelAndSource {
@@ -205,8 +205,8 @@ impl LintLevelsProvider for LintLevelQueryMap<'_> {
205
205
fn current_specs ( & self ) -> & FxHashMap < LintId , LevelAndSource > {
206
206
self . specs . specs . get ( & self . cur . local_id ) . unwrap_or ( & self . empty )
207
207
}
208
- fn current_specs_mut ( & mut self ) -> & mut FxHashMap < LintId , LevelAndSource > {
209
- self . specs . specs . get_mut_or_insert_default ( self . cur . local_id )
208
+ fn insert ( & mut self , id : LintId , lvl : LevelAndSource ) {
209
+ self . specs . specs . get_mut_or_insert_default ( self . cur . local_id ) . insert ( id , lvl ) ;
210
210
}
211
211
fn get_lint_level ( & self , lint : & ' static Lint , _: & Session ) -> LevelAndSource {
212
212
self . specs . lint_level_id_at_node ( self . tcx , LintId :: of ( lint) , self . cur )
@@ -227,10 +227,10 @@ impl LintLevelsProvider for QueryMapExpectationsWrapper<'_> {
227
227
fn current_specs ( & self ) -> & FxHashMap < LintId , LevelAndSource > {
228
228
self . specs . specs . get ( & self . cur . local_id ) . unwrap_or ( & self . empty )
229
229
}
230
- fn current_specs_mut ( & mut self ) -> & mut FxHashMap < LintId , LevelAndSource > {
230
+ fn insert ( & mut self , id : LintId , lvl : LevelAndSource ) {
231
231
let specs = self . specs . specs . get_mut_or_insert_default ( self . cur . local_id ) ;
232
232
specs. clear ( ) ;
233
- specs
233
+ specs. insert ( id , lvl ) ;
234
234
}
235
235
fn get_lint_level ( & self , lint : & ' static Lint , _: & Session ) -> LevelAndSource {
236
236
self . specs . lint_level_id_at_node ( self . tcx , LintId :: of ( lint) , self . cur )
@@ -487,8 +487,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
487
487
self . provider . current_specs ( )
488
488
}
489
489
490
- fn current_specs_mut ( & mut self ) -> & mut FxHashMap < LintId , LevelAndSource > {
491
- self . provider . current_specs_mut ( )
490
+ fn insert ( & mut self , id : LintId , lvl : LevelAndSource ) {
491
+ self . provider . insert ( id , lvl )
492
492
}
493
493
494
494
fn add_command_line ( & mut self ) {
@@ -511,7 +511,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
511
511
512
512
if self . check_gated_lint ( id, DUMMY_SP ) {
513
513
let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
514
- self . current_specs_mut ( ) . insert ( id, ( level, src) ) ;
514
+ self . insert ( id, ( level, src) ) ;
515
515
}
516
516
}
517
517
}
@@ -625,23 +625,21 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
625
625
626
626
match ( old_level, level) {
627
627
// If the new level is an expectation store it in `ForceWarn`
628
- ( Level :: ForceWarn ( _) , Level :: Expect ( expectation_id) ) => self
629
- . current_specs_mut ( )
630
- . insert ( id, ( Level :: ForceWarn ( Some ( expectation_id) ) , old_src) ) ,
631
- // Keep `ForceWarn` level but drop the expectation
632
- ( Level :: ForceWarn ( _) , _) => {
633
- self . current_specs_mut ( ) . insert ( id, ( Level :: ForceWarn ( None ) , old_src) )
628
+ ( Level :: ForceWarn ( _) , Level :: Expect ( expectation_id) ) => {
629
+ self . insert ( id, ( Level :: ForceWarn ( Some ( expectation_id) ) , old_src) )
634
630
}
631
+ // Keep `ForceWarn` level but drop the expectation
632
+ ( Level :: ForceWarn ( _) , _) => self . insert ( id, ( Level :: ForceWarn ( None ) , old_src) ) ,
635
633
// Set the lint level as normal
636
- _ => self . current_specs_mut ( ) . insert ( id, ( level, src) ) ,
634
+ _ => self . insert ( id, ( level, src) ) ,
637
635
} ;
638
636
}
639
637
640
638
fn add ( & mut self , attrs : & [ ast:: Attribute ] , is_crate_node : bool , source_hir_id : Option < HirId > ) {
641
639
let sess = self . sess ;
642
640
for ( attr_index, attr) in attrs. iter ( ) . enumerate ( ) {
643
641
if attr. has_name ( sym:: automatically_derived) {
644
- self . current_specs_mut ( ) . insert (
642
+ self . insert (
645
643
LintId :: of ( SINGLE_USE_LIFETIMES ) ,
646
644
( Level :: Allow , LintLevelSource :: Default ) ,
647
645
) ;
0 commit comments