diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2019-04-04 15:07:02 +0200 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2019-04-04 15:44:45 +0200 |
| commit | 4352b0adaabbfdbf92c55691b05c47984b2e2a95 (patch) | |
| tree | c5afe605414f9701790d90df0bf4173c6c0cfe60 /talpid-core/src | |
| parent | 2b2b0e3087ac4dcdc7ac1ae14a243ef182710a91 (diff) | |
| download | mullvadvpn-4352b0adaabbfdbf92c55691b05c47984b2e2a95.tar.xz mullvadvpn-4352b0adaabbfdbf92c55691b05c47984b2e2a95.zip | |
Add #![deny(rust_2018_idioms)] to all crates and fix warnings
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/dns/linux/mod.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/dns/linux/network_manager.rs | 10 | ||||
| -rw-r--r-- | talpid-core/src/dns/linux/systemd_resolved.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/firewall/linux.rs | 18 | ||||
| -rw-r--r-- | talpid-core/src/firewall/mod.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/lib.rs | 1 | ||||
| -rw-r--r-- | talpid-core/src/process/openvpn.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/proxy/mod.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/proxy/shadowsocks.rs | 2 | ||||
| -rw-r--r-- | talpid-core/src/tunnel/wireguard/mod.rs | 2 |
10 files changed, 24 insertions, 23 deletions
diff --git a/talpid-core/src/dns/linux/mod.rs b/talpid-core/src/dns/linux/mod.rs index 5f378875f4..4e379d01f3 100644 --- a/talpid-core/src/dns/linux/mod.rs +++ b/talpid-core/src/dns/linux/mod.rs @@ -74,7 +74,7 @@ pub enum DnsMonitorHolder { } impl fmt::Display for DnsMonitorHolder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::DnsMonitorHolder::*; let name = match self { Resolvconf(..) => "resolvconf", diff --git a/talpid-core/src/dns/linux/network_manager.rs b/talpid-core/src/dns/linux/network_manager.rs index 46777e8223..1ac732bdfc 100644 --- a/talpid-core/src/dns/linux/network_manager.rs +++ b/talpid-core/src/dns/linux/network_manager.rs @@ -53,7 +53,7 @@ impl NetworkManager { } fn ensure_network_manager_exists(&self) -> Result<()> { - let _: Box<RefArg> = self + let _: Box<dyn RefArg> = self .as_manager() .get(&NM_TOP_OBJECT, GLOBAL_DNS_CONF_KEY) .map_err(Error::NetworkManagerNotDetected)?; @@ -87,7 +87,7 @@ impl NetworkManager { Ok(()) } - fn as_manager(&self) -> dbus::ConnPath<&dbus::Connection> { + fn as_manager(&self) -> dbus::ConnPath<'_, &dbus::Connection> { self.dbus_connection .with_path(NM_BUS, NM_OBJECT_PATH, RPC_TIMEOUT_MS) } @@ -107,7 +107,7 @@ impl NetworkManager { } } -type GlobalDnsConfig = HashMap<&'static str, Variant<Box<RefArg>>>; +type GlobalDnsConfig = HashMap<&'static str, Variant<Box<dyn RefArg>>>; // The NetworkManager GlobalDnsConfiguration schema looks something like this // { @@ -146,8 +146,8 @@ fn create_empty_global_settings() -> GlobalDnsConfig { HashMap::new() } -fn as_variant<T: RefArg + 'static>(t: T) -> Variant<Box<RefArg>> { - Variant(Box::new(t) as Box<RefArg>) +fn as_variant<T: RefArg + 'static>(t: T) -> Variant<Box<dyn RefArg>> { + Variant(Box::new(t) as Box<dyn RefArg>) } fn eq_file_content<P: AsRef<Path>>(a: &P, b: &P) -> bool { diff --git a/talpid-core/src/dns/linux/systemd_resolved.rs b/talpid-core/src/dns/linux/systemd_resolved.rs index f8d0df11af..6ed023d9cd 100644 --- a/talpid-core/src/dns/linux/systemd_resolved.rs +++ b/talpid-core/src/dns/linux/systemd_resolved.rs @@ -92,7 +92,7 @@ impl SystemdResolved { } fn ensure_resolved_exists(&self) -> Result<()> { - let _: Box<RefArg> = self + let _: Box<dyn RefArg> = self .as_manager_object() .get(&MANAGER_INTERFACE, "DNS") .map_err(Error::NoSystemdResolved)?; @@ -130,7 +130,7 @@ impl SystemdResolved { } } - fn as_manager_object(&self) -> dbus::ConnPath<&dbus::Connection> { + fn as_manager_object(&self) -> dbus::ConnPath<'_, &dbus::Connection> { self.dbus_connection .with_path(RESOLVED_BUS, "/org/freedesktop/resolve1", RPC_TIMEOUT_MS) } diff --git a/talpid-core/src/firewall/linux.rs b/talpid-core/src/firewall/linux.rs index e687a7c7a7..85aa82eafb 100644 --- a/talpid-core/src/firewall/linux.rs +++ b/talpid-core/src/firewall/linux.rs @@ -446,7 +446,7 @@ impl<'a> PolicyBatch<'a> { } fn allow_interface_rule<'a>( - chain: &'a Chain, + chain: &'a Chain<'_>, direction: Direction, iface: &str, ) -> Result<Rule<'a>> { @@ -457,7 +457,7 @@ fn allow_interface_rule<'a>( Ok(rule) } -fn check_iface(rule: &mut Rule, direction: Direction, iface: &str) -> Result<()> { +fn check_iface(rule: &mut Rule<'_>, direction: Direction, iface: &str) -> Result<()> { let iface_index = crate::linux::iface_index(iface) .map_err(|e| Error::LookupIfaceIndexError(iface.to_owned(), e))?; rule.add_expr(&match direction { @@ -468,7 +468,7 @@ fn check_iface(rule: &mut Rule, direction: Direction, iface: &str) -> Result<()> Ok(()) } -fn check_net(rule: &mut Rule, end: End, net: IpNetwork) { +fn check_net(rule: &mut Rule<'_>, end: End, net: IpNetwork) { // Must check network layer protocol before loading network layer payload check_l3proto(rule, net.ip()); @@ -485,12 +485,12 @@ fn check_net(rule: &mut Rule, end: End, net: IpNetwork) { rule.add_expr(&nft_expr!(cmp == net.ip())); } -fn check_endpoint(rule: &mut Rule, end: End, endpoint: &Endpoint) { +fn check_endpoint(rule: &mut Rule<'_>, end: End, endpoint: &Endpoint) { check_ip(rule, end, endpoint.address.ip()); check_port(rule, endpoint.protocol, end, endpoint.address.port()); } -fn check_ip(rule: &mut Rule, end: End, ip: IpAddr) { +fn check_ip(rule: &mut Rule<'_>, end: End, ip: IpAddr) { // Must check network layer protocol before loading network layer payload check_l3proto(rule, ip); @@ -506,7 +506,7 @@ fn check_ip(rule: &mut Rule, end: End, ip: IpAddr) { } } -fn check_port(rule: &mut Rule, protocol: TransportProtocol, end: End, port: u16) { +fn check_port(rule: &mut Rule<'_>, protocol: TransportProtocol, end: End, port: u16) { // Must check transport layer protocol before loading transport layer payload check_l4proto(rule, protocol); @@ -519,7 +519,7 @@ fn check_port(rule: &mut Rule, protocol: TransportProtocol, end: End, port: u16) rule.add_expr(&nft_expr!(cmp == port.to_be())); } -fn check_l3proto(rule: &mut Rule, ip: IpAddr) { +fn check_l3proto(rule: &mut Rule<'_>, ip: IpAddr) { rule.add_expr(&nft_expr!(meta nfproto)); rule.add_expr(&nft_expr!(cmp == l3proto(ip))); } @@ -531,7 +531,7 @@ fn l3proto(addr: IpAddr) -> u8 { } } -fn check_l4proto(rule: &mut Rule, protocol: TransportProtocol) { +fn check_l4proto(rule: &mut Rule<'_>, protocol: TransportProtocol) { rule.add_expr(&nft_expr!(meta l4proto)); rule.add_expr(&nft_expr!(cmp == l4proto(protocol))); } @@ -543,7 +543,7 @@ fn l4proto(protocol: TransportProtocol) -> u8 { } } -fn add_verdict(rule: &mut Rule, verdict: &expr::Verdict) { +fn add_verdict(rule: &mut Rule<'_>, verdict: &expr::Verdict) { if *ADD_COUNTERS { rule.add_expr(&nft_expr!(counter)); } diff --git a/talpid-core/src/firewall/mod.rs b/talpid-core/src/firewall/mod.rs index af29d0739c..40aaf52040 100644 --- a/talpid-core/src/firewall/mod.rs +++ b/talpid-core/src/firewall/mod.rs @@ -80,7 +80,7 @@ pub enum FirewallPolicy { } impl fmt::Display for FirewallPolicy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { FirewallPolicy::Connecting { peer_endpoint, diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs index a636a22466..1b75276561 100644 --- a/talpid-core/src/lib.rs +++ b/talpid-core/src/lib.rs @@ -1,4 +1,5 @@ #![deny(missing_docs)] +#![deny(rust_2018_idioms)] //! The core components of the talpidaemon VPN client. //! diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs index 3cc5e31938..50c0c61206 100644 --- a/talpid-core/src/process/openvpn.rs +++ b/talpid-core/src/process/openvpn.rs @@ -335,7 +335,7 @@ impl OpenVpnCommand { impl fmt::Display for OpenVpnCommand { /// Format the program and arguments of an `OpenVpnCommand` for display. Any non-utf8 data /// is lossily converted using the utf8 replacement character. - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.write_str(&shell_escape::escape(self.openvpn_bin.to_string_lossy()))?; for arg in &self.get_arguments() { fmt.write_str(" ")?; diff --git a/talpid-core/src/proxy/mod.rs b/talpid-core/src/proxy/mod.rs index dac4e63cd2..f16c84da5f 100644 --- a/talpid-core/src/proxy/mod.rs +++ b/talpid-core/src/proxy/mod.rs @@ -22,8 +22,8 @@ pub trait ProxyMonitor: Send { fn port(&self) -> u16; } -impl fmt::Debug for ProxyMonitor { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl fmt::Debug for dyn ProxyMonitor { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ProxyMonitor {{ port: {} }}", self.port()) } } diff --git a/talpid-core/src/proxy/shadowsocks.rs b/talpid-core/src/proxy/shadowsocks.rs index 3b6e312bd2..91da5e3b59 100644 --- a/talpid-core/src/proxy/shadowsocks.rs +++ b/talpid-core/src/proxy/shadowsocks.rs @@ -99,7 +99,7 @@ impl ShadowsocksCommand { } impl fmt::Display for ShadowsocksCommand { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.write_str(&shell_escape::escape( self.shadowsocks_bin.to_string_lossy(), ))?; diff --git a/talpid-core/src/tunnel/wireguard/mod.rs b/talpid-core/src/tunnel/wireguard/mod.rs index f183cc36e0..d1c0c451d9 100644 --- a/talpid-core/src/tunnel/wireguard/mod.rs +++ b/talpid-core/src/tunnel/wireguard/mod.rs @@ -53,7 +53,7 @@ pub struct WireguardMonitor { /// Route manager router: routing::RouteManager, /// Callback to signal tunnel events - event_callback: Box<Fn(TunnelEvent) + Send + Sync + 'static>, + event_callback: Box<dyn Fn(TunnelEvent) + Send + Sync + 'static>, close_msg_sender: mpsc::Sender<CloseMsg>, close_msg_receiver: mpsc::Receiver<CloseMsg>, } |
