Skip to content

Commit

Permalink
Fix clippy 1.83 warnings (elite lifetimes, use non_exhaustive)
Browse files Browse the repository at this point in the history
  • Loading branch information
strohel committed Dec 5, 2024
1 parent b2e4149 commit c9ead42
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand All @@ -727,7 +727,7 @@ impl<'a> From<&'a Peer> for PeerConfigBuilder {
}
}

impl<'a> From<PeerDiff<'a>> for PeerConfigBuilder {
impl From<PeerDiff<'_>> 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 {
Expand Down
2 changes: 0 additions & 2 deletions wireguard-control/src/backends/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl TryFrom<WgPeer> for PeerInfo {
endpoint,
persistent_keepalive_interval,
allowed_ips,
__cant_construct_me: (),
},
stats: PeerStats {
last_handshake_time,
Expand Down Expand Up @@ -158,7 +157,6 @@ impl<'a> TryFrom<&'a [WgDeviceAttrs]> for Device {
peers,
linked_name: None,
backend: Backend::Kernel,
__cant_construct_me: (),
})
}
}
Expand Down
2 changes: 0 additions & 2 deletions wireguard-control/src/backends/userspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -119,7 +118,6 @@ impl ConfigParser {
peers: vec![],
linked_name: resolve_tun(name).ok(),
backend: Backend::Userspace,
__cant_construct_me: (),
};

Self {
Expand Down
1 change: 0 additions & 1 deletion wireguard-control/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl PeerConfigBuilder {
endpoint: self.endpoint,
persistent_keepalive_interval: self.persistent_keepalive_interval,
allowed_ips: self.allowed_ips,
__cant_construct_me: (),
}
}

Expand Down
5 changes: 2 additions & 3 deletions wireguard-control/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -57,7 +58,6 @@ pub struct PeerConfig {
pub persistent_keepalive_interval: Option<u16>,
/// The IP addresses this peer is allowed to have.
pub allowed_ips: Vec<AllowedIp>,
pub(crate) __cant_construct_me: (),
}

/// Represents a single peer's current statistics (i.e. the data from the current session).
Expand Down Expand Up @@ -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,
Expand All @@ -108,8 +109,6 @@ pub struct Device {
pub linked_name: Option<String>,
/// The backend the device exists on (userspace or kernel).
pub backend: Backend,

pub(crate) __cant_construct_me: (),
}

type RawInterfaceName = [c_char; libc::IFNAMSIZ];
Expand Down

0 comments on commit c9ead42

Please sign in to comment.