Skip to content

Commit

Permalink
style: fix some random clippy lints (#749)
Browse files Browse the repository at this point in the history
This commit fixes a few clippy lints, primarily the use of `.clone()` on
types which implement `Copy`. I stumbled across this while trying to use
clippy to find instances of passing references to `SocketAddr`s instead
of copying them, which is inefficient...but it turns out that we don't
actually do that anywhere...

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw authored Nov 18, 2020
1 parent f7a8ee9 commit 04431a3
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 16 deletions.
1 change: 0 additions & 1 deletion linkerd/addr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(warnings, rust_2018_idioms)]

use http;
use linkerd2_dns_name::Name;
use std::{
fmt,
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/core/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Config {
.push(tls::ConnectLayer::new(identity))
.push_timeout(self.connect.timeout)
.push(self::client::layer())
.push(reconnect::layer(backoff.clone()))
.push(reconnect::layer(backoff))
.push(self::resolve::layer(dns, backoff))
.push_on_response(self::control::balance::layer())
.into_new_service()
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/inbound/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl Config {
connect.h2_settings,
))
.push(reconnect::layer({
let backoff = connect.backoff.clone();
let backoff = connect.backoff;
move |_| Ok(backoff.stream())
}))
.check_new_service::<HttpEndpoint, http::Request<_>>();
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/integration/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl tower::Service<hyper::Uri> for Conn {

fn call(&mut self, _: hyper::Uri) -> Self::Future {
let tls = self.tls.clone();
let conn = TcpStream::connect(self.addr.clone());
let conn = TcpStream::connect(self.addr);
let abs_form = self.absolute_uris;
let running = self
.running
Expand Down
6 changes: 2 additions & 4 deletions linkerd/app/integration/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ impl Proxy {
}

pub fn inbound(mut self, s: server::Listening) -> Self {
let addr = s.addr.clone();
self.inbound = Some(addr);
self.inbound = Some(s.addr);
self.inbound_server = Some(s);
self
}
Expand All @@ -107,8 +106,7 @@ impl Proxy {
}

pub fn outbound(mut self, s: server::Listening) -> Self {
let addr = s.addr.clone();
self.outbound = Some(addr);
self.outbound = Some(s.addr);
self.outbound_server = Some(s);
self
}
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/src/http/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ where
.push(http::client::layer(config.h1_settings, config.h2_settings))
// Re-establishes a connection when the client fails.
.push(reconnect::layer({
let backoff = config.backoff.clone();
let backoff = config.backoff;
move |e: Error| {
if tcp::connect::is_loop(&*e) {
Err(e)
Expand Down
4 changes: 2 additions & 2 deletions linkerd/app/profiling/src/bin/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async fn main() {
.next()
.expect("PROFILING_SUPPORT_SERVER resolved to no addrs!");

let srv = server::mock_listening(addr.clone());
let srv2 = server::mock_listening(addr.clone());
let srv = server::mock_listening(addr);
let srv2 = server::mock_listening(addr);

let ctrl = controller::new();
let transparency_tx = ctrl.destination_tx("transparency.test.svc.cluster.local");
Expand Down
3 changes: 2 additions & 1 deletion linkerd/dns/name/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub struct InvalidName;

impl Name {
pub fn is_localhost(&self) -> bool {
*self == Name::try_from("localhost.".as_bytes()).unwrap()
use std::str::FromStr;
*self == Name::from_str("localhost.").unwrap()
}

pub fn without_trailing_dot(&self) -> &str {
Expand Down
2 changes: 1 addition & 1 deletion linkerd/exp-backoff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct InvalidBackoff(&'static str);
impl ExponentialBackoff {
pub fn stream(&self) -> ExponentialBackoffStream {
ExponentialBackoffStream {
backoff: self.clone(),
backoff: *self,
rng: SmallRng::from_entropy(),
iterations: 0,
delay: None,
Expand Down
2 changes: 1 addition & 1 deletion linkerd/proxy/http/src/h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<C: Clone, B> Clone for Connect<C, B> {
fn clone(&self) -> Self {
Connect {
connect: self.connect.clone(),
h2_settings: self.h2_settings.clone(),
h2_settings: self.h2_settings,
_marker: PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion linkerd/proxy/transport/src/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ mod mock {

impl OrigDstAddr for MockOrigDstAddr {
fn orig_dst_addr(&self, _: &TcpStream) -> Option<SocketAddr> {
Some(self.0.clone())
Some(self.0)
}
}
}
2 changes: 1 addition & 1 deletion linkerd/timeout/src/failfast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ where
// triggering failfast.
Self {
inner: self.inner.clone(),
max_unavailable: self.max_unavailable.clone(),
max_unavailable: self.max_unavailable,
state: State::Open,
}
}
Expand Down

0 comments on commit 04431a3

Please sign in to comment.