@@ -87,7 +87,7 @@ impl LintLevelSets {
8787 let level = reveal_actual_level ( level, & mut src, sess, lint, |id| {
8888 self . raw_lint_id_level ( id, idx, aux)
8989 } ) ;
90- ( level, src)
90+ LevelAndSource { level, src }
9191 }
9292
9393 fn raw_lint_id_level (
@@ -97,14 +97,14 @@ impl LintLevelSets {
9797 aux : Option < & FxIndexMap < LintId , LevelAndSource > > ,
9898 ) -> ( Option < Level > , LintLevelSource ) {
9999 if let Some ( specs) = aux
100- && let Some ( & ( level, src) ) = specs. get ( & id)
100+ && let Some ( & LevelAndSource { level, src } ) = specs. get ( & id)
101101 {
102102 return ( Some ( level) , src) ;
103103 }
104104
105105 loop {
106106 let LintSet { ref specs, parent } = self . list [ idx] ;
107- if let Some ( & ( level, src) ) = specs. get ( & id) {
107+ if let Some ( & LevelAndSource { level, src } ) = specs. get ( & id) {
108108 return ( Some ( level) , src) ;
109109 }
110110 if idx == COMMAND_LINE {
@@ -131,8 +131,8 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
131131 } )
132132 . filter_map ( |lint| {
133133 let lint_level = map. lint_level_id_at_node ( tcx, LintId :: of ( lint) , CRATE_HIR_ID ) ;
134- if matches ! ( lint_level, ( Level :: Allow , .. ) )
135- || ( matches ! ( lint_level, ( .. , LintLevelSource :: Default ) ) )
134+ if matches ! ( lint_level. level , Level :: Allow )
135+ || ( matches ! ( lint_level. src , LintLevelSource :: Default ) )
136136 && lint. default_level ( tcx. sess . edition ( ) ) == Level :: Allow
137137 {
138138 Some ( LintId :: of ( lint) )
@@ -582,15 +582,15 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
582582 } ;
583583 for id in ids {
584584 // ForceWarn and Forbid cannot be overridden
585- if let Some ( ( Level :: ForceWarn ( _) | Level :: Forbid , _ ) ) =
585+ if let Some ( LevelAndSource { level : Level :: ForceWarn ( _) | Level :: Forbid , .. } ) =
586586 self . current_specs ( ) . get ( & id)
587587 {
588588 continue ;
589589 }
590590
591591 if self . check_gated_lint ( id, DUMMY_SP , true ) {
592592 let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
593- self . insert ( id, ( level, src) ) ;
593+ self . insert ( id, LevelAndSource { level, src } ) ;
594594 }
595595 }
596596 }
@@ -599,8 +599,9 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
599599 /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
600600 /// (e.g. if a forbid was already inserted on the same scope), then emits a
601601 /// diagnostic with no change to `specs`.
602- fn insert_spec ( & mut self , id : LintId , ( level, src) : LevelAndSource ) {
603- let ( old_level, old_src) = self . provider . get_lint_level ( id. lint , self . sess ) ;
602+ fn insert_spec ( & mut self , id : LintId , LevelAndSource { level, src } : LevelAndSource ) {
603+ let LevelAndSource { level : old_level, src : old_src } =
604+ self . provider . get_lint_level ( id. lint , self . sess ) ;
604605
605606 // Setting to a non-forbid level is an error if the lint previously had
606607 // a forbid level. Note that this is not necessarily true even with a
@@ -680,13 +681,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
680681
681682 match ( old_level, level) {
682683 // If the new level is an expectation store it in `ForceWarn`
683- ( Level :: ForceWarn ( _) , Level :: Expect ( expectation_id) ) => {
684- self . insert ( id, ( Level :: ForceWarn ( Some ( expectation_id) ) , old_src) )
685- }
684+ ( Level :: ForceWarn ( _) , Level :: Expect ( expectation_id) ) => self . insert (
685+ id,
686+ LevelAndSource { level : Level :: ForceWarn ( Some ( expectation_id) ) , src : old_src } ,
687+ ) ,
686688 // Keep `ForceWarn` level but drop the expectation
687- ( Level :: ForceWarn ( _) , _) => self . insert ( id, ( Level :: ForceWarn ( None ) , old_src) ) ,
689+ ( Level :: ForceWarn ( _) , _) => {
690+ self . insert ( id, LevelAndSource { level : Level :: ForceWarn ( None ) , src : old_src } )
691+ }
688692 // Set the lint level as normal
689- _ => self . insert ( id, ( level, src) ) ,
693+ _ => self . insert ( id, LevelAndSource { level, src } ) ,
690694 } ;
691695 }
692696
@@ -701,7 +705,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
701705 if attr. has_name ( sym:: automatically_derived) {
702706 self . insert (
703707 LintId :: of ( SINGLE_USE_LIFETIMES ) ,
704- ( Level :: Allow , LintLevelSource :: Default ) ,
708+ LevelAndSource { level : Level :: Allow , src : LintLevelSource :: Default } ,
705709 ) ;
706710 continue ;
707711 }
@@ -712,7 +716,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
712716 . meta_item_list ( )
713717 . is_some_and ( |l| ast:: attr:: list_contains_name ( & l, sym:: hidden) )
714718 {
715- self . insert ( LintId :: of ( MISSING_DOCS ) , ( Level :: Allow , LintLevelSource :: Default ) ) ;
719+ self . insert (
720+ LintId :: of ( MISSING_DOCS ) ,
721+ LevelAndSource { level : Level :: Allow , src : LintLevelSource :: Default } ,
722+ ) ;
716723 continue ;
717724 }
718725
@@ -920,7 +927,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
920927 let src = LintLevelSource :: Node { name, span : sp, reason } ;
921928 for & id in ids {
922929 if self . check_gated_lint ( id, sp, false ) {
923- self . insert_spec ( id, ( level, src) ) ;
930+ self . insert_spec ( id, LevelAndSource { level, src } ) ;
924931 }
925932 }
926933
@@ -951,7 +958,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
951958 }
952959
953960 if self . lint_added_lints && !is_crate_node {
954- for ( id, & ( level, ref src) ) in self . current_specs ( ) . iter ( ) {
961+ for ( id, & LevelAndSource { level, ref src } ) in self . current_specs ( ) . iter ( ) {
955962 if !id. lint . crate_level_only {
956963 continue ;
957964 }
@@ -989,10 +996,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
989996
990997 if self . lint_added_lints {
991998 let lint = builtin:: UNKNOWN_LINTS ;
992- let ( level, src ) = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
999+ let level = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
9931000 // FIXME: make this translatable
9941001 #[ allow( rustc:: diagnostic_outside_of_impl) ]
995- lint_level ( self . sess , lint, level, src , Some ( span. into ( ) ) , |lint| {
1002+ lint_level ( self . sess , lint, level, Some ( span. into ( ) ) , |lint| {
9961003 lint. primary_message ( fluent:: lint_unknown_gated_lint) ;
9971004 lint. arg ( "name" , lint_id. lint . name_lower ( ) ) ;
9981005 lint. note ( fluent:: lint_note) ;
@@ -1027,8 +1034,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10271034 span : Option < MultiSpan > ,
10281035 decorate : impl for <' a , ' b > FnOnce ( & ' b mut Diag < ' a , ( ) > ) ,
10291036 ) {
1030- let ( level, src ) = self . lint_level ( lint) ;
1031- lint_level ( self . sess , lint, level, src , span, decorate)
1037+ let level = self . lint_level ( lint) ;
1038+ lint_level ( self . sess , lint, level, span, decorate)
10321039 }
10331040
10341041 #[ track_caller]
@@ -1038,16 +1045,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10381045 span : MultiSpan ,
10391046 decorate : impl for < ' a > LintDiagnostic < ' a , ( ) > ,
10401047 ) {
1041- let ( level, src ) = self . lint_level ( lint) ;
1042- lint_level ( self . sess , lint, level, src , Some ( span) , |lint| {
1048+ let level = self . lint_level ( lint) ;
1049+ lint_level ( self . sess , lint, level, Some ( span) , |lint| {
10431050 decorate. decorate_lint ( lint) ;
10441051 } ) ;
10451052 }
10461053
10471054 #[ track_caller]
10481055 pub fn emit_lint ( & self , lint : & ' static Lint , decorate : impl for < ' a > LintDiagnostic < ' a , ( ) > ) {
1049- let ( level, src ) = self . lint_level ( lint) ;
1050- lint_level ( self . sess , lint, level, src , None , |lint| {
1056+ let level = self . lint_level ( lint) ;
1057+ lint_level ( self . sess , lint, level, None , |lint| {
10511058 decorate. decorate_lint ( lint) ;
10521059 } ) ;
10531060 }
0 commit comments