Skip to content

Clippy large_stack_arrays false positive with vec![] macro #304

@josecelano

Description

@josecelano

Problem

Clippy reports a false positive large_stack_arrays lint when using the vec![] macro to create vectors of ServiceTopology items in tests.

Error Message

error: allocating a local array larger than 16384 bytes
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#large_stack_arrays
  = note: `-D clippy::large-stack-arrays` implied by `-D clippy::pedantic`
  = help: to override `-D clippy::pedantic` add `#[allow(clippy::large_stack_arrays)]`

Root Cause

This is a known clippy bug where the vec![] macro is incorrectly flagged for creating a large stack array. The vec![] macro creates a Vec<T> which allocates on the heap, not the stack. The lint is a false positive.

Upstream Issue: rust-lang/rust-clippy#12586

Affected Code

Tests in src/domain/topology/aggregate.rs that create vectors of ServiceTopology:

let topology = DockerComposeTopology::new(vec![
    ServiceTopology::with_networks(Service::Tracker, vec![Network::Database]),
    ServiceTopology::with_networks(Service::MySQL, vec![Network::Database]),
])
.unwrap();

Current Workaround

Crate-level #![allow(clippy::large_stack_arrays)] in src/lib.rs.

Local suppression methods (module-level, function-level) don't work because the lint fires during macro expansion before the allow attributes are processed.

Potential Regression

The upstream fix (PR #12624) was merged April 27, 2024 and should be in Rust 1.80.0+. However, we're still seeing this error on Rust 1.93.0 (January 2026). This suggests either:

  1. Regression: The bug may have regressed in a later clippy version
  2. Different code pattern: Our vec![] with ServiceTopology (large struct with EnumSet fields) might trigger a variant not covered by the original fix
  3. CI environment: Some discrepancy in the clippy version used in CI

Acceptance Criteria

  • Investigate if this is a regression in clippy
  • Report upstream if confirmed as regression
  • Remove crate-level allow once upstream fix is available

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions