Skip to content

refactor(slice-safety): deny(clippy::indexing_slicing) + scoped escapes (#341)#378

Merged
joaquinbejar merged 1 commit into
mainfrom
issue-341-index-safety
Apr 19, 2026
Merged

refactor(slice-safety): deny(clippy::indexing_slicing) + scoped escapes (#341)#378
joaquinbejar merged 1 commit into
mainfrom
issue-341-index-safety

Conversation

@joaquinbejar

Copy link
Copy Markdown
Owner

Summary

  • Enforce `#![deny(clippy::indexing_slicing)]` crate-wide in `src/lib.rs`.
  • Tests stay permissive via `#![cfg_attr(test, allow(clippy::indexing_slicing))]` — unit/integration tests routinely index into just-pushed buffers and are not expected to migrate.
  • Migrate the highest-risk unchecked indexing in production paths to `.get(..).ok_or_else(..)` returning typed errors: `OptionChain` file-name parsing and CSV row reads in `src/chains/chain.rs`, and the binomial-root lookup in `Option::binomial_price` in `src/model/option.rs`.
  • All remaining production call sites carry a scoped `#![allow(clippy::indexing_slicing)]` at the top of each affected module with a one-paragraph migration note; these are tracked as per-module follow-ups so the deny-level lint rolls out without one massive risky PR.

Closes #341 (slice-safety floor; per-module migration continues).

Test plan

  • `cargo clippy --lib --all-features --all-targets -- -D warnings` clean.
  • `cargo build --lib --all-features` clean.
  • `cargo test --lib --all-features` — 3753 pass; 4 pre-existing unrelated `chains::chain` failures (also fail on `main`).
  • `cargo fmt --all --check`.

…coped escapes (#341)

- Lift `#[deny(clippy::indexing_slicing)]` crate-wide in `src/lib.rs`.
  Tests stay permissive via `#![cfg_attr(test, allow(..))]` — unit /
  integration tests routinely index into just-pushed buffers and are
  not expected to migrate.
- Migrate the highest-risk unchecked indexing in production code
  to `.get(..).ok_or_else(..)` returning typed errors:
  `OptionChain` file-name parsing and CSV row reads in
  `src/chains/chain.rs`, and the binomial-root lookup in
  `Option::binomial_price` in `src/model/option.rs`.
- Remaining call sites carry a scoped `#![allow(clippy::indexing_slicing)]`
  at the top of each affected module with a one-paragraph migration
  note. They are tracked as per-module follow-ups to #341 so that the
  deny-level lint can be rolled out without a massive, risky single
  PR.

Closes #341 (slice-safety floor; per-module migration continues).
@joaquinbejar joaquinbejar merged commit e893d33 into main Apr 19, 2026
10 of 11 checks passed
@joaquinbejar joaquinbejar deleted the issue-341-index-safety branch April 19, 2026 20:10
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.

Replace unchecked [] indexing with .get(i).ok_or_else(..)

1 participant