Skip to content

Add #[must_use] to relevant generated methods - #147

Open
danlehmann wants to merge 2 commits into
mainfrom
fix-mustuse-lint
Open

Add #[must_use] to relevant generated methods#147
danlehmann wants to merge 2 commits into
mainfrom
fix-mustuse-lint

Conversation

@danlehmann

@danlehmann danlehmann commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Most methods on bitfields are without side effects, therefore it makes sense to mark them as #[must_use].

nicopap and others added 2 commits August 27, 2026 14:44
Most methods on bitfields are without side effects, therefore it makes
sense to mark them as `#[must_use]`.

* This fixes #140
* Since now, we get a warning on non-used return values on existing
  builder methods, we have to ignore some return types in the tests
* I added a `#![deny(clippy::must_use_candidate)]` to one of the tests
  to ensure no regression.
- Move the clippy::must_use_candidate enforcement into a dedicated library
  crate (bitbybit-compile-checks) and lint it explicitly in CI. The lint only
  applies to genuinely public items, and items inside integration-test binaries
  are never considered public, so the previous in-test guard in basic.rs was
  vacuous.
- The bitfield in the check crate exercises every generated method shape
  (plain/indexed getters and setters, ro/wo/rw fields, arbitrary-int fields,
  and a bitenum custom type), so dropping a #[must_use] from the macro fails it.
- CHANGELOG entry
@danlehmann danlehmann changed the title Fix mustuse lint Add #[must_use] to relevant generated methods Aug 27, 2026
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.

bitfield macro triggers clippy::must_use_candidate lints since 2.0.1

2 participants