1
Fork 0

Rollup merge of #133560 - clubby789:mut-mut-space, r=jieyouxu

Trim extra space in 'repeated `mut`' diagnostic

Trim an extra space when removing repeated `mut`.

Also an extra test for even more repeated `mut`s
This commit is contained in:
Guillaume Gomez 2024-11-28 12:06:07 +01:00 committed by GitHub
commit 22c5bb0bdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 14 deletions

View file

@ -2620,8 +2620,9 @@ pub(crate) enum InvalidMutInPattern {
#[diag(parse_repeated_mut_in_pattern)]
pub(crate) struct RepeatedMutInPattern {
#[primary_span]
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
pub span: Span,
#[suggestion(code = "", applicability = "machine-applicable", style = "verbose")]
pub suggestion: Span,
}
#[derive(Diagnostic)]

View file

@ -1089,7 +1089,9 @@ impl<'a> Parser<'a> {
return;
}
self.dcx().emit_err(RepeatedMutInPattern { span: lo.to(self.prev_token.span) });
let span = lo.to(self.prev_token.span);
let suggestion = span.with_hi(self.token.span.lo());
self.dcx().emit_err(RepeatedMutInPattern { span, suggestion });
}
/// Parse macro invocation