Skip to content

By-ref/by-mut-ref match on struct field names doesn't parse #7930

Closed

Description

@huonw
rusti> struct A { a: int }
rusti> let foo = A { a: 1 };
rusti> let A { a } = foo;
rusti> a
1
rusti> let A { ref a } = foo;
<anon>:2:6: 2:7 error: found `ref` in ident position
<anon>:2  let A { ref a } = foo; 
                  ^
<anon>:2:11: 2:12 error: expected `,` but found `a`
<anon>:2  let A { ref a } = foo; 
                      ^
rust: task failed at 'explicit failure', /home/huon/rust/src/libsyntax/diagnostic.rs:70
rusti> let A { ref mut a } = foo;
<anon>:2:6: 2:7 error: found `ref` in ident position
<anon>:2  let A { ref mut a } = foo; 
                  ^
<anon>:2:11: 2:14 error: expected `,` but found `mut`
<anon>:2  let A { ref mut a } = foo; 
                      ^~~
rust: task failed at 'explicit failure', /home/huon/rust/src/libsyntax/diagnostic.rs:70

These should be equivalent to, e.g., let A { a: ref mut a } = foo; which works fine (although not in rusti, because of its limitations).

Activity

  1. huonw commented on Aug 14, 2013

    @huonw
    ContributorAuthor

    Dup of #6137.

  2. added a commit that references this issue on Jun 4, 2022
  3. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions