- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code (playground link):
struct Point {
    x: u32,
    y: u32
}
fn process_point(Point { x, y: renamed }: Point) {
    /* ... */
}The current warning output is (ignoring non-relevant parts):
warning: unused variable: `renamed`
 --> src/lib.rs:6:32
  |
6 | fn process_point(Point { x, y: renamed }: Point) {
  |                                ^^^^^^^ help: try ignoring the field: `renamed: _`
Ideally the output should look like:
  |
6 | fn process_point(Point { x, y: renamed }: Point) {
  |                                ^^^^^^^ help: try ignoring the field: `y: _`
because using y: renamed: _ does not work (of course).
Using cargo fix is broken by this too, I got the following message (removing the big message about making a bug report to remove clutter):
✖ cg fix --allow-no-vcs  
    Checking playground v0.1.0 (/Users/alexis/Projects/rust/playground)
warning: failed to automatically apply fixes suggested by rustc to crate `playground`
after fixes were automatically applied the compiler reported errors within these files:
  * src/main.rs
The following errors were reported:
error: expected `,`
  --> src/main.rs:18:46
   |
18 |     fn process_point(Point { x: _, y: renamed: _ }: Point) { /* ... */ }
   |                      -----                   ^
   |                      |
   |                      while parsing the fields for this pattern
error: aborting due to previous error
...
@rustbot label A-diagnostics C-bug D-incorrect D-invalid-suggestion
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.