@@ -174,7 +174,7 @@ pub struct TopDown {
174174
175175pub trait LintLevelsProvider {
176176 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 ) ;
178178 fn get_lint_level ( & self , lint : & ' static Lint , sess : & Session ) -> LevelAndSource ;
179179 fn push_expectation ( & mut self , _id : LintExpectationId , _expectation : LintExpectation ) { }
180180}
@@ -184,8 +184,8 @@ impl LintLevelsProvider for TopDown {
184184 & self . sets . list [ self . cur ] . specs
185185 }
186186
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 ) ;
189189 }
190190
191191 fn get_lint_level ( & self , lint : & ' static Lint , sess : & Session ) -> LevelAndSource {
@@ -205,8 +205,8 @@ impl LintLevelsProvider for LintLevelQueryMap<'_> {
205205 fn current_specs ( & self ) -> & FxHashMap < LintId , LevelAndSource > {
206206 self . specs . specs . get ( & self . cur . local_id ) . unwrap_or ( & self . empty )
207207 }
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 ) ;
210210 }
211211 fn get_lint_level ( & self , lint : & ' static Lint , _: & Session ) -> LevelAndSource {
212212 self . specs . lint_level_id_at_node ( self . tcx , LintId :: of ( lint) , self . cur )
@@ -227,10 +227,10 @@ impl LintLevelsProvider for QueryMapExpectationsWrapper<'_> {
227227 fn current_specs ( & self ) -> & FxHashMap < LintId , LevelAndSource > {
228228 self . specs . specs . get ( & self . cur . local_id ) . unwrap_or ( & self . empty )
229229 }
230- fn current_specs_mut ( & mut self ) -> & mut FxHashMap < LintId , LevelAndSource > {
230+ fn insert ( & mut self , id : LintId , lvl : LevelAndSource ) {
231231 let specs = self . specs . specs . get_mut_or_insert_default ( self . cur . local_id ) ;
232232 specs. clear ( ) ;
233- specs
233+ specs. insert ( id , lvl ) ;
234234 }
235235 fn get_lint_level ( & self , lint : & ' static Lint , _: & Session ) -> LevelAndSource {
236236 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> {
487487 self . provider . current_specs ( )
488488 }
489489
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 )
492492 }
493493
494494 fn add_command_line ( & mut self ) {
@@ -511,7 +511,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
511511
512512 if self . check_gated_lint ( id, DUMMY_SP ) {
513513 let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
514- self . current_specs_mut ( ) . insert ( id, ( level, src) ) ;
514+ self . insert ( id, ( level, src) ) ;
515515 }
516516 }
517517 }
@@ -625,23 +625,21 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
625625
626626 match ( old_level, level) {
627627 // 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) )
634630 }
631+ // Keep `ForceWarn` level but drop the expectation
632+ ( Level :: ForceWarn ( _) , _) => self . insert ( id, ( Level :: ForceWarn ( None ) , old_src) ) ,
635633 // Set the lint level as normal
636- _ => self . current_specs_mut ( ) . insert ( id, ( level, src) ) ,
634+ _ => self . insert ( id, ( level, src) ) ,
637635 } ;
638636 }
639637
640638 fn add ( & mut self , attrs : & [ ast:: Attribute ] , is_crate_node : bool , source_hir_id : Option < HirId > ) {
641639 let sess = self . sess ;
642640 for ( attr_index, attr) in attrs. iter ( ) . enumerate ( ) {
643641 if attr. has_name ( sym:: automatically_derived) {
644- self . current_specs_mut ( ) . insert (
642+ self . insert (
645643 LintId :: of ( SINGLE_USE_LIFETIMES ) ,
646644 ( Level :: Allow , LintLevelSource :: Default ) ,
647645 ) ;
0 commit comments