@@ -12,7 +12,7 @@ use rustc_errors::{
1212 ColorConfig , Diag , DiagCtxt , DiagCtxtHandle , DiagMessage , EmissionGuarantee , MultiSpan ,
1313 StashKey , fallback_fluent_bundle,
1414} ;
15- use rustc_feature:: { GateIssue , UnstableFeatures , find_feature_issue } ;
15+ use rustc_feature:: { GateIssues , UnstableFeatures , find_feature_issues } ;
1616use rustc_span:: edition:: Edition ;
1717use rustc_span:: hygiene:: ExpnId ;
1818use rustc_span:: source_map:: { FilePathMapping , SourceMap } ;
@@ -87,21 +87,21 @@ pub fn feature_err(
8787 span : impl Into < MultiSpan > ,
8888 explain : impl Into < DiagMessage > ,
8989) -> Diag < ' _ > {
90- feature_err_issue ( sess, feature, span, GateIssue :: Language , explain)
90+ feature_err_issues ( sess, & [ feature] , span, GateIssues :: Language , explain)
9191}
9292
9393/// Construct a diagnostic for a feature gate error.
9494///
9595/// This variant allows you to control whether it is a library or language feature.
9696/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
9797#[ 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 ] ,
101101 span : impl Into < MultiSpan > ,
102- issue : GateIssue ,
102+ issues : GateIssues ,
103103 explain : impl Into < DiagMessage > ,
104- ) -> Diag < ' _ > {
104+ ) -> Diag < ' a > {
105105 let span = span. into ( ) ;
106106
107107 // Cancel an earlier warning for this same error, if it exists.
@@ -112,7 +112,7 @@ pub fn feature_err_issue(
112112 }
113113
114114 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 ) ;
116116 err
117117}
118118
@@ -121,7 +121,7 @@ pub fn feature_err_issue(
121121/// This diagnostic is only a warning and *does not cause compilation to fail*.
122122#[ track_caller]
123123pub 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) ;
125125}
126126
127127/// 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
133133#[ allow( rustc:: diagnostic_outside_of_impl) ]
134134#[ allow( rustc:: untranslatable_diagnostic) ]
135135#[ track_caller]
136- pub fn feature_warn_issue (
136+ pub fn feature_warn_issues (
137137 sess : & Session ,
138- feature : Symbol ,
138+ features : & [ Symbol ] ,
139139 span : Span ,
140- issue : GateIssue ,
140+ issues : GateIssues ,
141141 explain : & ' static str ,
142142) {
143143 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 ) ;
145145
146146 // Decorate this as a future-incompatibility lint as in rustc_middle::lint::lint_level
147147 let lint = UNSTABLE_SYNTAX_PRE_EXPANSION ;
@@ -161,7 +161,7 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
161161 sess : & Session ,
162162 feature : Symbol ,
163163) {
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 ) ;
165165}
166166
167167/// Adds the diagnostics for a feature to an existing error.
@@ -170,20 +170,21 @@ pub fn add_feature_diagnostics<G: EmissionGuarantee>(
170170/// Almost always, you want to use this for a language feature. If so, prefer
171171/// `add_feature_diagnostics`.
172172#[ 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 > (
174174 err : & mut Diag < ' _ , G > ,
175175 sess : & Session ,
176- feature : Symbol ,
177- issue : GateIssue ,
176+ features : & [ Symbol ] ,
177+ issues : GateIssues ,
178178 feature_from_cli : bool ,
179179 inject_span : Option < Span > ,
180180) {
181- if let Some ( n ) = find_feature_issue ( feature , issue ) {
181+ for n in find_feature_issues ( features , issues ) {
182182 err. subdiagnostic ( FeatureDiagnosticForIssue { n } ) ;
183183 }
184184
185185 // #23973: do not suggest `#![feature(...)]` if we are in beta/stable
186186 if sess. psess . unstable_features . is_nightly_build ( ) {
187+ let feature: String = features. iter ( ) . map ( |s| s. as_str ( ) ) . intersperse ( ", " ) . collect ( ) ;
187188 if feature_from_cli {
188189 err. subdiagnostic ( CliFeatureDiagnosticHelp { feature } ) ;
189190 } else if let Some ( span) = inject_span {
0 commit comments