Closed
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
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Category: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A structured suggestion resulting in incorrect code.Relevant to the compiler team, which will review and decide on the PR/issue.