Compiler hallucinates on unused variable

I'm sharing this mostly for the lulz, but it may be related to a compiler bug or overzealous error correction by it.

warning: unused variable: `pan_id`
  --> /home/neumann/RustroverProjects/ezsp/src/zigbee/network_manager/incoming_message.rs:22:13
   |
22 |         let pan_id = self.get_pan_id().await?;
   |             ^^^^^^
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
help: if this is intentional, prefix it with an underscore
   |
22 |         let _pan_id = self.get_pan_id().await?;
   |             +
help: you might have meant to pattern match on the similarly named constant `HOME_GATEWAY`
   |
22 -         let pan_id = self.get_pan_id().await?;
22 +         let zigbee::network_manager::builder::HOME_GATEWAY = self.get_pan_id().await?;
   |

I especially found the similarly named part hilarious. :smiley:

3 Likes

Looks like it's a known issue: Lint `unused_variables`'s "typoed pattern" suggestion still suggests invalid and unrelated paths · Issue #147595 · rust-lang/rust · GitHub

3 Likes