@@ -87,7 +87,7 @@ impl LintLevelSets {
87
87
let level = reveal_actual_level ( level, & mut src, sess, lint, |id| {
88
88
self . raw_lint_id_level ( id, idx, aux)
89
89
} ) ;
90
- ( level, src)
90
+ LevelAndSource { level, src }
91
91
}
92
92
93
93
fn raw_lint_id_level (
@@ -97,14 +97,14 @@ impl LintLevelSets {
97
97
aux : Option < & FxIndexMap < LintId , LevelAndSource > > ,
98
98
) -> ( Option < Level > , LintLevelSource ) {
99
99
if let Some ( specs) = aux
100
- && let Some ( & ( level, src) ) = specs. get ( & id)
100
+ && let Some ( & LevelAndSource { level, src } ) = specs. get ( & id)
101
101
{
102
102
return ( Some ( level) , src) ;
103
103
}
104
104
105
105
loop {
106
106
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) {
108
108
return ( Some ( level) , src) ;
109
109
}
110
110
if idx == COMMAND_LINE {
@@ -131,8 +131,8 @@ fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
131
131
} )
132
132
. filter_map ( |lint| {
133
133
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 ) )
136
136
&& lint. default_level ( tcx. sess . edition ( ) ) == Level :: Allow
137
137
{
138
138
Some ( LintId :: of ( lint) )
@@ -582,15 +582,15 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
582
582
} ;
583
583
for id in ids {
584
584
// ForceWarn and Forbid cannot be overridden
585
- if let Some ( ( Level :: ForceWarn ( _) | Level :: Forbid , _ ) ) =
585
+ if let Some ( LevelAndSource { level : Level :: ForceWarn ( _) | Level :: Forbid , .. } ) =
586
586
self . current_specs ( ) . get ( & id)
587
587
{
588
588
continue ;
589
589
}
590
590
591
591
if self . check_gated_lint ( id, DUMMY_SP , true ) {
592
592
let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
593
- self . insert ( id, ( level, src) ) ;
593
+ self . insert ( id, LevelAndSource { level, src } ) ;
594
594
}
595
595
}
596
596
}
@@ -599,8 +599,9 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
599
599
/// Attempts to insert the `id` to `level_src` map entry. If unsuccessful
600
600
/// (e.g. if a forbid was already inserted on the same scope), then emits a
601
601
/// 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 ) ;
604
605
605
606
// Setting to a non-forbid level is an error if the lint previously had
606
607
// a forbid level. Note that this is not necessarily true even with a
@@ -680,13 +681,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
680
681
681
682
match ( old_level, level) {
682
683
// 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
+ ) ,
686
688
// 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
+ }
688
692
// Set the lint level as normal
689
- _ => self . insert ( id, ( level, src) ) ,
693
+ _ => self . insert ( id, LevelAndSource { level, src } ) ,
690
694
} ;
691
695
}
692
696
@@ -701,7 +705,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
701
705
if attr. has_name ( sym:: automatically_derived) {
702
706
self . insert (
703
707
LintId :: of ( SINGLE_USE_LIFETIMES ) ,
704
- ( Level :: Allow , LintLevelSource :: Default ) ,
708
+ LevelAndSource { level : Level :: Allow , src : LintLevelSource :: Default } ,
705
709
) ;
706
710
continue ;
707
711
}
@@ -712,7 +716,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
712
716
. meta_item_list ( )
713
717
. is_some_and ( |l| ast:: attr:: list_contains_name ( & l, sym:: hidden) )
714
718
{
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
+ ) ;
716
723
continue ;
717
724
}
718
725
@@ -920,7 +927,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
920
927
let src = LintLevelSource :: Node { name, span : sp, reason } ;
921
928
for & id in ids {
922
929
if self . check_gated_lint ( id, sp, false ) {
923
- self . insert_spec ( id, ( level, src) ) ;
930
+ self . insert_spec ( id, LevelAndSource { level, src } ) ;
924
931
}
925
932
}
926
933
@@ -951,7 +958,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
951
958
}
952
959
953
960
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 ( ) {
955
962
if !id. lint . crate_level_only {
956
963
continue ;
957
964
}
@@ -989,10 +996,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
989
996
990
997
if self . lint_added_lints {
991
998
let lint = builtin:: UNKNOWN_LINTS ;
992
- let ( level, src ) = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
999
+ let level = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
993
1000
// FIXME: make this translatable
994
1001
#[ 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| {
996
1003
lint. primary_message ( fluent:: lint_unknown_gated_lint) ;
997
1004
lint. arg ( "name" , lint_id. lint . name_lower ( ) ) ;
998
1005
lint. note ( fluent:: lint_note) ;
@@ -1027,8 +1034,8 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
1027
1034
span : Option < MultiSpan > ,
1028
1035
decorate : impl for <' a , ' b > FnOnce ( & ' b mut Diag < ' a , ( ) > ) ,
1029
1036
) {
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)
1032
1039
}
1033
1040
1034
1041
#[ track_caller]
@@ -1038,16 +1045,16 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
1038
1045
span : MultiSpan ,
1039
1046
decorate : impl for < ' a > LintDiagnostic < ' a , ( ) > ,
1040
1047
) {
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| {
1043
1050
decorate. decorate_lint ( lint) ;
1044
1051
} ) ;
1045
1052
}
1046
1053
1047
1054
#[ track_caller]
1048
1055
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| {
1051
1058
decorate. decorate_lint ( lint) ;
1052
1059
} ) ;
1053
1060
}
0 commit comments