1
Fork 0

Trim whitespace in RemoveLet primary span

Separate `RemoveLet` span into primary span for `let` and removal
suggestion span for `let `, so that primary span does not include
whitespace.

Fixes: #133031

Signed-off-by: Tyrone Wu <wudevelops@gmail.com>
This commit is contained in:
Tyrone Wu 2024-11-15 02:27:51 +00:00
parent c82e0dff84
commit dd557c988f
No known key found for this signature in database
GPG key ID: 978B1A1B79210AD6
5 changed files with 31 additions and 15 deletions

View file

@ -650,8 +650,9 @@ pub(crate) struct LeftArrowOperator {
#[diag(parse_remove_let)]
pub(crate) struct RemoveLet {
#[primary_span]
#[suggestion(applicability = "machine-applicable", code = "", style = "verbose")]
pub span: Span,
#[suggestion(applicability = "machine-applicable", code = "", style = "verbose")]
pub suggestion: Span,
}
#[derive(Diagnostic)]

View file

@ -685,7 +685,7 @@ impl<'a> Parser<'a> {
self.bump();
// Trim extra space after the `let`
let span = lo.with_hi(self.token.span.lo());
self.dcx().emit_err(RemoveLet { span });
self.dcx().emit_err(RemoveLet { span: lo, suggestion: span });
lo = self.token.span;
}