Skip to content

feature(destructuring_assignment) suggested errorneously #90095

Open
@moxian

Description

@moxian

(playground)

fn main(){
  let foo: [u8; _] = [1,2,3];
}
error[E0658]: destructuring assignments are unstable
 --> src/main.rs:2:17
  |
2 |   let foo: [u8; _] = [1,2,3];
  |                 ^
  |
  = note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
  = help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable

error: in expressions, `_` can only be used on the left-hand side of an assignment
 --> src/main.rs:2:17
  |
2 |   let foo: [u8; _] = [1,2,3];
  |                 ^ `_` not allowed here

For more information about this error, try `rustc --explain E0658`.

However the #![feature(destructuring_assignment)] seems to be completely irrelevant here, and indeed adding that (playground)

#![feature(destructuring_assignment)]
fn main(){
  let foo: [u8; _] = [1,2,3];
}

still gives error of

error: in expressions, `_` can only be used on the left-hand side of an assignment
 --> src/main.rs:3:17
  |
3 |   let foo: [u8; _] = [1,2,3];
  |                 ^ `_` not allowed here

(Tangentially: technically the error message is wrong since _ is used in the left hand side of an assignment. Just not as the variable name as rustc expected... )

cc #71126

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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