Skip to content

clippy::large_stack_arrays doesn't detect large arrays defined by comma-separated list #10741

Closed
@kathoum

Description

@kathoum

Summary

The clippy lint large_stack_arrays only checks expressions in the form [expr; n], and it doesn't detect large arrays declared as a comma-separated list of initializers.

Lint Name

large_stack_arrays

Reproducer

I tried this code, with the default array-size-threshold = 512000:

#[derive(Copy, Clone)]
struct Large([u32; 100_000]);

fn build() -> Large { Large([0; 100_000]) }

#[warn(clippy::large_stack_arrays)]
pub fn f() {
    // warning on this line
    let _x = [build(); 3];

    // missing warning on this line
    let _y = [build(), build(), build()];
}

Version

rustc 1.68.2 (9eb3afe9e 2023-03-27)
binary: rustc
commit-hash: 9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0
commit-date: 2023-03-27
host: x86_64-apple-darwin
release: 1.68.2
LLVM version: 15.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions