Skip to content

Slice patterns cannot be used in trait methods #50571

Closed

Description

The following code works on beta:

fn foo([a, b]: [i32; 2]) {}

But when used in a trait like so:

trait Foo {
    fn foo([a, b]: [i32; 2]) {}
}

rustc reports the following error:

error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `,`
 --> src/main.rs:2:14
  |
2 |     fn foo([a, b]: [i32; 2]) {}
  |              ^ expected one of 7 possible tokens here

error: aborting due to previous error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions