@@ -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) )
@@ -595,15 +595,15 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
595595 } ;
596596 for id in ids {
597597 // ForceWarn and Forbid cannot be overridden
598- if let Some ( ( Level :: ForceWarn ( _) | Level :: Forbid , _ ) ) =
598+ if let Some ( LevelAndSource { level : Level :: ForceWarn ( _) | Level :: Forbid , .. } ) =
599599 self . current_specs ( ) . get ( & id)
600600 {
601601 continue ;
602602 }
603603
604604 if self . check_gated_lint ( id, DUMMY_SP , true ) {
605605 let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
606- self . insert ( id, ( level, src) ) ;
606+ self . insert ( id, LevelAndSource { level, src } ) ;
607607 }
608608 }
609609 }
@@ -612,8 +612,9 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
612612 /// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
613613 /// (e.g. if a forbid was already inserted on the same scope), then emits a
614614 /// diagnostic with no change to `specs`.
615- fn insert_spec ( & mut self , id : LintId , ( level, src) : LevelAndSource ) {
616- let ( old_level, old_src) = self . provider . get_lint_level ( id. lint , self . sess ) ;
615+ fn insert_spec ( & mut self , id : LintId , LevelAndSource { level, src } : LevelAndSource ) {
616+ let LevelAndSource { level : old_level, src : old_src } =
617+ self . provider . get_lint_level ( id. lint , self . sess ) ;
617618
618619 // Setting to a non-forbid level is an error if the lint previously had
619620 // a forbid level. Note that this is not necessarily true even with a
@@ -693,13 +694,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
693694
694695 match ( old_level, level) {
695696 // If the new level is an expectation store it in `ForceWarn`
696- ( Level :: ForceWarn ( _) , Level :: Expect ( expectation_id) ) => {
697- self . insert ( id, ( Level :: ForceWarn ( Some ( expectation_id) ) , old_src) )
698- }
697+ ( Level :: ForceWarn ( _) , Level :: Expect ( expectation_id) ) => self . insert (
698+ id,
699+ LevelAndSource { level : Level :: ForceWarn ( Some ( expectation_id) ) , src : old_src } ,
700+ ) ,
699701 // Keep `ForceWarn` level but drop the expectation
700- ( Level :: ForceWarn ( _) , _) => self . insert ( id, ( Level :: ForceWarn ( None ) , old_src) ) ,
702+ ( Level :: ForceWarn ( _) , _) => {
703+ self . insert ( id, LevelAndSource { level : Level :: ForceWarn ( None ) , src : old_src } )
704+ }
701705 // Set the lint level as normal
702- _ => self . insert ( id, ( level, src) ) ,
706+ _ => self . insert ( id, LevelAndSource { level, src } ) ,
703707 } ;
704708 }
705709
@@ -714,7 +718,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
714718 if attr. has_name ( sym:: automatically_derived) {
715719 self . insert (
716720 LintId :: of ( SINGLE_USE_LIFETIMES ) ,
717- ( Level :: Allow , LintLevelSource :: Default ) ,
721+ LevelAndSource { level : Level :: Allow , src : LintLevelSource :: Default } ,
718722 ) ;
719723 continue ;
720724 }
@@ -725,7 +729,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
725729 . meta_item_list ( )
726730 . is_some_and ( |l| ast:: attr:: list_contains_name ( & l, sym:: hidden) )
727731 {
728- self . insert ( LintId :: of ( MISSING_DOCS ) , ( Level :: Allow , LintLevelSource :: Default ) ) ;
732+ self . insert (
733+ LintId :: of ( MISSING_DOCS ) ,
734+ LevelAndSource { level : Level :: Allow , src : LintLevelSource :: Default } ,
735+ ) ;
729736 continue ;
730737 }
731738
@@ -933,7 +940,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
933940 let src = LintLevelSource :: Node { name, span : sp, reason } ;
934941 for & id in ids {
935942 if self . check_gated_lint ( id, sp, false ) {
936- self . insert_spec ( id, ( level, src) ) ;
943+ self . insert_spec ( id, LevelAndSource { level, src } ) ;
937944 }
938945 }
939946
@@ -964,7 +971,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
964971 }
965972
966973 if self . lint_added_lints && !is_crate_node {
967- for ( id, & ( level, ref src) ) in self . current_specs ( ) . iter ( ) {
974+ for ( id, & LevelAndSource { level, ref src } ) in self . current_specs ( ) . iter ( ) {
968975 if !id. lint . crate_level_only {
969976 continue ;
970977 }
@@ -1002,10 +1009,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10021009
10031010 if self . lint_added_lints {
10041011 let lint = builtin:: UNKNOWN_LINTS ;
1005- let ( level, src ) = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
1012+ let level = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
10061013 // FIXME: make this translatable
10071014 #[ allow( rustc:: diagnostic_outside_of_impl) ]
1008- lint_level ( self . sess , lint, level, src , Some ( span. into ( ) ) , |lint| {
1015+ lint_level ( self . sess , lint, level, Some ( span. into ( ) ) , |lint| {
10091016 lint. primary_message ( fluent:: lint_unknown_gated_lint) ;
10101017 lint. arg ( "name" , lint_id. lint . name_lower ( ) ) ;
10111018 lint. note ( fluent:: lint_note) ;
@@ -1040,8 +1047,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10401047 span : Option < MultiSpan > ,
10411048 decorate : impl for <' a , ' b > FnOnce ( & ' b mut Diag < ' a , ( ) > ) ,
10421049 ) {
1043- let ( level, src ) = self . lint_level ( lint) ;
1044- lint_level ( self . sess , lint, level, src , span, decorate)
1050+ let level = self . lint_level ( lint) ;
1051+ lint_level ( self . sess , lint, level, span, decorate)
10451052 }
10461053
10471054 #[ track_caller]
@@ -1051,16 +1058,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10511058 span : MultiSpan ,
10521059 decorate : impl for < ' a > LintDiagnostic < ' a , ( ) > ,
10531060 ) {
1054- let ( level, src ) = self . lint_level ( lint) ;
1055- lint_level ( self . sess , lint, level, src , Some ( span) , |lint| {
1061+ let level = self . lint_level ( lint) ;
1062+ lint_level ( self . sess , lint, level, Some ( span) , |lint| {
10561063 decorate. decorate_lint ( lint) ;
10571064 } ) ;
10581065 }
10591066
10601067 #[ track_caller]
10611068 pub fn emit_lint ( & self , lint : & ' static Lint , decorate : impl for < ' a > LintDiagnostic < ' a , ( ) > ) {
1062- let ( level, src ) = self . lint_level ( lint) ;
1063- lint_level ( self . sess , lint, level, src , None , |lint| {
1069+ let level = self . lint_level ( lint) ;
1070+ lint_level ( self . sess , lint, level, None , |lint| {
10641071 decorate. decorate_lint ( lint) ;
10651072 } ) ;
10661073 }
0 commit comments