Skip to content

Use configured array length for usize literal generation#370

Open
uurl wants to merge 1 commit into
NVlabs:mainfrom
uurl:fix/usize-literal-array-bound
Open

Use configured array length for usize literal generation#370
uurl wants to merge 1 commit into
NVlabs:mainfrom
uurl:fix/usize-literal-array-bound

Conversation

@uurl

@uurl uurl commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Closes #369

Summary

Use TyConfig::array_max_len when generating small usize literals instead of relying on the hard-coded value 8.

Changes

  • Split the existing Sombrero distribution into usize-specific and isize-specific distributions.
  • Parameterize the usize distribution with the configured upper bound.
  • Pass tcx.config.array_max_len from GenLiteral::gen_literal.
  • Remove the FIXME associated with the hard-coded array-length value.

Rationale

Array lengths are configurable, so duplicating the default value in the literal generator can produce inconsistent behavior when array-max-len is changed.

Using the value from TyCtxt keeps literal generation aligned with type generation.

Validation

  • cargo test
  • cargo clippy --all-targets
  • cargo fmt --all --check
  • cd crates/fuzzer/rustlantis && cargo test -p generate usize_sombrero_uses_configured_small_values_upper_bound
  • cd crates/fuzzer/rustlantis && cargo test -p generate
  • cd crates/fuzzer/rustlantis && cargo clippy -p generate --all-targets
  • cd crates/fuzzer/rustlantis && cargo fmt --all -- --check

Signed-off-by: Raul Estrada <raulestradaa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use configured array length when generating usize literals

1 participant