-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
compiler suggests invalid code with ref pattern #54180
Comments
warning: unused variable: `f1`
--> src/main.rs:9:15
|
9 | let S{ref f1} = s;
- | ^^ help: tryignoring the field: `f1: _`
+ | ^^^^^^ help: try ignoring the field: `f1: _`
|
= note: #[warn(unused_variables)] on by default the ambiguity in the lint caused by the wrong span. |
There is an issue regarding this with the 2018 edition. |
Just to be clear, AFAIK there are no lints for transitioning to default binding mode (edition idiom or otherwise), so the comment that it won't be an issue in 2018 isn't correct, this issue still applies to all editions. |
include mode in unused binding suggestion span Fixes rust-lang#54180.
include mode in unused binding suggestion span Fixes rust-lang#54180.
The following example:
Gives the following suggestion:
When the suggestion is applied, the code does not compile:
I'm not sure what the best suggestion would be. Removing the
ref
might be an option (I'm not sure if using a wildcard is equivalent in this case?). Suggesting..
is another option.This suggestion was changed in 1.28 (previous versions gave a different, wrong suggestion). Tested up to rustc 1.30.0-nightly (2d4e34c 2018-09-09).
The text was updated successfully, but these errors were encountered: