Use multispan suggestions more often
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
This commit is contained in:
parent
5fb3394cbd
commit
0b8f192cfe
61 changed files with 661 additions and 442 deletions
|
@ -228,20 +228,12 @@ impl ParseSess {
|
|||
|
||||
/// Extend an error with a suggestion to wrap an expression with parentheses to allow the
|
||||
/// parser to continue parsing the following operation as part of the same expression.
|
||||
pub fn expr_parentheses_needed(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
span: Span,
|
||||
alt_snippet: Option<String>,
|
||||
) {
|
||||
if let Some(snippet) = self.source_map().span_to_snippet(span).ok().or(alt_snippet) {
|
||||
err.span_suggestion(
|
||||
span,
|
||||
"parentheses are required to parse this as an expression",
|
||||
format!("({})", snippet),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
pub fn expr_parentheses_needed(&self, err: &mut DiagnosticBuilder<'_>, span: Span) {
|
||||
err.multipart_suggestion(
|
||||
"parentheses are required to parse this as an expression",
|
||||
vec![(span.shrink_to_lo(), "(".to_string()), (span.shrink_to_hi(), ")".to_string())],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn save_proc_macro_span(&self, span: Span) -> usize {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue