fix a bunch of lints

This commit is contained in:
Qyriad 2026-03-22 15:57:38 +01:00
parent aed73e99be
commit 420fac5f18
5 changed files with 40 additions and 41 deletions

View file

@ -26,7 +26,7 @@ use crate::{
use crate::{OwnedFdWithFlags, TokenFd};
pub static UID: LazyLock<Uid> = LazyLock::new(|| rustix::process::getuid());
pub static UID: LazyLock<Uid> = LazyLock::new(rustix::process::getuid);
pub static USER_SOCKET_DIR: LazyLock<&'static Path> = LazyLock::new(|| {
let dir: Box<Path> = env::var_os("XDG_RUNTIME_DIR")
@ -52,19 +52,23 @@ pub enum ConvenientAttrPath {
}
impl ConvenientAttrPath {
/// Not currently used, but here for completeness.
#[expect(dead_code)]
pub fn clone_from_dotted(s: &str) -> Self {
Self::Dotted(Box::from(s))
}
/// Not currently used, but here for completeness.
#[expect(dead_code)]
pub fn clone_from_split(s: &[&str]) -> Self {
Self::from_str_iter(s.into_iter().map(Deref::deref))
Self::from_str_iter(s.iter().map(Deref::deref))
}
pub fn from_str_iter<'i, I>(iter: I) -> Self
where
I: Iterator<Item = &'i str>,
{
let boxed = iter.map(|s| Box::from(s));
let boxed = iter.map(Box::from);
Self::Split(Box::from_iter(boxed))
}
@ -254,10 +258,10 @@ impl Daemon {
debug!("opened daemon to {:?} file descriptor {fd:?}", name);
let path = match &name {
Some(name) => Some(PathBuf::from(name).into_boxed_path()),
None => None,
};
let path = name
.as_ref()
.map(PathBuf::from)
.map(PathBuf::into_boxed_path);
Self {
config_path,

View file

@ -130,7 +130,7 @@ impl From<OwnedFd> for OwnedFdWithFlags {
impl Read for &OwnedFdWithFlags {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, IoError> {
debug_assert!(buf.len() > 0);
debug_assert!(!buf.is_empty());
loop {
buf.fill(0);
match rustix::io::read(self.as_ref_owned(), &mut *buf) {

View file

@ -52,7 +52,7 @@ impl FdInfo {
match Self::guess_name(self.fd) {
Ok(name) => {
let prev = self.name.set(Box::from(name));
let prev = self.name.set(name);
debug_assert_eq!(prev, Ok(()));
},
Err(e) => {
@ -105,13 +105,14 @@ impl<'a> Display for FdInfoDisplay<'a> {
}
#[derive(Copy)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[non_exhaustive]
pub enum FdKind {
File,
Socket,
SockStream,
Poller,
#[default]
Unknown,
}
@ -128,12 +129,6 @@ impl FdKind {
}
}
impl Default for FdKind {
fn default() -> FdKind {
FdKind::Unknown
}
}
#[derive(Copy)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TokenFd {

View file

@ -14,7 +14,7 @@ use tracing_subscriber::{EnvFilter, layer::SubscriberExt};
fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
// Default RUST_LOG to warn if it's not specified.
if let None = env::var_os("RUST_LOG") {
if env::var_os("RUST_LOG").is_none() {
unsafe {
env::set_var("RUST_LOG", "warn");
}

View file

@ -5,27 +5,27 @@
#[allow(unused_imports)]
use crate::prelude::*;
#[derive(Debug, Clone, PartialEq, Hash)]
pub(crate) struct NixEvalExpr<E, A> {
pub(crate) expr: E,
pub(crate) attrpath: A,
}
impl<E, A> NixEvalExpr<E, A>
where
E: AsRef<OsStr>,
A: AsRef<OsStr>,
{
pub(crate) fn into_command(self) -> Command {
let mut cmd = Command::new("nix-instantiate");
cmd.arg("--eval")
.arg("--json")
.arg("--strict")
.arg("--expr")
.arg(self.expr)
.arg("-A")
.arg(self.attrpath);
cmd
}
}
//#[derive(Debug, Clone, PartialEq, Hash)]
//pub(crate) struct NixEvalExpr<E, A> {
// pub(crate) expr: E,
// pub(crate) attrpath: A,
//}
//
//impl<E, A> NixEvalExpr<E, A>
//where
// E: AsRef<OsStr>,
// A: AsRef<OsStr>,
//{
// pub(crate) fn into_command(self) -> Command {
// let mut cmd = Command::new("nix-instantiate");
// cmd.arg("--eval")
// .arg("--json")
// .arg("--strict")
// .arg("--expr")
// .arg(self.expr)
// .arg("-A")
// .arg(self.attrpath);
//
// cmd
// }
//}