Skip to content

unused_variables syntax error with box patterns / box syntax #105099

@matthiaskrgr

Description

@matthiaskrgr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions