Suppress "constant is never used"

Today's n00b question: How do I suppress

warning: constant is never used: `LL_RELIABLE_FLAG`
  --> src/messages/mod.rs:26:1
   |
26 | const LL_RELIABLE_FLAG: u8 = 0x40;      // This packet was sent reliably (implies please ack this packet)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

Source code is:

#[allow(dead_code)]                     // ***TEMP***
const LL_ZERO_CODE_FLAG: u8 = 0x80;     // 0's in packet body are run length encoded, such that series of 1 to 255 zero bytes are encoded to take 2 bytes.
const LL_RELIABLE_FLAG: u8 = 0x40;      // This packet was sent reliably (implies please ack this packet)
const LL_RESENT_FLAG: u8 = 0x20;        // This packet is a resend from the source.
const LL_ACK_FLAG: u8 = 0x10;           // This packet contains appended acks.

The

#[allow(dead_code)]  

should have suppressed those messages, right?

What I'm doing, obviously, is writing all the definitions first, with code to follow. So I'd like to quiet down the warning noise for a while.

#[allow(dead_code)] will only apply to the item that immediately follows it.

You can either repeat it before each const, or you can put #![allow(dead_code)] (note the exclamation point) at the top of the file to apply it to the entire module.

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.