From 6dbafbcb508da2b25afad7a6af385ad324d06391 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Fri, 7 Jul 2023 16:19:29 +0200 Subject: [PATCH] improve conditional compilation for unix see also https://github.com/mbrubeck/agate/pull/274#issuecomment-1624453851 --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5f57565..6a49c0f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -159,8 +159,7 @@ static ARGS: Lazy = Lazy::new(|| { struct Args { addrs: Vec, - // only used on unix, so dead code on windows - #[cfg_attr(windows, allow(dead_code))] + #[cfg(unix)] sockets: Vec, content_dir: PathBuf, certs: Arc, @@ -349,10 +348,10 @@ fn args() -> Result { addrs.push(i.parse()?); } - #[allow(unused_mut)] // only used on unix + #[cfg_attr(not(unix), allow(unused_mut))] let mut empty = addrs.is_empty(); - #[allow(unused_mut)] // only used on unix + #[cfg(unix)] let mut sockets = vec![]; #[cfg(unix)] { @@ -372,6 +371,7 @@ fn args() -> Result { Ok(Args { addrs, + #[cfg(unix)] sockets, content_dir: check_path(matches.opt_get_default("content", "content".into())?)?, certs: Arc::new(certs), @@ -463,7 +463,7 @@ impl RequestHandle { } } -#[cfg(target_family = "unix")] +#[cfg(unix)] impl RequestHandle { async fn new_unix( stream: UnixStream,