Skip to content

Commit c7cfdae

Browse files
doublegateclaude
andcommitted
fix(windows): Suppress unused variable warnings in discovery.rs
## Problem Windows builds were generating 6 warnings in the discovery module: - 3 x "unused variable: `iter`" - 3 x "variable does not need to be mutable" These warnings appeared in all Windows build steps (Build, Run tests, Build release) due to platform-specific conditional compilation. ## Root Cause On Windows, the `iter` variable is created but never used because: 1. Unix uses: `iter.next_with_timeout(Duration::from_millis(100))` 2. Windows uses: `Ok(None)` (method doesn't exist on Windows) The `iter` variable is necessary for Unix but unused on Windows, causing the compiler to warn about unused mutable variables. ## Solution Added `#[cfg_attr(windows, allow(unused_variables, unused_mut))]` attributes to all 3 iterator creation sites: **Line 203**: ICMP Echo Request iterator **Line 284**: ICMPv6 Echo Request iterator **Line 407**: NDP Neighbor Solicitation iterator This tells the compiler to suppress these warnings only on Windows builds, where the variables are legitimately unused. ## Testing **Linux**: ✅ ALL PASS - cargo build --release: 0 warnings - cargo clippy: 0 warnings - cargo test: 270 passed, 5 ignored **Expected Windows**: ✅ 0 warnings - All 6 warnings will be suppressed by cfg_attr ## Technical Details **Approach**: Platform-specific warning suppression - Unix: Uses `iter` normally, no warnings - Windows: Suppresses warnings for intentionally unused variable **Alternative Approaches Considered**: 1. ❌ Remove `iter` on Windows - breaks code structure 2. ❌ Use `_iter` prefix - doesn't fix "unused mut" warning 3. ✅ `cfg_attr` - Clean, explicit, platform-specific ## Impact - Zero functional changes - Cleaner Windows build output (0 warnings) - Better CI experience (no noise in logs) - Makes actual warnings more visible 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d836112 commit c7cfdae

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

crates/prtip-scanner/src/discovery.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ impl DiscoveryEngine {
200200

201201
// Wait for Echo Reply (Type 0) with timeout
202202
let start = std::time::Instant::now();
203+
#[cfg_attr(windows, allow(unused_variables, unused_mut))]
203204
let mut iter = icmp_packet_iter(&mut rx);
204205

205206
while start.elapsed() < self.timeout {
@@ -280,6 +281,7 @@ impl DiscoveryEngine {
280281

281282
// Wait for Echo Reply (Type 129) with timeout
282283
let start = std::time::Instant::now();
284+
#[cfg_attr(windows, allow(unused_variables, unused_mut))]
283285
let mut iter = pnet::transport::icmpv6_packet_iter(&mut rx);
284286

285287
while start.elapsed() < self.timeout {
@@ -402,6 +404,7 @@ impl DiscoveryEngine {
402404

403405
// Wait for Neighbor Advertisement (Type 136)
404406
let start = std::time::Instant::now();
407+
#[cfg_attr(windows, allow(unused_variables, unused_mut))]
405408
let mut iter = pnet::transport::icmpv6_packet_iter(&mut rx);
406409

407410
while start.elapsed() < self.timeout {

0 commit comments

Comments
 (0)