From c9ead4210886f68205d0fd8ec6a6b78a4923833d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Laitl?= Date: Thu, 5 Dec 2024 21:46:37 +0100 Subject: [PATCH] Fix clippy 1.83 warnings (elite lifetimes, use non_exhaustive) --- server/src/error.rs | 2 +- shared/src/types.rs | 8 ++++---- wireguard-control/src/backends/kernel.rs | 2 -- wireguard-control/src/backends/userspace.rs | 2 -- wireguard-control/src/config.rs | 1 - wireguard-control/src/device.rs | 5 ++--- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/server/src/error.rs b/server/src/error.rs index 16541c4..6adb191 100644 --- a/server/src/error.rs +++ b/server/src/error.rs @@ -36,7 +36,7 @@ pub enum ServerError { Hyper(#[from] hyper::Error), } -impl<'a> From<&'a ServerError> for StatusCode { +impl From<&ServerError> for StatusCode { fn from(error: &ServerError) -> StatusCode { use ServerError::*; match error { diff --git a/shared/src/types.rs b/shared/src/types.rs index cd8f156..947c90c 100644 --- a/shared/src/types.rs +++ b/shared/src/types.rs @@ -110,7 +110,7 @@ impl<'de> Deserialize<'de> for Endpoint { D: serde::Deserializer<'de>, { struct EndpointVisitor; - impl<'de> serde::de::Visitor<'de> for EndpointVisitor { + impl serde::de::Visitor<'_> for EndpointVisitor { type Value = Endpoint; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -238,7 +238,7 @@ pub struct CidrTree<'a> { contents: &'a Cidr, } -impl<'a> std::ops::Deref for CidrTree<'a> { +impl std::ops::Deref for CidrTree<'_> { type Target = Cidr; fn deref(&self) -> &Self::Target { @@ -718,7 +718,7 @@ impl<'a> PeerDiff<'a> { } } -impl<'a> From<&'a Peer> for PeerConfigBuilder { +impl From<&Peer> for PeerConfigBuilder { fn from(peer: &Peer) -> Self { PeerDiff::new(None, Some(peer)) .expect("No Err on explicitly set peer data") @@ -727,7 +727,7 @@ impl<'a> From<&'a Peer> for PeerConfigBuilder { } } -impl<'a> From> for PeerConfigBuilder { +impl From> for PeerConfigBuilder { /// Turn a PeerDiff into a minimal set of instructions to update the WireGuard interface, /// hopefully minimizing dropped packets and other interruptions. fn from(diff: PeerDiff) -> Self { diff --git a/wireguard-control/src/backends/kernel.rs b/wireguard-control/src/backends/kernel.rs index 9b4ac0b..ea067a1 100644 --- a/wireguard-control/src/backends/kernel.rs +++ b/wireguard-control/src/backends/kernel.rs @@ -118,7 +118,6 @@ impl TryFrom for PeerInfo { endpoint, persistent_keepalive_interval, allowed_ips, - __cant_construct_me: (), }, stats: PeerStats { last_handshake_time, @@ -158,7 +157,6 @@ impl<'a> TryFrom<&'a [WgDeviceAttrs]> for Device { peers, linked_name: None, backend: Backend::Kernel, - __cant_construct_me: (), }) } } diff --git a/wireguard-control/src/backends/userspace.rs b/wireguard-control/src/backends/userspace.rs index 961ae23..0f1e690 100644 --- a/wireguard-control/src/backends/userspace.rs +++ b/wireguard-control/src/backends/userspace.rs @@ -86,7 +86,6 @@ fn new_peer_info(public_key: Key) -> PeerInfo { endpoint: None, persistent_keepalive_interval: None, allowed_ips: vec![], - __cant_construct_me: (), }, stats: PeerStats { last_handshake_time: None, @@ -119,7 +118,6 @@ impl ConfigParser { peers: vec![], linked_name: resolve_tun(name).ok(), backend: Backend::Userspace, - __cant_construct_me: (), }; Self { diff --git a/wireguard-control/src/config.rs b/wireguard-control/src/config.rs index 909351b..54adc85 100644 --- a/wireguard-control/src/config.rs +++ b/wireguard-control/src/config.rs @@ -69,7 +69,6 @@ impl PeerConfigBuilder { endpoint: self.endpoint, persistent_keepalive_interval: self.persistent_keepalive_interval, allowed_ips: self.allowed_ips, - __cant_construct_me: (), } } diff --git a/wireguard-control/src/device.rs b/wireguard-control/src/device.rs index ca2c040..24c2aac 100644 --- a/wireguard-control/src/device.rs +++ b/wireguard-control/src/device.rs @@ -46,6 +46,7 @@ impl std::str::FromStr for AllowedIp { /// /// These are the attributes that don't change over time and are part of the configuration. #[derive(Debug, PartialEq, Eq, Clone)] +#[non_exhaustive] pub struct PeerConfig { /// The public key of the peer. pub public_key: Key, @@ -57,7 +58,6 @@ pub struct PeerConfig { pub persistent_keepalive_interval: Option, /// The IP addresses this peer is allowed to have. pub allowed_ips: Vec, - pub(crate) __cant_construct_me: (), } /// Represents a single peer's current statistics (i.e. the data from the current session). @@ -91,6 +91,7 @@ pub struct PeerInfo { /// The peer statistics are retrieved once at construction time, /// and need to be updated manually by calling [`get_by_name`](DeviceInfo::get_by_name). #[derive(Debug, PartialEq, Eq, Clone)] +#[non_exhaustive] pub struct Device { /// The interface name of this device pub name: InterfaceName, @@ -108,8 +109,6 @@ pub struct Device { pub linked_name: Option, /// The backend the device exists on (userspace or kernel). pub backend: Backend, - - pub(crate) __cant_construct_me: (), } type RawInterfaceName = [c_char; libc::IFNAMSIZ];