Skip to content

zephyr-build, zephyr-macros: pass clippy -D warnings - #1

Open
JPHutchins wants to merge 3 commits into
ci/run-on-all-prsfrom
clippy/1-host-crates
Open

JPHutchins wants to merge 3 commits into
ci/run-on-all-prsfrom
clippy/1-host-crates

Conversation

@JPHutchins

@JPHutchins JPHutchins commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Warning

LLM Disclosure

This post was authored by claude-opus-5-5 on behalf of @JPHutchins. JP asked to bring zephyr-lang-rust under strict clippy rules matching embassy's (default groups, -D warnings), to report deficiencies found along the way, and to open the work as a stacked series of review PRs on the intercreate fork.

zephyr-build and zephyr-macros fail cargo clippy -- -D warnings. The devicetree code generator also emits &'static on every generated static, which adds one redundant_static_lifetimes error per devicetree property (167 for native_sim/native/64) once the zephyr crate is linted. No behavior change: the generated devicetree.rs for native_sim/native/64 is byte-identical before and after the refactor.

Stack, merge in order:

  1. ci: run the build and docs workflows on pull requests to any branch #5: CI on pull requests to any branch
  2. zephyr-build, zephyr-macros: pass clippy -D warnings #1: host crates pass clippy (this PR)
  3. zephyr: pass the module's clippy flags #2: the zephyr crate passes the module's clippy flags
  4. cmake: lint the zephyr crate with a clippy_zephyr target #3: clippy_zephyr target and CI
  5. zephyr: fix unsafe contracts found while documenting unsafe code #4: unsafe-contract fixes
  6. zephyr: device: gpio: implement embedded-hal-async digital::Wait #6: embedded_hal_async::digital::Wait for GpioPin
Commits
Testing
  • rustc/clippy 1.95.0: cargo fmt --check and cargo clippy --all-targets -- -D warnings pass in zephyr-build, and cargo clippy -- -D warnings passes in zephyr-macros.
  • devicetree.rs generated for samples/hello_world on native_sim/native/64 compared with cmp before and after the slice-pattern commit: identical.
  • samples/hello_world builds for native_sim/native/64 at this PR's head.

Review notes

The devicetree code generator emits one
`pub static RAW_*: &'static [crate::devicetree::Value]` per property.
Statics are already 'static, so clippy's redundant_static_lifetimes
rejects every one of them: 167 errors for a native_sim/native/64 build
when the zephyr crate is linted with the module's own clippy flags
(-D warnings -D clippy::undocumented_unsafe_blocks).

CI never reported this because the module's clippy target lints only
the application crate. The zephyr crate is a patched path dependency,
not a workspace member, so cargo does not run clippy-driver on it.

Assisted-by: Claude:claude-opus-5-5
clippy::collapsible_match rejects the nested `if` inside the
`Value::Words` arm of `property_walk`, so `cargo clippy -- -D warnings`
fails on this host crate.

Match the single number with a slice pattern instead, and make each
arm an expression rather than an early `return`. The generated
devicetree.rs for native_sim/native/64 is byte-identical before and
after.

Assisted-by: Claude:claude-opus-5-5
`cargo clippy -- -D warnings` fails on this host crate:
`!x.is_none()` is `x.is_some()` (nonminimal_bool), and comparing an
`Ident` against a string does not need `to_string()` first
(cmp_owned). Applied with `cargo clippy --fix`.

Assisted-by: Claude:claude-opus-5-5
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