diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-07-14 04:28:20 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-07-15 12:00:46 +0800 |
| commit | ed88af21637ff3677100fd26f8db354cd6134ad4 (patch) | |
| tree | d03f55a747f4481c6674f693f42131663bfee0ce /tests/ui/parser/issues | |
| parent | 1cac8cbde98e7b15ad24fc96af4864cdd67b9c30 (diff) | |
| download | rust-ed88af21637ff3677100fd26f8db354cd6134ad4.tar.gz rust-ed88af21637ff3677100fd26f8db354cd6134ad4.zip | |
Recover and suggest use `;` to construct array type
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Diffstat (limited to 'tests/ui/parser/issues')
| -rw-r--r-- | tests/ui/parser/issues/error-pattern-issue-50571.rs | 11 | ||||
| -rw-r--r-- | tests/ui/parser/issues/error-pattern-issue-50571.stderr | 28 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/parser/issues/error-pattern-issue-50571.rs b/tests/ui/parser/issues/error-pattern-issue-50571.rs new file mode 100644 index 00000000000..0c2ce6052cb --- /dev/null +++ b/tests/ui/parser/issues/error-pattern-issue-50571.rs @@ -0,0 +1,11 @@ +// There is a regression introduced for issue #143828 +//@ edition: 2015 + +#![allow(dead_code)] +trait Foo { + fn foo([a, b]: [i32; 2]) {} + //~^ ERROR: expected `;` or `]`, found `,` + //~| ERROR: patterns aren't allowed in methods without bodies +} + +fn main() {} diff --git a/tests/ui/parser/issues/error-pattern-issue-50571.stderr b/tests/ui/parser/issues/error-pattern-issue-50571.stderr new file mode 100644 index 00000000000..47457cff461 --- /dev/null +++ b/tests/ui/parser/issues/error-pattern-issue-50571.stderr @@ -0,0 +1,28 @@ +error: expected `;` or `]`, found `,` + --> $DIR/error-pattern-issue-50571.rs:6:14 + | +LL | fn foo([a, b]: [i32; 2]) {} + | ^ expected `;` or `]` + | + = note: you might have meant to write a slice or array type +help: you might have meant to use `;` as the separator + | +LL - fn foo([a, b]: [i32; 2]) {} +LL + fn foo([a; b]: [i32; 2]) {} + | + +error[E0642]: patterns aren't allowed in methods without bodies + --> $DIR/error-pattern-issue-50571.rs:6:12 + | +LL | fn foo([a, b]: [i32; 2]) {} + | ^^^^^^ + | +help: give this argument a name or use an underscore to ignore it + | +LL - fn foo([a, b]: [i32; 2]) {} +LL + fn foo(_: [i32; 2]) {} + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0642`. |
