@@ -12,7 +12,7 @@ use rustc_ast as ast;
1212use rustc_ast_pretty:: pprust;
1313use rustc_data_structures:: fx:: FxHashMap ;
1414use rustc_errors:: { DecorateLint , DiagnosticBuilder , DiagnosticMessage , MultiSpan } ;
15- use rustc_feature:: Features ;
15+ use rustc_feature:: { Features , GateIssue } ;
1616use rustc_hir as hir;
1717use rustc_hir:: intravisit:: { self , Visitor } ;
1818use rustc_hir:: HirId ;
@@ -24,12 +24,14 @@ use rustc_middle::lint::{
2424} ;
2525use rustc_middle:: query:: Providers ;
2626use rustc_middle:: ty:: { RegisteredTools , TyCtxt } ;
27- use rustc_session:: lint:: builtin:: { RENAMED_AND_REMOVED_LINTS , UNKNOWN_LINTS , UNUSED_ATTRIBUTES } ;
2827use rustc_session:: lint:: {
29- builtin:: { self , FORBIDDEN_LINT_GROUPS , SINGLE_USE_LIFETIMES , UNFULFILLED_LINT_EXPECTATIONS } ,
28+ builtin:: {
29+ self , FORBIDDEN_LINT_GROUPS , RENAMED_AND_REMOVED_LINTS , SINGLE_USE_LIFETIMES ,
30+ UNFULFILLED_LINT_EXPECTATIONS , UNKNOWN_LINTS , UNUSED_ATTRIBUTES ,
31+ } ,
3032 Level , Lint , LintExpectationId , LintId ,
3133} ;
32- use rustc_session:: parse:: { add_feature_diagnostics , feature_err} ;
34+ use rustc_session:: parse:: feature_err;
3335use rustc_session:: Session ;
3436use rustc_span:: symbol:: { sym, Symbol } ;
3537use rustc_span:: { Span , DUMMY_SP } ;
@@ -566,7 +568,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
566568 continue ;
567569 }
568570
569- if self . check_gated_lint ( id, DUMMY_SP ) {
571+ if self . check_gated_lint ( id, DUMMY_SP , true ) {
570572 let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
571573 self . insert ( id, ( level, src) ) ;
572574 }
@@ -837,7 +839,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
837839 reason,
838840 } ;
839841 for & id in * ids {
840- if self . check_gated_lint ( id, attr. span ) {
842+ if self . check_gated_lint ( id, attr. span , false ) {
841843 self . insert_spec ( id, ( level, src) ) ;
842844 }
843845 }
@@ -854,7 +856,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
854856 reason,
855857 } ;
856858 for & id in ids {
857- if self . check_gated_lint ( id, attr. span ) {
859+ if self . check_gated_lint ( id, attr. span , false ) {
858860 self . insert_spec ( id, ( level, src) ) ;
859861 }
860862 }
@@ -955,7 +957,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
955957 reason,
956958 } ;
957959 for & id in ids {
958- if self . check_gated_lint ( id, attr. span ) {
960+ if self . check_gated_lint ( id, attr. span , false ) {
959961 self . insert_spec ( id, ( level, src) ) ;
960962 }
961963 }
@@ -1000,7 +1002,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10001002 // FIXME only emit this once for each attribute, instead of repeating it 4 times for
10011003 // pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
10021004 #[ track_caller]
1003- fn check_gated_lint ( & self , lint_id : LintId , span : Span ) -> bool {
1005+ fn check_gated_lint ( & self , lint_id : LintId , span : Span , lint_from_cli : bool ) -> bool {
10041006 if let Some ( feature) = lint_id. lint . feature_gate {
10051007 if !self . features . enabled ( feature) {
10061008 let lint = builtin:: UNKNOWN_LINTS ;
@@ -1015,7 +1017,13 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10151017 |lint| {
10161018 lint. set_arg ( "name" , lint_id. lint . name_lower ( ) ) ;
10171019 lint. note ( fluent:: lint_note) ;
1018- add_feature_diagnostics ( lint, & self . sess . parse_sess , feature) ;
1020+ rustc_session:: parse:: add_feature_diagnostics_for_issue (
1021+ lint,
1022+ & self . sess . parse_sess ,
1023+ feature,
1024+ GateIssue :: Language ,
1025+ lint_from_cli,
1026+ ) ;
10191027 lint
10201028 } ,
10211029 ) ;
0 commit comments