Skip to content

Commit 9e9be12

Browse files
chore(clippy): enforce production denies under the virt feature
The denies (panic, unwrap, expect, indexing_slicing, and others) were gated on not(any(test, feature = "virt")). Every CI job builds with --all-features, so the virt feature was always on and the denies never ran in CI. Violations could then land unnoticed. Gate the denies on not(test) instead, so they cover production code even when virt is enabled. The few virt test-utility match arms that panic on a poisoned lock or mark an unreachable path keep a local allow. The now-redundant module-level deny in psl is dropped.
1 parent 7fd290f commit 9e9be12

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

libwebauthn/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
// Tests and the virt test-utility feature are allowed to use unwrap/expect/panic for convenience.
2-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::unwrap_used))]
3-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::expect_used))]
4-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::panic))]
5-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::todo))]
6-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::unreachable))]
7-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::indexing_slicing))]
8-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::unwrap_in_result))]
1+
// Production code must not panic. Tests keep unwrap/expect/panic latitude
2+
// through `not(test)`, and the virt test-utility code through local allows.
3+
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
4+
#![cfg_attr(not(test), deny(clippy::expect_used))]
5+
#![cfg_attr(not(test), deny(clippy::panic))]
6+
#![cfg_attr(not(test), deny(clippy::todo))]
7+
#![cfg_attr(not(test), deny(clippy::unreachable))]
8+
#![cfg_attr(not(test), deny(clippy::indexing_slicing))]
9+
#![cfg_attr(not(test), deny(clippy::unwrap_in_result))]
910

1011
#[cfg(all(
1112
feature = "nfc",

libwebauthn/src/ops/webauthn/psl/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
//! Most callers should use [`SystemPublicSuffixList::auto`], which probes
2121
//! the standard system paths for whichever format is available.
2222
23-
// Module-scoped until the crate-wide indexing_slicing deny lands.
24-
#![cfg_attr(not(any(test, feature = "virt")), deny(clippy::indexing_slicing))]
25-
2623
pub mod dafsa;
2724
pub mod dat;
2825
mod system;

libwebauthn/src/transport/hid/channel.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ impl<'d> HidChannel<'d> {
244244
.open_device(&hidapi)
245245
.or(Err(Error::Transport(TransportError::ConnectionFailed)))?),
246246
#[cfg(feature = "virt")]
247+
#[allow(clippy::unreachable)]
248+
// virtual devices never go through hid_open
247249
HidBackendDevice::VirtualDevice(_) => unreachable!(),
248250
}
249251
}
@@ -317,6 +319,8 @@ impl<'d> HidChannel<'d> {
317319
response
318320
}
319321
#[cfg(feature = "virt")]
322+
#[allow(clippy::panic)]
323+
// virt test-utility: a poisoned lock is unrecoverable
320324
OpenHidDevice::VirtualDevice(backend) => {
321325
let Ok(mut guard) = backend.lock() else {
322326
panic!("Poisoned lock on Virtual HID device");
@@ -378,6 +382,8 @@ impl<'d> HidChannel<'d> {
378382
})?
379383
}
380384
#[cfg(feature = "virt")]
385+
#[allow(clippy::panic)]
386+
// virt test-utility: a poisoned lock is unrecoverable
381387
OpenHidDevice::VirtualDevice(backend) => {
382388
let Ok(mut guard) = backend.lock() else {
383389
panic!("Poisoned lock on Virtual HID device");

0 commit comments

Comments
 (0)