Skip to content

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

Closed
@huonw

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).

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