22//! It also serves as an input to the parser itself.
33
44use crate :: config:: CheckCfg ;
5- use crate :: errors:: { FeatureDiagnosticForIssue , FeatureDiagnosticHelp , FeatureGateError } ;
5+ use crate :: errors:: {
6+ ExprParenthesesNeeded , FeatureDiagnosticForIssue , FeatureDiagnosticHelp , FeatureGateError ,
7+ } ;
68use crate :: lint:: {
79 builtin:: UNSTABLE_SYNTAX_PRE_EXPANSION , BufferedEarlyLint , BuiltinLintDiagnostics , Lint , LintId ,
810} ;
@@ -11,7 +13,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
1113use rustc_data_structures:: sync:: { Lock , Lrc } ;
1214use rustc_errors:: { emitter:: SilentEmitter , ColorConfig , Handler } ;
1315use rustc_errors:: {
14- fallback_fluent_bundle, Applicability , Diagnostic , DiagnosticBuilder , DiagnosticId ,
16+ fallback_fluent_bundle, AddToDiagnostic , Diagnostic , DiagnosticBuilder , DiagnosticId ,
1517 DiagnosticMessage , EmissionGuarantee , ErrorGuaranteed , IntoDiagnostic , MultiSpan , StashKey ,
1618} ;
1719use rustc_feature:: { find_feature_issue, GateIssue , UnstableFeatures } ;
@@ -325,11 +327,7 @@ impl ParseSess {
325327 /// Extend an error with a suggestion to wrap an expression with parentheses to allow the
326328 /// parser to continue parsing the following operation as part of the same expression.
327329 pub fn expr_parentheses_needed ( & self , err : & mut Diagnostic , span : Span ) {
328- err. multipart_suggestion (
329- "parentheses are required to parse this as an expression" ,
330- vec ! [ ( span. shrink_to_lo( ) , "(" . to_string( ) ) , ( span. shrink_to_hi( ) , ")" . to_string( ) ) ] ,
331- Applicability :: MachineApplicable ,
332- ) ;
330+ ExprParenthesesNeeded :: surrounding ( span) . add_to_diagnostic ( err) ;
333331 }
334332
335333 pub fn save_proc_macro_span ( & self , span : Span ) -> usize {
0 commit comments