Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
huonw opened this issue Jul 20, 2013 · 1 comment
Closed

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

huonw opened this issue Jul 20, 2013 · 1 comment
Labels
A-parser Area: The parsing of Rust source code to an AST

Comments

@huonw
Copy link
Member

huonw commented Jul 20, 2013

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

@huonw
Copy link
Member Author

huonw commented Aug 14, 2013

Dup of #6137.

@huonw huonw closed this as completed Aug 14, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 4, 2022
new lint: `borrow_deref_ref`

changelog: ``[`borrow_deref_ref`]``

Related pr: rust-lang#6837 rust-lang#7577
`@Jarcho` Could you please give a review?

`cargo lintcheck` gives no false negative (but tested crates are out-of-date).

TODO:
1. Not sure the name. `deref_on_immutable_ref` or some others?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

1 participant