Skip to content

Commit 04431a3

Browse files
authored
style: fix some random clippy lints (#749)
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 <[email protected]>
1 parent f7a8ee9 commit 04431a3

File tree

12 files changed

+14
-16
lines changed

12 files changed

+14
-16
lines changed

linkerd/addr/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![deny(warnings, rust_2018_idioms)]
22

3-
use http;
43
use linkerd2_dns_name::Name;
54
use std::{
65
fmt,

linkerd/app/core/src/control.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Config {
6161
.push(tls::ConnectLayer::new(identity))
6262
.push_timeout(self.connect.timeout)
6363
.push(self::client::layer())
64-
.push(reconnect::layer(backoff.clone()))
64+
.push(reconnect::layer(backoff))
6565
.push(self::resolve::layer(dns, backoff))
6666
.push_on_response(self::control::balance::layer())
6767
.into_new_service()

linkerd/app/inbound/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl Config {
210210
connect.h2_settings,
211211
))
212212
.push(reconnect::layer({
213-
let backoff = connect.backoff.clone();
213+
let backoff = connect.backoff;
214214
move |_| Ok(backoff.stream())
215215
}))
216216
.check_new_service::<HttpEndpoint, http::Request<_>>();

linkerd/app/integration/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl tower::Service<hyper::Uri> for Conn {
278278

279279
fn call(&mut self, _: hyper::Uri) -> Self::Future {
280280
let tls = self.tls.clone();
281-
let conn = TcpStream::connect(self.addr.clone());
281+
let conn = TcpStream::connect(self.addr);
282282
let abs_form = self.absolute_uris;
283283
let running = self
284284
.running

linkerd/app/integration/src/proxy.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ impl Proxy {
8282
}
8383

8484
pub fn inbound(mut self, s: server::Listening) -> Self {
85-
let addr = s.addr.clone();
86-
self.inbound = Some(addr);
85+
self.inbound = Some(s.addr);
8786
self.inbound_server = Some(s);
8887
self
8988
}
@@ -107,8 +106,7 @@ impl Proxy {
107106
}
108107

109108
pub fn outbound(mut self, s: server::Listening) -> Self {
110-
let addr = s.addr.clone();
111-
self.outbound = Some(addr);
109+
self.outbound = Some(s.addr);
112110
self.outbound_server = Some(s);
113111
self
114112
}

linkerd/app/outbound/src/http/endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444
.push(http::client::layer(config.h1_settings, config.h2_settings))
4545
// Re-establishes a connection when the client fails.
4646
.push(reconnect::layer({
47-
let backoff = config.backoff.clone();
47+
let backoff = config.backoff;
4848
move |e: Error| {
4949
if tcp::connect::is_loop(&*e) {
5050
Err(e)

linkerd/app/profiling/src/bin/profile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ async fn main() {
2424
.next()
2525
.expect("PROFILING_SUPPORT_SERVER resolved to no addrs!");
2626

27-
let srv = server::mock_listening(addr.clone());
28-
let srv2 = server::mock_listening(addr.clone());
27+
let srv = server::mock_listening(addr);
28+
let srv2 = server::mock_listening(addr);
2929

3030
let ctrl = controller::new();
3131
let transparency_tx = ctrl.destination_tx("transparency.test.svc.cluster.local");

linkerd/dns/name/src/name.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub struct InvalidName;
1212

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

1819
pub fn without_trailing_dot(&self) -> &str {

linkerd/exp-backoff/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub struct InvalidBackoff(&'static str);
4343
impl ExponentialBackoff {
4444
pub fn stream(&self) -> ExponentialBackoffStream {
4545
ExponentialBackoffStream {
46-
backoff: self.clone(),
46+
backoff: *self,
4747
rng: SmallRng::from_entropy(),
4848
iterations: 0,
4949
delay: None,

linkerd/proxy/http/src/h2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<C: Clone, B> Clone for Connect<C, B> {
5252
fn clone(&self) -> Self {
5353
Connect {
5454
connect: self.connect.clone(),
55-
h2_settings: self.h2_settings.clone(),
55+
h2_settings: self.h2_settings,
5656
_marker: PhantomData,
5757
}
5858
}

0 commit comments

Comments
 (0)