Skip to content

Spurious dead_code warning #11224

Closed
@tomdale

Description

@tomdale

Rust is telling us that a method is not being called, but we're pretty sure that it is. There is no warning any other methods that call into it, and we believe the program would not work if this method was indeed not being called. :P

To reproduce, check out our protobuf library at the specific SHA here: https://github.com/tildeio/buffoon/tree/a6793623c496e83d578866e7f7ea34ae22370f96

Then compile the protobuf library by running:

cd src
rustc --rlib buffoon/lib.rs

(You can also just type rake from the top-level directory if you have Ruby installed.)

This is the error message we're getting:

buffoon/wire_type.rs:10:0: 19:1 warning: code is never used: `wire_type_bits`, #[warn(dead_code)] on by default
buffoon/wire_type.rs:10 pub fn wire_type_bits(wire_type: WireType) -> u64 {
buffoon/wire_type.rs:11   match wire_type {
buffoon/wire_type.rs:12     Varint => 0,
buffoon/wire_type.rs:13     SixtyFourBit => 1,
buffoon/wire_type.rs:14     LengthDelimited => 2,
buffoon/wire_type.rs:15     StartGroup => 3,

This function gets called from src/buffoon/output_stream.rs:66, which, as you can see, does not get a dead code warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions