Skip to content

fix(lint): satisfy Clippy from Rust 1.100 - #905

Merged
giswqs merged 2 commits into
mainfrom
fix/clippy-rust-1-100
Nov 12, 2026
Merged

giswqs merged 2 commits into
mainfrom
fix/clippy-rust-1-100

Conversation

@giswqs

@giswqs giswqs commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes the red CI on main: the workspace builds cleanly under Clippy from Rust 1.100 again. No user-visible behavior changes.

Cause

The GitHub runners' stable toolchain moved from Rust 1.99.1 to 1.100.0 between the runs on 52ab8f36 (green, 1.99.1) and 401165f0/d88099da (red, 1.100.0). Clippy 1.100 flags two sites that have been in the tree since October, and CI runs Clippy with -D warnings, so terrio no longer compiles in the lint step:

  • crates/terrio/src/ops/simplify.rs:221, needless_range_loop: for k in a + 1..b indexing self.points[owner][k]. Fails ubuntu-latest, macos-latest, windows-latest and GDAL backend (feature build).
  • crates/terrio/src/gpkg_validate.rs:6, needless_bool: on Windows the #[cfg(unix)] block compiles away, leaving if … { return false; } true. Fails windows-latest only.

No commit on main caused this; both files were last touched in #406.

Fix

  • The simplifier loop iterates the points with enumerate().take(b).skip(a + 1), visiting the same indices in the same order, so the farthest-point choice and its tie-breaking are unchanged.
  • same_image_metadata is one boolean expression that calls a same_inode helper: the device, inode and ctime comparison on Unix, and true elsewhere. The result is the same on every platform as before.

Evidence

  • Reproduced locally with Rust 1.100.0: cargo clippy --workspace --all-targets -- -D warnings failed on the simplify.rs site before the change and finishes cleanly after it.
  • Also clean under 1.100.0: cargo fmt --all -- --check, the ndarray Clippy invocation and both terrio-crs Clippy invocations from ci.yml.
  • cargo test -p terrio --lib -- simplify gpkg_validate: 19 passed, 1 ignored.
  • Not verified locally: the needless_bool site only exists on non-Unix targets, and the --features gdal Clippy invocations did not build in my local environment (a gdal-sys build-script failure unrelated to this change). Labeled ci:all so the Windows, macOS and GDAL backend jobs that failed on main prove both here.

Summary by CodeRabbit

  • Refactor
    • File metadata comparisons now follow platform-specific rules, retaining the existing comparison behavior on non-Unix platforms.
    • Line simplification continues to consider intermediate vertices using the existing distance calculations and candidate-selection rules. These changes do not alter expected results or add user-facing functionality.

The CI runners moved from Rust 1.99.1 to 1.100.0, whose Clippy rejects
two existing sites under -D warnings: an indexed range loop in the
tagged simplifier (needless_range_loop) and, where the cfg(unix) block
compiles away, an early-return bool in the GeoPackage image metadata
comparison (needless_bool). Neither change alters behavior.
@giswqs giswqs added the ci:all Run all optional CI (macOS, Windows, npm, conformance) for this pull request label Nov 12, 2026
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change refactors image metadata comparison into platform-specific helpers and updates the simplifier’s farthest-point scan to iterate over the relevant point slice with original indices.

Changes: Image metadata comparison

Layer / File(s) Summary
Platform-specific metadata comparison
crates/terrio/src/gpkg_validate.rs
same_image_metadata now uses same_inode. Unix compares device, inode, and change time. Non-Unix platforms continue to compare length and modification time.

Simplifier point scan

Layer / File(s) Summary
Intermediate point scan
crates/terrio/src/ops/simplify.rs
The farthest-point scan iterates over the points between a and b and computes their original indices. Distance calculation and candidate selection are unchanged.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: mavrick-f

Merge Risk: Minimal · up to 8c97c

This change fixes lint failures with behavior-preserving refactors. No actionable merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(lint): satisfy Clippy from Rust 1.100" matches the main purpose of the PR. The changes replace an indexed loop in the simplifier to satisfy the needless_range_loop lint, and rewrite sam…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(lint): satisfy Clippy from Rust 1.100" matches the main purpose of the PR. The changes replace an indexed loop in the simplifier to satisfy the needless_range_loop lint, and rewrite same_image_metadata to satisfy the needless_bool lint. The title is specific and conventional. It does not list every file, which is acceptable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each file in turn,
Then scans the points along the line.
It keeps the farthest candidate,
While inode checks follow the platform.
The slice returns each index,
And quiet code changes mark the day.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6fb1696f-e79a-47dc-9f1f-b7cfee488af8
Commits

Reviewing files that changed from the base of the PR and between dfebeba and 8c97c83.

Files selected for processing: 1

  • crates/terrio/src/ops/simplify.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Comment thread crates/terrio/src/ops/simplify.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

This PR is a small, behavior-preserving Clippy fix in two files. I found no bugs and no security issues. I confirmed the two refactors keep their semantics, and I posted one nit inline.

Bugs: None found.

  • gpkg_validate.rs: same_image_metadata keeps the original order of checks (length, mtime, then inode identity) through && short-circuiting. The sqlite cfg gating is consistent across same_image_metadata, both same_inode variants, and the unix-only test. Confidence: high.
  • simplify.rs:221: enumerate().take(b).skip(a + 1) visits the same indices in the same order as a + 1..b. b is always below points[owner].len(), so nothing changes. Confidence: high.

Security: None found.

Performance: None found. Both changes are constant-time per iteration and do no extra work.

Quality:

  • Nit, simplify.rs:221 (posted inline): the iterator form silently truncates if b is out of range, where the old indexing panicked. The invariant holds, so this has no effect today. The inline suggestion adds a debug_assert!. Confidence: high that it is equivalent; low that it matters.
  • Nit, gpkg_validate.rs:17-20: on non-Unix, same_inode returns true without checking any inode. The name describes intent rather than behavior. The doc comment explains it, so renaming it is optional. Confidence: medium.
  • Test coverage: the new identity check is exercised only on Unix (#[cfg(unix)] test). The non-Unix stub has no test. This gap predates the PR. Confidence: high.

CLAUDE.md (AGENTS.md):

  • The description opens with "Fixes the red CI on main…" and ends with "No user-visible behavior changes." AGENTS.md asks for an opening paragraph written as a changelog entry. For a no-behavior-change fix, a line such as "Fix Clippy 1.100 lint failures in the CI lint step; no user-visible change" would meet that. Confidence: medium.
  • No CHANGELOG.md edit, no draft PR, and no regression test is needed because there is no behavior change. Those rules are followed.

Unverified: The --features gdal Clippy build was not run, and I did not search gdal-gated code for other needless_range_loop sites. A quick scan of the tree showed many range loops, mostly in tests. The ci:all label should cover this, since the PR relies on CI for the Windows, macOS and GDAL jobs.

Change size

Compared with base: the whole PR against main (merge base d88099d to PR head dfebeba).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 42.1 KB
Size after 42.4 KB
Total size change +365 B
Path Before After Change
crates/terrio/src/gpkg_validate.rs 13.6 KB 14.1 KB +322 B
crates/terrio/src/ops/simplify.rs 28.4 KB 28.5 KB +43 B

- simplify: iterate the slice points[owner][a + 1..b] instead of
  enumerate().take(b).skip(a + 1), so an out-of-range bound still
  panics as the indexed loop did rather than truncating silently.

/// Platforms without inode metadata compare the length and modification time only.
#[cfg(all(feature = "sqlite", not(unix)))]
fn same_inode(_before: &std::fs::Metadata, _after: &std::fs::Metadata) -> bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (naming, confidence: medium): on non-Unix this same_inode never inspects inodes and just returns true, so the name claims a check that does not happen. The doc comment explains it, but a name such as inode_unchanged (or status_unchanged) would read correctly on both branches. The rename touches the Unix variant and its call site in same_image_metadata, so I have not included a suggestion block. The behavior is unchanged either way, and the non-Unix result matches the pre-PR code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left as is: the PR merged before this round, and the name states the question the helper answers (is this still the same inode), with the doc comment covering the platforms that cannot ask it. Behavior matches the code before the PR on every platform, so I am not opening a follow-up for the rename alone.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. I checked both changes for behavioral equivalence.

  • simplify.rs: The iterator self.points[owner][a + 1..b].iter().enumerate() visits the same indices in the same order as the old for k in a + 1..b. farthest is rebased as a + 1 + offset, so the tie-breaking is unchanged. The slice cannot panic. The loop body is reached only when b >= a + 2, and the stack invariant b > a holds from the initial (0, n-1) and both pushes.
  • gpkg_validate.rs: same_image_metadata keeps the original short-circuit order (length, mtime, then inode and ctime on Unix). On non-Unix it still returns the length and mtime result, so behavior matches the pre-PR code. All callers and the test are gated on feature = "sqlite", which matches the new cfgs.

Security: None found. The change is a pure refactor with no new input handling.

Performance: None. The iterator form does one bounds check on the slice instead of one per index. The effect is negligible.

Quality:

  • (confidence: medium) The non-Unix same_inode always returns true and never checks inodes, so its name claims more than it does. Inline comment posted on crates/terrio/src/gpkg_validate.rs:18.

CLAUDE.md / AGENTS.md:

  • (confidence: low) AGENTS.md asks the PR description to open with a changelog-style paragraph about the user-visible change. This description opens with "Fixes the red CI on main" and says there is no user-visible change. That is accurate for a CI-only fix, but it does not follow the requested format.
  • No CHANGELOG.md edit, so the changelog rule is satisfied.
  • The identifiers are behavior-named, and no ported code needs SPDX or NOTICE updates.

Not verified here: The needless_bool site exists only on non-Unix targets, and the --features gdal Clippy runs did not build for the author. Both depend on CI. The same_inode non-Unix path has no local test.

Change size

Compared with the base branch: the whole PR against main (merge base d88099d to PR head 8c97c83).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 42.1 KB
Size after 42.5 KB
Total size change +373 B
Path Before After Change
crates/terrio/src/gpkg_validate.rs 13.6 KB 13.9 KB +322 B
crates/terrio/src/ops/simplify.rs 28.4 KB 28.5 KB +51 B

@giswqs
giswqs merged commit 06e8730 into main Nov 12, 2026
24 checks passed
@giswqs
giswqs deleted the fix/clippy-rust-1-100 branch November 12, 2026 19:43
@giswqs giswqs mentioned this pull request Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:all Run all optional CI (macOS, Windows, npm, conformance) for this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant