@@ -12,7 +12,7 @@ use rustc_ast as ast;
12
12
use rustc_ast_pretty:: pprust;
13
13
use rustc_data_structures:: fx:: FxHashMap ;
14
14
use rustc_errors:: { DecorateLint , DiagnosticBuilder , DiagnosticMessage , MultiSpan } ;
15
- use rustc_feature:: Features ;
15
+ use rustc_feature:: { Features , GateIssue } ;
16
16
use rustc_hir as hir;
17
17
use rustc_hir:: intravisit:: { self , Visitor } ;
18
18
use rustc_hir:: HirId ;
@@ -24,12 +24,14 @@ use rustc_middle::lint::{
24
24
} ;
25
25
use rustc_middle:: query:: Providers ;
26
26
use rustc_middle:: ty:: { RegisteredTools , TyCtxt } ;
27
- use rustc_session:: lint:: builtin:: { RENAMED_AND_REMOVED_LINTS , UNKNOWN_LINTS , UNUSED_ATTRIBUTES } ;
28
27
use 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
+ } ,
30
32
Level , Lint , LintExpectationId , LintId ,
31
33
} ;
32
- use rustc_session:: parse:: { add_feature_diagnostics , feature_err} ;
34
+ use rustc_session:: parse:: feature_err;
33
35
use rustc_session:: Session ;
34
36
use rustc_span:: symbol:: { sym, Symbol } ;
35
37
use rustc_span:: { Span , DUMMY_SP } ;
@@ -566,7 +568,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
566
568
continue ;
567
569
}
568
570
569
- if self . check_gated_lint ( id, DUMMY_SP ) {
571
+ if self . check_gated_lint ( id, DUMMY_SP , true ) {
570
572
let src = LintLevelSource :: CommandLine ( lint_flag_val, orig_level) ;
571
573
self . insert ( id, ( level, src) ) ;
572
574
}
@@ -837,7 +839,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
837
839
reason,
838
840
} ;
839
841
for & id in * ids {
840
- if self . check_gated_lint ( id, attr. span ) {
842
+ if self . check_gated_lint ( id, attr. span , false ) {
841
843
self . insert_spec ( id, ( level, src) ) ;
842
844
}
843
845
}
@@ -854,7 +856,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
854
856
reason,
855
857
} ;
856
858
for & id in ids {
857
- if self . check_gated_lint ( id, attr. span ) {
859
+ if self . check_gated_lint ( id, attr. span , false ) {
858
860
self . insert_spec ( id, ( level, src) ) ;
859
861
}
860
862
}
@@ -955,7 +957,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
955
957
reason,
956
958
} ;
957
959
for & id in ids {
958
- if self . check_gated_lint ( id, attr. span ) {
960
+ if self . check_gated_lint ( id, attr. span , false ) {
959
961
self . insert_spec ( id, ( level, src) ) ;
960
962
}
961
963
}
@@ -1000,7 +1002,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
1000
1002
// FIXME only emit this once for each attribute, instead of repeating it 4 times for
1001
1003
// pre-expansion lints, post-expansion lints, `shallow_lint_levels_on` and `lint_expectations`.
1002
1004
#[ 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 {
1004
1006
if let Some ( feature) = lint_id. lint . feature_gate {
1005
1007
if !self . features . enabled ( feature) {
1006
1008
let lint = builtin:: UNKNOWN_LINTS ;
@@ -1015,7 +1017,13 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
1015
1017
|lint| {
1016
1018
lint. set_arg ( "name" , lint_id. lint . name_lower ( ) ) ;
1017
1019
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
+ ) ;
1019
1027
lint
1020
1028
} ,
1021
1029
) ;
0 commit comments