Skip to content

Syntax error on trait fns with destructured args #2847

Closed
@tobz1000

Description

@tobz1000

Trait functions with destructured arguments do not parse successfully. Some examples:

struct S { a: usize, b: usize }
struct NewType(usize);

trait T {
    // Syntax Error: expected COMMA/expected type
    fn f1((a, b): (usize, usize)) {}

    // Syntax Error: expected COMMA/expected value parameter/expected R_PAREN...
    fn f2(S { a, b }: S) {}

    // Syntax Error: expected COMMA
    fn f4(NewType(a): NewType) {}

    // Syntax Error: expected COMMA
    fn f3(&&a: &&usize) {}
}

These all parse okay as free-standing functions, or in a type impl-block.

The double-deref example is mentioned here, so apologies if this is a known issue.

Running in VS Code, built from commit ea0ee8e.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions