Skip to content

Fix clippy::all lints in tests/examples to unblock 0.7.0 release - #40

Merged
wiresock merged 2 commits into
mainfrom
chore/clippy-all-targets-release
Jun 24, 2026
Merged

Fix clippy::all lints in tests/examples to unblock 0.7.0 release#40
wiresock merged 2 commits into
mainfrom
chore/clippy-all-targets-release

Conversation

@wiresock

@wiresock wiresock commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Unblocks the 0.7.0 release. The publish workflow (publish.yml) gates on
cargo clippy --all-targets --all-features -- -D clippy::all across stable and nightly. Current clippy (1.96 stable / 1.98 nightly) flags lints in the tests and example programs that didn''t exist when 0.6.6 shipped (toolchain drift), which would fail static-analysis and skip the publish step.

The library API and behavior are unchanged — these are test/example fixes plus two cosmetic format! adjustments in the lib.

Changes

  • missing_transmute_annotations — add explicit transmute::<Src, Dst> in the sockaddr_storage tests and listadapters.
  • needless_range_looppackthru / unsorted-packthru iterate with enumerate().
  • unnecessary_mut_passedasync-passthru passes &packet (not &mut) to send_packet_to_mstcp.
  • unnecessary sort_byasync-packthru uses sort_by_key(Reverse(..)).
  • arc_with_non_send_sync#[allow] in the async examples, where sharing an Arc<Ndisapi> is the intended pattern (Ndisapi owns a raw HANDLE and is deliberately !Send/!Sync).
  • lib — drop a redundant & in two format! args (flagged by nightly clippy; would have failed the PR''s own build.yml nightly leg).

Verification (stable + nightly)

  • cargo clippy --all-targets --all-features -- -D clippy::all — pass
  • cargo test — pass (31 unit + 8 doctests)
  • cargo fmt --check — pass
  • cargo publish --dry-run — packages and verifies cleanly

After this merges, the 0.7.0 release/tag can be created to trigger auto-publish.

The release workflow (publish.yml) runs
`cargo clippy --all-targets --all-features -- -D clippy::all` on current
stable and nightly. Newer clippy (since 0.6.6 shipped) flags lints in the
tests and example programs that previously passed, which would block the
auto-publish step. The library API and behavior are unchanged.

- tests/examples: add explicit transmute::<Src, Dst> annotations
  (missing_transmute_annotations).
- packthru / unsorted-packthru: iterate with enumerate() instead of range
  indexing (needless_range_loop).
- async-passthru: pass &packet (not &mut) to send_packet_to_mstcp
  (unnecessary_mut_passed).
- async examples: sort with sort_by_key(Reverse(..)) (unnecessary sort_by),
  and allow arc_with_non_send_sync where the async API intentionally shares
  an Arc<Ndisapi> (Ndisapi owns a raw HANDLE and is deliberately !Send/!Sync).
- lib: drop a redundant & in two format! args flagged by nightly clippy.

Verified locally on stable and nightly: clippy --all-targets -D clippy::all,
cargo test, cargo fmt --check, and cargo publish --dry-run all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 19:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors several examples and source files to improve code quality, readability, and idiomatic Rust usage. Key changes include replacing manual indexing with iterators, removing unnecessary references in format strings, and adding clippy allowances for Arc usage. The review feedback highlights opportunities to further improve safety and idiomaticity by replacing unsafe mem::transmute calls with safe .into() conversions for IP addresses and using the as operator for pointer casting.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/listadapters.rs Outdated
Comment thread src/netlib/ip_helper/sockaddr_storage.rs Outdated
Comment thread src/netlib/ip_helper/sockaddr_storage.rs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates test and example code (plus two small format! call adjustments) to satisfy clippy::all on current stable/nightly toolchains so the publish workflow can pass for the 0.7.0 release, without changing library behavior.

Changes:

  • Adds explicit type parameters to mem::transmute calls in tests/examples to satisfy newer Clippy lints.
  • Refactors packet-processing loops in examples to avoid needless_range_loop by iterating with enumerate().
  • Tweaks async examples to address unnecessary_mut_passed, unnecessary sort_by, and arc_with_non_send_sync lints.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/netlib/ip_helper/sockaddr_storage.rs Makes transmute annotations explicit in tests to satisfy missing_transmute_annotations.
src/netlib/ip_helper/network_adapter_info.rs Removes redundant borrow in format! argument (but needs formatting cleanup).
src/ndisapi/static_api.rs Removes redundant borrow in format! argument.
examples/unsorted-packthru.rs Uses iterator + enumerate() instead of index loop to satisfy Clippy.
examples/packthru.rs Uses iterator + enumerate() and passes packet refs directly to request builders.
examples/listadapters.rs Adds explicit transmute type parameters for Clippy (can be simplified to cast).
examples/async-passthru.rs Stops passing &mut where not needed; adds a targeted Clippy allow for Arc<!Send + !Sync>.
examples/async-packthru.rs Uses sort_by_key(Reverse(..)) and adds the targeted Clippy allow for Arc<!Send + !Sync>.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/netlib/ip_helper/network_adapter_info.rs Outdated
Comment thread examples/listadapters.rs
- listadapters: cast the pointer with `.cast::<u8>()` instead of
  `mem::transmute`, and drop the now-unused `mem` import.
- sockaddr_storage tests: build IN_ADDR / IN6_ADDR via the safe
  `Ipv4Addr` / `Ipv6Addr` `.into()` conversions rather than
  `unsafe mem::transmute`.
- set_friendly_name: fix the `format!` indentation.

Verified on stable and nightly: clippy --all-targets -D clippy::all,
cargo test, and cargo fmt --check all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@wiresock
wiresock merged commit 57c37bb into main Jun 24, 2026
6 checks passed
@wiresock
wiresock deleted the chore/clippy-all-targets-release branch June 24, 2026 20:00
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.

2 participants