@@ -12,7 +12,7 @@ use rustc_errors::{
12
12
ColorConfig , Diag , DiagCtxt , DiagCtxtHandle , DiagMessage , EmissionGuarantee , MultiSpan ,
13
13
StashKey , fallback_fluent_bundle,
14
14
} ;
15
- use rustc_feature:: { GateIssue , UnstableFeatures , find_feature_issue } ;
15
+ use rustc_feature:: { GateIssues , UnstableFeatures , find_feature_issues } ;
16
16
use rustc_span:: edition:: Edition ;
17
17
use rustc_span:: hygiene:: ExpnId ;
18
18
use rustc_span:: source_map:: { FilePathMapping , SourceMap } ;
@@ -87,21 +87,21 @@ pub fn feature_err(
87
87
span : impl Into < MultiSpan > ,
88
88
explain : impl Into < DiagMessage > ,
89
89
) -> Diag < ' _ > {
90
- feature_err_issue ( sess, feature, span, GateIssue :: Language , explain)
90
+ feature_err_issues ( sess, & [ feature] , span, GateIssues :: Language , explain)
91
91
}
92
92
93
93
/// Construct a diagnostic for a feature gate error.
94
94
///
95
95
/// This variant allows you to control whether it is a library or language feature.
96
96
/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
97
97
#[ track_caller]
98
- pub fn feature_err_issue (
99
- sess : & Session ,
100
- feature : Symbol ,
98
+ pub fn feature_err_issues < ' a > (
99
+ sess : & ' a Session ,
100
+ features : & [ Symbol ] ,
101
101
span : impl Into < MultiSpan > ,
102
- issue : GateIssue ,
102
+ issues : GateIssues ,
103
103
explain : impl Into < DiagMessage > ,
104
- ) -> Diag < ' _ > {
104
+ ) -> Diag < ' a > {
105
105
let span = span. into ( ) ;
106
106
107
107
// Cancel an earlier warning for this same error, if it exists.
@@ -112,7 +112,7 @@ pub fn feature_err_issue(
112
112
}
113
113
114
114
let mut err = sess. dcx ( ) . create_err ( FeatureGateError { span, explain : explain. into ( ) } ) ;
115
- add_feature_diagnostics_for_issue ( & mut err, sess, feature , issue , false , None ) ;
115
+ add_feature_diagnostics_for_issues ( & mut err, sess, features , issues , false , None ) ;
116
116
err
117
117
}
118
118
@@ -121,7 +121,7 @@ pub fn feature_err_issue(
121
121
/// This diagnostic is only a warning and *does not cause compilation to fail*.
122
122
#[ track_caller]
123
123
pub fn feature_warn ( sess : & Session , feature : Symbol , span : Span , explain : & ' static str ) {
124
- feature_warn_issue ( sess, feature, span, GateIssue :: Language , explain) ;
124
+ feature_warn_issues ( sess, & [ feature] , span, GateIssues :: Language , explain) ;
125
125
}
126
126
127
127
/// Construct a future incompatibility diagnostic for a feature gate.
@@ -133,15 +133,15 @@ pub fn feature_warn(sess: &Session, feature: Symbol, span: Span, explain: &'stat
133
133
#[ allow( rustc:: diagnostic_outside_of_impl) ]
134
134
#[ allow( rustc:: untranslatable_diagnostic) ]
135
135
#[ track_caller]
136
- pub fn feature_warn_issue (
136
+ pub fn feature_warn_issues (
137
137
sess : & Session ,
138
- feature : Symbol ,
138
+ features : & [ Symbol ] ,
139
139
span : Span ,
140
- issue : GateIssue ,
140
+ issues : GateIssues ,
141
141
explain : & ' static str ,
142
142
) {
143
143
let mut err = sess. dcx ( ) . struct_span_warn ( span, explain) ;
144
- add_feature_diagnostics_for_issue ( & mut err, sess, feature , issue , false , None ) ;
144
+ add_feature_diagnostics_for_issues ( & mut err, sess, features , issues , false , None ) ;
145
145
146
146
// Decorate this as a future-incompatibility lint as in rustc_middle::lint::lint_level
147
147
let lint = UNSTABLE_SYNTAX_PRE_EXPANSION ;
@@ -161,7 +161,7 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
161
161
sess : & Session ,
162
162
feature : Symbol ,
163
163
) {
164
- add_feature_diagnostics_for_issue ( err, sess, feature, GateIssue :: Language , false , None ) ;
164
+ add_feature_diagnostics_for_issues ( err, sess, & [ feature] , GateIssues :: Language , false , None ) ;
165
165
}
166
166
167
167
/// Adds the diagnostics for a feature to an existing error.
@@ -170,20 +170,21 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
170
170
/// Almost always, you want to use this for a language feature. If so, prefer
171
171
/// `add_feature_diagnostics`.
172
172
#[ allow( rustc:: diagnostic_outside_of_impl) ] // FIXME
173
- pub fn add_feature_diagnostics_for_issue < G : EmissionGuarantee > (
173
+ pub fn add_feature_diagnostics_for_issues < G : EmissionGuarantee > (
174
174
err : & mut Diag < ' _ , G > ,
175
175
sess : & Session ,
176
- feature : Symbol ,
177
- issue : GateIssue ,
176
+ features : & [ Symbol ] ,
177
+ issues : GateIssues ,
178
178
feature_from_cli : bool ,
179
179
inject_span : Option < Span > ,
180
180
) {
181
- if let Some ( n ) = find_feature_issue ( feature , issue ) {
181
+ for n in find_feature_issues ( features , issues ) {
182
182
err. subdiagnostic ( FeatureDiagnosticForIssue { n } ) ;
183
183
}
184
184
185
185
// #23973: do not suggest `#![feature(...)]` if we are in beta/stable
186
186
if sess. psess . unstable_features . is_nightly_build ( ) {
187
+ let feature: String = features. iter ( ) . map ( |s| s. as_str ( ) ) . intersperse ( ", " ) . collect ( ) ;
187
188
if feature_from_cli {
188
189
err. subdiagnostic ( CliFeatureDiagnosticHelp { feature } ) ;
189
190
} else if let Some ( span) = inject_span {
0 commit comments