Skip to content

fix: clippy deny on empty map struct#30

Merged
nuskey8 merged 1 commit intonuskey8:mainfrom
paq:fix-empty-ranges
Apr 10, 2026
Merged

fix: clippy deny on empty map struct#30
nuskey8 merged 1 commit intonuskey8:mainfrom
paq:fix-empty-ranges

Conversation

@paq
Copy link
Copy Markdown
Contributor

@paq paq commented Apr 9, 2026

Issue

The FromMessagePack derive macro generates for _ in 0..0 for empty map structs, which clippy denies1.

Example code

#[derive(ToMessagePack, FromMessagePack, Debug, PartialEq)]
#[msgpack(map)]
struct Empty {}

let empty = Empty {};
let data = zerompk::to_msgpack_vec(&empty).unwrap();

Fix

Added #[allow(clippy::reversed_empty_ranges)] on the generated loop.


Footnotes

  1. https://rust-lang.github.io/rust-clippy/master/index.html#reversed_empty_ranges

Copilot AI review requested due to automatic review settings April 9, 2026 05:17
Copy link
Copy Markdown

Copilot AI left a comment

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 fixes a Clippy -D warnings failure caused by the FromMessagePack derive macro generating an empty range loop (for _ in 0..0) for map-based structs/variants with zero fields.

Changes:

  • Adds #[allow(clippy::reversed_empty_ranges)] to the generated map-deserialization loop for empty map structs.
  • Adds the same allow attribute to the generated map-deserialization loop for map-represented enum variants with zero active fields.

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

@nuskey8 nuskey8 merged commit ddd022b into nuskey8:main Apr 10, 2026
4 of 6 checks passed
@nuskey8
Copy link
Copy Markdown
Owner

nuskey8 commented Apr 10, 2026

Merged the PR. Thanks!

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.

3 participants