Skip to content

Unused variables lint does not work inside an array length expression #77169

Closed
@ecstatic-morse

Description

@ecstatic-morse

Array length expressions can can do anything that a const initializer can. However, the unused variables lint does not work inside an array length expression. For example,

fn main() {
    let _ = [(); {
        let x = 42;
        35
    }];
}

(Playground)

...compiles with no warnings:

   Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.51s
     Running `target/debug/playground`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-HIRArea: The high-level intermediate representation (HIR)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.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