Skip to content

fix(editor-doc): iterate the style rules with enumerate, for clippy 1.100 - #143

Merged
aRustyDev merged 1 commit into
mainfrom
fix/clippy-1-100-needless-range-loop
Nov 12, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
fix/clippy-1-100-needless-range-loop

Conversation

@aRustyDev

@aRustyDev aRustyDev commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

What

lint is red on every pull request since 2026-11-12, with no change to the code: CI installs stable unpinned, and rustc 1.100.0 (2026-11-09) reached the runners that day. Main's last green run (17:04Z, 8ca9a49) used 1.99.1; the next run used 1.100.0 and failed clippy::needless_range_loop in crates/thrust-editor-doc/src/domparse.rs:824, on both the native and the wasm32 job. It was seen on #142, a PR that does not touch the file.

This PR changes that loop and nothing else:

// before
for i in start..self.styles.len() {
    let r = &self.styles[i];
// after
for (i, r) in self.styles.iter().enumerate().skip(start) {

i is still the rule's position (found and after carry it to the next scan), and a start past the end is an empty scan in both forms. No #[allow].

This is the failure the open issue #92 describes (a clippy release turning lint red). #92 stays open: this PR does not pin the toolchain. A pin is the lasting fix, and it changes how CI and scripts/rs pick the compiler, so it is its own decision.

Evidence (2026-11-12, local)

rustc 1.100.0 installed beside stable, which is still 1.99.0 on this machine (scripts/rs hard-codes stable, so the runs used a copy of it pointed at 1.100.0).

  • Before: cargo clippy --workspace --all-targets --locked on 1.100.0 warns once, at domparse.rs:824, and nowhere else. The only other output is cargo's own manifest warnings, which -D warnings after -- does not turn into errors (CI sets neither RUSTFLAGS nor build.warnings).
  • After: the two commands of the lint job, with -D warnings, exit 0 (native, and -p thrust-worker --no-default-features --target wasm32-unknown-unknown), and cargo fmt --all --check exits 0. Both clippy logs show thrust-editor-doc checked.
  • cargo nextest run -p thrust-editor-doc: 31 passed (the leaky controls test reports LEAK, as it does without this change), 4 skipped.
  • Control: with every style rule skipped (.skip(start + 100000), planted and reverted) three tests fail, stage3_not_vacuous, parity_stage3_html_to_json and controls::baseline_has_zero_failures_and_no_schema_drift, on the corpus cases f-style-bold, f-style-deco and f-style-italic: the loop is under test.
  • A gap, stated: an off-by-one in the bound (.skip(start + 1)) is not caught; no corpus case depends on the first rule or on the rule after a match. That the two forms are equal rests on the loop's shape, not on that test. The corpus is recorded from the TypeScript oracle, so I did not add a case by hand.

Left alone

On 1.100.0 cargo also warns unused dependency for tokio-tungstenite (thrust-contract-tests), base64 (thrust-editor-doc) and futures-util (thrust-ports). They do not fail lint, and I did not check whether they are real (a dependency used only in the wasm32 build, for one, would be a false positive), so they are not touched here.

🤖 Generated with Claude Code

….100

CI installs `stable` unpinned, and rustc 1.100.0 (2026-11-09) reached the
runners on 2026-11-12. Its clippy fails `needless_range_loop` on the style-rule
scan in `Parser::read_styles` (`domparse.rs`), so `lint` was red on both the
native and the wasm32 job for every pull request, with no change to the code:
main's last green run (17:04Z) used 1.99.1, the next one 1.100.0.

`for i in start..self.styles.len()` indexing `self.styles[i]` becomes
`for (i, r) in self.styles.iter().enumerate().skip(start)`. The index is still
the rule's position, which `found` and `after` carry on to the next scan, and
a `start` past the end gives an empty scan in both forms, so the behaviour is
the same. No `#[allow]`.

Measured (2026-11-12, rustc 1.100.0 installed beside `stable`, which is
1.99.0 on this machine):

- Before: `cargo clippy --workspace --all-targets --locked` warns once, at
  `domparse.rs:824`, and nowhere else (the only other output is cargo's own
  manifest warnings, which `-D warnings` does not turn into errors).
- After: CI's two commands with `-D warnings` (native, and
  `-p thrust-worker --no-default-features --target wasm32-unknown-unknown`)
  and `cargo fmt --all --check` exit 0, and both logs show `thrust-editor-doc`
  checked.
- `cargo nextest run -p thrust-editor-doc`: 31 passed (the leaky
  `thrust-editor-doc` control test reports LEAK, as before), 4 skipped.
- Control: with every style rule skipped (`.skip(start + 100000)`, planted and
  reverted) three tests fail, `stage3_not_vacuous`,
  `parity_stage3_html_to_json` and
  `controls::baseline_has_zero_failures_and_no_schema_drift`, on the corpus
  cases `f-style-bold`, `f-style-deco` and `f-style-italic`, so the loop is
  under test. An off-by-one in the bound (`.skip(start + 1)`) is NOT caught:
  no corpus case depends on the first rule or on the rule after a match. The
  two forms are equal by construction, not by that test.

Refs: #92
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 84dcafa into main Nov 12, 2026
66 of 68 checks passed
@aRustyDev
aRustyDev deleted the fix/clippy-1-100-needless-range-loop branch November 12, 2026 22:05
aRustyDev added a commit that referenced this pull request Nov 12, 2026
Picks up #143 (the clippy 1.100 fix), the only commit main gained since the
last rebase, so that `lint` is green on this branch.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.

1 participant