Skip to content

Span is too large for unused rest @ .. pattern warning #81314

Closed
@camelid

Description

@camelid

The compiler suggests replacing rest @ .. with _rest, when in fact it should suggest _rest @ ..:

fn main() {
    let [rest @ ..] = [1, 2, 3];
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: unused variable: `rest`
 --> src/main.rs:2:10
  |
2 |     let [rest @ ..] = [1, 2, 3];
  |          ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_rest`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.73s
     Running `target/debug/playground`

The span should point to just rest.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions