@@ -135,7 +135,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
135135 unstable_to_stable_ids : FxHashMap :: default ( ) ,
136136 empty : FxHashMap :: default ( ) ,
137137 } ,
138- warn_about_weird_lints : false ,
138+ lint_added_lints : false ,
139139 store,
140140 registered_tools : tcx. registered_tools ( ( ) ) ,
141141 } ;
@@ -164,7 +164,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
164164 empty : FxHashMap :: default ( ) ,
165165 attrs,
166166 } ,
167- warn_about_weird_lints : false ,
167+ lint_added_lints : false ,
168168 store,
169169 registered_tools : tcx. registered_tools ( ( ) ) ,
170170 } ;
@@ -451,7 +451,7 @@ pub struct LintLevelsBuilder<'s, P> {
451451 sess : & ' s Session ,
452452 features : & ' s Features ,
453453 provider : P ,
454- warn_about_weird_lints : bool ,
454+ lint_added_lints : bool ,
455455 store : & ' s LintStore ,
456456 registered_tools : & ' s RegisteredTools ,
457457}
@@ -464,15 +464,15 @@ impl<'s> LintLevelsBuilder<'s, TopDown> {
464464 pub ( crate ) fn new (
465465 sess : & ' s Session ,
466466 features : & ' s Features ,
467- warn_about_weird_lints : bool ,
467+ lint_added_lints : bool ,
468468 store : & ' s LintStore ,
469469 registered_tools : & ' s RegisteredTools ,
470470 ) -> Self {
471471 let mut builder = LintLevelsBuilder {
472472 sess,
473473 features,
474474 provider : TopDown { sets : LintLevelSets :: new ( ) , cur : COMMAND_LINE } ,
475- warn_about_weird_lints ,
475+ lint_added_lints ,
476476 store,
477477 registered_tools,
478478 } ;
@@ -642,7 +642,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
642642 //
643643 // This means that this only errors if we're truly lowering the lint
644644 // level from forbid.
645- if level != Level :: Forbid {
645+ if self . lint_added_lints && level != Level :: Forbid {
646646 if let Level :: Forbid = old_level {
647647 // Backwards compatibility check:
648648 //
@@ -968,7 +968,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
968968 continue ;
969969 }
970970
971- _ if !self . warn_about_weird_lints => { }
971+ _ if !self . lint_added_lints => { }
972972
973973 CheckLintNameResult :: Renamed ( ref replace) => {
974974 let suggestion =
@@ -1029,7 +1029,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10291029 }
10301030 }
10311031
1032- if !is_crate_node {
1032+ if self . lint_added_lints && !is_crate_node {
10331033 for ( id, & ( level, ref src) ) in self . current_specs ( ) . iter ( ) {
10341034 if !id. lint . crate_level_only {
10351035 continue ;
@@ -1054,33 +1054,33 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10541054 /// Checks if the lint is gated on a feature that is not enabled.
10551055 ///
10561056 /// Returns `true` if the lint's feature is enabled.
1057- // FIXME only emit this once for each attribute, instead of repeating it 4 times for
1058- // pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
10591057 #[ track_caller]
10601058 fn check_gated_lint ( & self , lint_id : LintId , span : Span , lint_from_cli : bool ) -> bool {
10611059 if let Some ( feature) = lint_id. lint . feature_gate {
10621060 if !self . features . active ( feature) {
1063- let lint = builtin:: UNKNOWN_LINTS ;
1064- let ( level, src) = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
1065- struct_lint_level (
1066- self . sess ,
1067- lint,
1068- level,
1069- src,
1070- Some ( span. into ( ) ) ,
1071- fluent:: lint_unknown_gated_lint,
1072- |lint| {
1073- lint. set_arg ( "name" , lint_id. lint . name_lower ( ) ) ;
1074- lint. note ( fluent:: lint_note) ;
1075- rustc_session:: parse:: add_feature_diagnostics_for_issue (
1076- lint,
1077- & self . sess . parse_sess ,
1078- feature,
1079- GateIssue :: Language ,
1080- lint_from_cli,
1081- ) ;
1082- } ,
1083- ) ;
1061+ if self . lint_added_lints {
1062+ let lint = builtin:: UNKNOWN_LINTS ;
1063+ let ( level, src) = self . lint_level ( builtin:: UNKNOWN_LINTS ) ;
1064+ struct_lint_level (
1065+ self . sess ,
1066+ lint,
1067+ level,
1068+ src,
1069+ Some ( span. into ( ) ) ,
1070+ fluent:: lint_unknown_gated_lint,
1071+ |lint| {
1072+ lint. set_arg ( "name" , lint_id. lint . name_lower ( ) ) ;
1073+ lint. note ( fluent:: lint_note) ;
1074+ rustc_session:: parse:: add_feature_diagnostics_for_issue (
1075+ lint,
1076+ & self . sess . parse_sess ,
1077+ feature,
1078+ GateIssue :: Language ,
1079+ lint_from_cli,
1080+ ) ;
1081+ } ,
1082+ ) ;
1083+ }
10841084 return false ;
10851085 }
10861086 }
0 commit comments