Repository navigation
chore(lint): every lint suppression says why, and expect replaces allow - #2063
Conversation
Turns on clippy's allow_attributes and allow_attributes_without_reason for the workspace (and the two apps that keep their own copy of its lints), so a suppression is #[expect(lint, reason = "…")]: a reviewer reads why, and one that stops being needed fails the build instead of lingering. Of the 175 allow attributes (counting cfg_attr ones): - 130 are removed as redundant: too_many_arguments and type_complexity are allowed for the whole workspace, and unwrap_used, expect_used and panic in test code are allowed by clippy.toml. - 4 more go: three turned out to be unneeded once checked with expect (the legacy query oracle's dead_code, Seen's on wasm, and an unused_mut on Windows for a builder that every platform changes), and a dead helper in dialogs.rs that existed only to be allowed. - 38 become expect with a reason, most behind the cfg they apply to. - The three #![allow(dead_code)] in tests/support stay allow (each test crate that includes them uses a different part) with a reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| /// Android's entry point for a `NativeActivity` (`android-activity` calls it on its own thread). | ||
| // `no_mangle` is the one unsafe attribute here: the name is what `android-activity` calls. | ||
| #[allow(unsafe_code)] | ||
| #[expect(unsafe_code, reason = "`no_mangle`: `android-activity` calls this name")] |
There was a problem hiding this comment.
Unverified on Android (confidence: medium). This expect(unsafe_code) sits in mod android, which only compiles for target_os = "android". The same goes for phone.rs:34. No CI workflow under .github builds Android, and the PR's testing list covers Linux, macOS, Windows and wasm only. If rustc's unsafe_code lint does not fire on #[unsafe(no_mangle)], this becomes an unfulfilled expectation and the Android build fails under -D warnings. I could not confirm either way from the source. Please run an Android check (for example cargo check --target aarch64-linux-android -p rustgis-mobile, or the NDK build in the crate's README) before merging.
There was a problem hiding this comment.
Checked: unsafe_code fires on #[unsafe(no_mangle)] (and on the unsafe {} block in phone.rs), so both expectations are fulfilled on Android. The construct is target-independent, so I compiled it on the host with rustc 1.99, edition 2024, #![deny(unsafe_code)] and -D warnings: with the expects it builds cleanly; without the one on no_mangle it fails with "usage of the unsafe no_mangle attribute".
| //! happen later through the existing user-interface path, with its normal progress and Cancel. | ||
| //! https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_handle_AEs/SAppsHandleAEs.html | ||
| #![allow(unsafe_code)] | ||
| #![expect(unsafe_code, reason = "the Apple event handler is an Objective-C class (#1706)")] |
There was a problem hiding this comment.
Platform-only changes need a platform CI run before merge (confidence: high). This module, like the Windows-only build.rs logo expectation and the other cfg-gated expects, compiles only on its own platform. Per AGENTS.md, PRs run CI on Linux only, and macOS and Windows run on pushes to main or when labelled. The PR body says the full CI covers macOS and Windows, which will not happen on this PR as it stands. Please add ci:full (or ci:macos and ci:windows) so the removed allows and new expects are checked there.
There was a problem hiding this comment.
This head (a11adf8) already ran the full CI on Linux, macOS (ARM64) and Windows (x64 and ARM64) on the fork, all green: https://github.com/Mavrick-F/RustGIS/actions/runs/43620321602. The first run on the earlier head caught one unfulfilled expect on Windows (audit.rs), removed before this push. Not adding ci:full to repeat the same run upstream.
Code reviewI found no bugs in the changed code. The suppression counts in the PR body match the diff (175 Bugs
Security
Performance
Quality
AGENTS.md
Prior review threads: none existed, so no earlier concerns were left alone. Change sizeCompared with the base branch (merge base 05eb128 to PR head a11adf8).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
Summary
Every lint suppression now says why, and uses
#[expect]so one that stops being needed fails the build instead of lingering.allow_attributesandallow_attributes_without_reasonfor the workspace, and inapps/rustgisandapps/rustgis-mobile, which keep their own copy of the workspace lints. CI's-D warningsmakes both errors.allowattributes (countingcfg_attrones):too_many_argumentsandtype_complexityare already allowed for the whole workspace inCargo.toml, andclippy.tomlalready allowsunwrap_used,expect_usedandpanicin test code.expectchecked them (the legacy query oracle'sdead_code,Seen's on wasm, and anunused_muton Windows for aDirBuilderevery platform changes), plus a deadfn unused(_: Value) {}indialogs.rsthat existed only to be allowed.#[expect(lint, reason = "…")], most behind thecfgthey apply to, e.g.#[cfg_attr(target_arch = "wasm32", expect(dead_code, reason = "database sources are desktop only"))].#![allow(dead_code, reason = …)]:tests/support/*.rsare included by several test crates, each using a different part, so anexpectwould go unfulfilled in some. Inner#![allow]is outsideallow_attributes.A suppression that a lint really needs is now
#[expect(lint, reason = "…")]; clippy refuses a bare#[allow].Testing
cargo clippy --workspace --all-targets --locked: no warnings (this is how the redundant attributes were found: an unfulfilledexpectis a warning).RUSTFLAGS='-D warnings' cargo build --locked --target wasm32-unknown-unknown -p rustgis-web: passes; the wasm-only expectations are checked there.expect(unsafe_code)there were checked by compiling the same constructs (#[unsafe(no_mangle)], anunsafeblock) underdeny(unsafe_code).UI evidence
No visible UI change.
Related issue
None.
Summary by CodeRabbit