2
2
//! It also serves as an input to the parser itself.
3
3
4
4
use crate :: config:: CheckCfg ;
5
- use crate :: errors:: { FeatureDiagnosticForIssue , FeatureDiagnosticHelp , FeatureGateError } ;
5
+ use crate :: errors:: {
6
+ ExprParenthesesNeeded , FeatureDiagnosticForIssue , FeatureDiagnosticHelp , FeatureGateError ,
7
+ } ;
6
8
use crate :: lint:: {
7
9
builtin:: UNSTABLE_SYNTAX_PRE_EXPANSION , BufferedEarlyLint , BuiltinLintDiagnostics , Lint , LintId ,
8
10
} ;
@@ -11,7 +13,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
11
13
use rustc_data_structures:: sync:: { Lock , Lrc } ;
12
14
use rustc_errors:: { emitter:: SilentEmitter , ColorConfig , Handler } ;
13
15
use rustc_errors:: {
14
- fallback_fluent_bundle, Applicability , Diagnostic , DiagnosticBuilder , DiagnosticId ,
16
+ fallback_fluent_bundle, AddToDiagnostic , Diagnostic , DiagnosticBuilder , DiagnosticId ,
15
17
DiagnosticMessage , EmissionGuarantee , ErrorGuaranteed , IntoDiagnostic , MultiSpan , StashKey ,
16
18
} ;
17
19
use rustc_feature:: { find_feature_issue, GateIssue , UnstableFeatures } ;
@@ -325,11 +327,7 @@ impl ParseSess {
325
327
/// Extend an error with a suggestion to wrap an expression with parentheses to allow the
326
328
/// parser to continue parsing the following operation as part of the same expression.
327
329
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) ;
333
331
}
334
332
335
333
pub fn save_proc_macro_span ( & self , span : Span ) -> usize {
0 commit comments