Skip to content

Linter issue with enums #95

Closed as duplicate
Closed as duplicate

Description

@nhatcher

In the latest Rust version (1.92), encoding enums gives a linter error.

For instance, running cargo clippy on:

use bitcode::{Decode, Encode};

#[derive(Clone, Encode, Decode, PartialEq, Debug)]
enum Diff {
    SetCellValue {
        sheet: u32,
        row: i32,
        column: i32,
        new_value: String,
    },
    CellClearContents {
        sheet: u32,
        row: i32,
        column: i32,
    },
}

fn main() {
    let original = Diff::SetCellValue {
        sheet: 0,
        row: 1,
        column: 2,
        new_value: "Hello, world!".to_string(),
    };
    let encoded: Vec<u8> = bitcode::encode(&original);
    let decoded: Diff = bitcode::decode(&encoded).unwrap();
    assert_eq!(original, decoded);
}

produces a bunch of:

warning: value assigned to `sheet` is never read
 --> src/main.rs:7:9
  |
7 |         sheet: u32,
  |         ^^^^^
  |
  = help: maybe it is overwritten before being read?
  = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

warning: value assigned to `row` is never read
 --> src/main.rs:8:9
  |
8 |         row: i32,
  |         ^^^
  |
  = help: maybe it is overwritten before being read?

Also, since I am here. Amazing project! Huge fan!

Activity

  1. finnbear commented on Dec 17, 2025

    @finnbear
    Member

    Thanks very much! This is a duplicate of #89 but I don't blame you because I closed that issue when the PR fixing it merged, but before updating crates.io

  2. nhatcher commented on Dec 17, 2025

    @nhatcher
    Author

    Amazing, thank you!

  3. finnbear commented on Dec 17, 2025

    @finnbear
    Member

    bitcode@0.6.8 is available. Please confirm that it fixes this :)

  4. nhatcher commented on Dec 17, 2025

    @nhatcher
    Author

    Confirmed!

    ironcalc/IronCalc#641

    That is what I call I quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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