1
Fork 0

Rollup merge of #117990 - estebank:issue-100825-part-deux, r=Nilstrieb

Tweak error and move tests

r? `@Nilstrieb`

Split off #117565.
This commit is contained in:
Matthias Krüger 2023-11-17 00:41:24 +01:00 committed by GitHub
commit a5d7f8bcf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 77 additions and 15 deletions

View file

@ -830,8 +830,8 @@ impl<'a> Parser<'a> {
// https://github.com/rust-lang/rust/issues/72373
if self.prev_token.is_ident() && self.token.kind == token::DotDot {
let msg = format!(
"if you meant to bind the contents of \
the rest of the array pattern into `{}`, use `@`",
"if you meant to bind the contents of the rest of the array \
pattern into `{}`, use `@`",
pprust::token_to_string(&self.prev_token)
);
expect_err

View file

@ -638,13 +638,13 @@ impl<'a> Parser<'a> {
/// Error on `mut $pat` where `$pat` is not an ident.
fn ban_mut_general_pat(&self, lo: Span, pat: &Pat, changed_any_binding: bool) {
let span = lo.to(pat.span);
let pat = pprust::pat_to_string(&pat);
self.sess.emit_err(if changed_any_binding {
InvalidMutInPattern::NestedIdent { span, pat }
InvalidMutInPattern::NestedIdent {
span: lo.to(pat.span),
pat: pprust::pat_to_string(&pat),
}
} else {
InvalidMutInPattern::NonIdent { span, pat }
InvalidMutInPattern::NonIdent { span: lo.until(pat.span) }
});
}