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

unused_variables syntax error with box patterns / box syntax #105099

Open
matthiaskrgr opened this issue Nov 30, 2022 · 0 comments
Open

unused_variables syntax error with box patterns / box syntax #105099

matthiaskrgr opened this issue Nov 30, 2022 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Given the following code:

#![feature(box_patterns)]
#![feature(box_syntax)]

enum E {
    StructVar { boxed: Box<i32> },
}

fn main() {
    let a = E::StructVar { boxed: box 3 };
    match a {
        E::StructVar { box boxed } => {}
    }
}

cargo fix

warning: build failed, waiting for other jobs to finish...
warning: failed to automatically apply fixes suggested by rustc to crate `g`

after fixes were automatically applied the compiler reported errors within these files:

  * src/main.rs

This likely indicates a bug in either rustc or cargo itself,
and we would appreciate a bug report! You're likely to see
a number of compiler warnings after this message which cargo
attempted to fix but failed. If you could open an issue at
https://github.com/rust-lang/rust/issues
quoting the full output of this command we'd be very appreciative!
Note that you may be able to make some more progress in the near-term
fixing code with the `--broken-code` flag

The following errors were reported:
error[E0026]: variant `E::StructVar` does not have a field named `_boxed`
  --> src/main.rs:11:28
   |
11 |         E::StructVar { box _boxed } => { }
   |                            ^^^^^^
   |                            |
   |                            variant `E::StructVar` does not have this field
   |                            help: a field with a similar name exists: `boxed`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0026`.
Original diagnostics will follow.

warning: unused variable: `boxed`
  --> src/main.rs:11:28
   |
11 |         E::StructVar { box boxed } => { }
   |                            ^^^^^ help: if this is intentional, prefix it with an underscore: `_boxed`
   |
   = note: `#[warn(unused_variables)]` on by default
@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant