Skip to content

Clippy complains about unused assignments in the Encode derive macro in nightly. #89

@ReCore-sys

Description

@ReCore-sys

A project I'm working on uses nightly and recently clippy has started throwing some errors regarding unused assignments. I am currently using nightly version 1.92.0 (367fd9f21 2025-10-15) and the following snippet of code is causing linting errors:

#[derive(Encode, Decode, Clone, Eq, PartialEq, Debug)]
pub enum PaletteType {
    Single(VarInt),
    Indirect {
        bits_per_block: u8,
        data: Vec<i64>,
        palette: Vec<VarInt>,
    },
    Direct {
        bits_per_block: u8,
        data: Vec<i64>,
    },
}

with the following error from running cargo clippy:

warning: value assigned to `bits_per_block` is never read
  --> src\lib\world\src\chunk_format.rs:61:9
   |
61 |         bits_per_block: u8,
   |         ^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

warning: value assigned to `data` is never read
  --> src\lib\world\src\chunk_format.rs:62:9
   |
62 |         data: Vec<i64>,
   |         ^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `palette` is never read
  --> src\lib\world\src\chunk_format.rs:63:9
   |
63 |         palette: Vec<VarInt>,
   |         ^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `bits_per_block` is never read
  --> src\lib\world\src\chunk_format.rs:66:9
   |
66 |         bits_per_block: u8,
   |         ^^^^^^^^^^^^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `data` is never read
  --> src\lib\world\src\chunk_format.rs:67:9
   |
67 |         data: Vec<i64>,
   |         ^^^^
   |
   = help: maybe it is overwritten before being read?

The fields are 100% being read and written to in other parts of the codebase, even in the same file. Removing the Encode derive macro causes these linting errors to disappear. We are using Encode/Decode in many other places in the codebase but as far as I know, this is the only instance where we use it on enums with fields, the rest are either structs or plain enums.
Here is an expanded version of the macro: https://gist.github.com/ReCore-sys/50285d4eb94a6cd52bb9b9fffadb510c
This has only cropped up recently and since we try to stay on the latest version of nightly, this is likely an issues with bleeding-edge clippy having breaking changes, not your code but I'd still appreciate it if this could be looked into.
I do want to note that this appears to only be an issue with the Encode derive macro, removing/adding the Decode one doesn't fix the linting errors in any way.
I'm happy to link the full codebase if needed but I don't want to come across as advertising my project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions