Improve compilation error message for invalid usage of rest pattern

This commit is contained in:
Guillaume Gomez 2024-07-31 15:16:02 +02:00
parent c860a22e85
commit 4de78ad9be
2 changed files with 2 additions and 2 deletions

View File

@ -238,7 +238,7 @@ fn only_one_rest_pattern<'a>(
if let Target::Rest(s) = target { if let Target::Rest(s) = target {
if !allow_named_rest && s.inner.is_some() { if !allow_named_rest && s.inner.is_some() {
return Err(nom::Err::Failure(ErrorContext::new( return Err(nom::Err::Failure(ErrorContext::new(
format!("`@ ..` cannot be used in {type_kind}"), "`@ ..` is only allowed in slice patterns",
s.span, s.span,
))); )));
} }

View File

@ -35,7 +35,7 @@ error: unexpected `,` character after `..`
31 | | "#, 31 | | "#,
| |__^ | |__^
error: `@ ..` cannot be used in tuple error: `@ ..` is only allowed in slice patterns
--> <source attribute>:2:18 --> <source attribute>:2:18
"who @ .., 4) = (1, 2, 3, 4) -%}\n{%- endif -%}\n" "who @ .., 4) = (1, 2, 3, 4) -%}\n{%- endif -%}\n"
--> tests/ui/rest_pattern.rs:39:14 --> tests/ui/rest_pattern.rs:39:14