@@ -135,7 +135,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
135
135
unstable_to_stable_ids : FxHashMap :: default ( ) ,
136
136
empty : FxHashMap :: default ( ) ,
137
137
} ,
138
- warn_about_weird_lints : false ,
138
+ lint_added_lints : false ,
139
139
store,
140
140
registered_tools : tcx. registered_tools ( ( ) ) ,
141
141
} ;
@@ -164,7 +164,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
164
164
empty : FxHashMap :: default ( ) ,
165
165
attrs,
166
166
} ,
167
- warn_about_weird_lints : false ,
167
+ lint_added_lints : false ,
168
168
store,
169
169
registered_tools : tcx. registered_tools ( ( ) ) ,
170
170
} ;
@@ -451,7 +451,7 @@ pub struct LintLevelsBuilder<'s, P> {
451
451
sess : & ' s Session ,
452
452
features : & ' s Features ,
453
453
provider : P ,
454
- warn_about_weird_lints : bool ,
454
+ lint_added_lints : bool ,
455
455
store : & ' s LintStore ,
456
456
registered_tools : & ' s RegisteredTools ,
457
457
}
@@ -464,15 +464,15 @@ impl<'s> LintLevelsBuilder<'s, TopDown> {
464
464
pub ( crate ) fn new (
465
465
sess : & ' s Session ,
466
466
features : & ' s Features ,
467
- warn_about_weird_lints : bool ,
467
+ lint_added_lints : bool ,
468
468
store : & ' s LintStore ,
469
469
registered_tools : & ' s RegisteredTools ,
470
470
) -> Self {
471
471
let mut builder = LintLevelsBuilder {
472
472
sess,
473
473
features,
474
474
provider : TopDown { sets : LintLevelSets :: new ( ) , cur : COMMAND_LINE } ,
475
- warn_about_weird_lints ,
475
+ lint_added_lints ,
476
476
store,
477
477
registered_tools,
478
478
} ;
@@ -642,7 +642,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
642
642
//
643
643
// This means that this only errors if we're truly lowering the lint
644
644
// level from forbid.
645
- if level != Level :: Forbid {
645
+ if self . lint_added_lints && level != Level :: Forbid {
646
646
if let Level :: Forbid = old_level {
647
647
// Backwards compatibility check:
648
648
//
@@ -968,7 +968,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
968
968
continue ;
969
969
}
970
970
971
- _ if !self . warn_about_weird_lints => { }
971
+ _ if !self . lint_added_lints => { }
972
972
973
973
CheckLintNameResult :: Renamed ( ref replace) => {
974
974
let suggestion =
@@ -1029,7 +1029,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
1029
1029
}
1030
1030
}
1031
1031
1032
- if !is_crate_node {
1032
+ if self . lint_added_lints && !is_crate_node {
1033
1033
for ( id, & ( level, ref src) ) in self . current_specs ( ) . iter ( ) {
1034
1034
if !id. lint . crate_level_only {
1035
1035
continue ;
@@ -1054,33 +1054,33 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
1054
1054
/// Checks if the lint is gated on a feature that is not enabled.
1055
1055
///
1056
1056
/// 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`.
1059
1057
#[ track_caller]
1060
1058
fn check_gated_lint ( & self , lint_id : LintId , span : Span , lint_from_cli : bool ) -> bool {
1061
1059
if let Some ( feature) = lint_id. lint . feature_gate {
1062
1060
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
+ }
1084
1084
return false ;
1085
1085
}
1086
1086
}
0 commit comments