Skip to content

Commit

Permalink
Fix clippy warnings (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia authored Jun 29, 2024
1 parent 643618c commit d2b59c5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/child/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pub use start::start_child;

// This shouldn't be seeing very many requests. If this many concurrent requests are occurring,
// it's clearly a sign that *way* too many requests are being sent.
pub(self) const PENDING_REQUEST_CAPACITY: usize = 256;
pub const PENDING_REQUEST_CAPACITY: usize = 256;
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#![cfg_attr(not(test), deny(clippy::use_debug))]
// Panicking in tests is okay.
#![cfg_attr(not(test), deny(clippy::arithmetic_side_effects))]
// Type checking is good enough for me.
#![allow(clippy::missing_transmute_annotations)]

// Now for all the module specifications

Expand Down
9 changes: 0 additions & 9 deletions src/parent/ipc/native_ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::process::Stdio;
use std::time::SystemTime;

// Don't leak the process in case of spawn error.
struct KillChildOnDrop<'a>(Option<&'a mut std::process::Child>);

#[cold]
fn panic_if_real_error(e: Error) {
Expand All @@ -27,14 +26,6 @@ fn terminate_raw_child(child: &mut std::process::Child) {
}
}

impl Drop for KillChildOnDrop<'_> {
fn drop(&mut self) {
if let Some(child) = self.0.take() {
terminate_raw_child(child)
}
}
}

type ChildStdio = (std::process::ChildStdin, std::process::ChildStdout);

struct UserGroupTableCacheEntry {
Expand Down
24 changes: 11 additions & 13 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// A nice, pretty prelude to cut down on the vast number of `use` statements commonly used.

#[cfg(test)]
mod test_prelude {
pub use crate::test_utils::*;
pub use quickcheck::Arbitrary;
pub use quickcheck::Gen;
pub use quickcheck_macros::quickcheck;
}

#[cfg(test)]
pub use test_prelude::*;

pub use crate::common::*;
pub use crate::ffi::normalize_errno;
pub use crate::state::*;
Expand All @@ -23,7 +12,6 @@ pub use std::io::BufRead;
pub use std::io::Error;
pub use std::io::ErrorKind;
pub use std::io::Read;
pub use std::io::Seek;
pub use std::io::Write;
pub use std::mem::replace;
pub use std::mem::take;
Expand All @@ -36,6 +24,16 @@ pub use std::sync::Mutex;
pub use std::sync::MutexGuard;
pub use std::sync::Once;
pub use std::sync::RwLock;
pub use std::task::*;
pub use std::time::Duration;
pub use std::time::Instant;

#[cfg(test)]
pub use test_prelude::*;

#[cfg(test)]
mod test_prelude {
pub use crate::test_utils::*;
pub use quickcheck::Arbitrary;
pub use quickcheck::Gen;
pub use quickcheck_macros::quickcheck;
}
4 changes: 1 addition & 3 deletions src/state/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ impl fmt::Debug for Key {

fn is_valid_hex_string(bytes: &[u8]) -> bool {
matches!(bytes.len(), len @ 1..=MAX_KEY_LEN if len % 2 == 0)
&& bytes
.iter()
.all(|b| matches!(b, b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f'))
&& bytes.iter().all(|b| b.is_ascii_hexdigit())
}

fn normalize_hex(byte: u8) -> u8 {
Expand Down

0 comments on commit d2b59c5

Please sign in to comment.