Skip to content

large_stack_arrays still lint on nested const items #13529

Closed
@flip1995

Description

@flip1995

bool is not sufficient to keep track if we're in a constant item:

is_in_const_item: bool,

const A: u8 = {
    const B: () = ();

    let x = [0u8; 20_000_000];
    x[0]
};

This will still lint the array assigned to x. But if one comments out const B, it won't lint, because of the fix added in #13485

To fix this, turn the bool into a counter, increment it when entering an item and decrementing it when exiting it.

The current impl also won't prevent the lint from triggering in const fns. But I'm not sure if this is intended intended.

Originally posted by @flip1995 in #13485 (comment)

This issue has been assigned to @GnomedDev via this comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-false-positiveIssue: The lint was triggered on code it shouldn't havegood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions