Skip to content

Commit 38d9aed

Browse files
committed
Eliminate needless compiler directives (#1371)
We've accrued various compiler directives and clippy exceptions that are no longer necesary. This change removes these unnecessary settings. This change also addresses a lint in our integration tests. (cherry picked from commit 611b8ed) Signed-off-by: Oliver Gould <ver@buoyant.io>
1 parent 7799c1a commit 38d9aed

File tree

13 files changed

+42
-33
lines changed

13 files changed

+42
-33
lines changed

linkerd/app/integration/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
33
#![deny(warnings, rust_2018_idioms)]
44
#![forbid(unsafe_code)]
5-
#![recursion_limit = "256"]
6-
#![type_length_limit = "16289823"]
7-
// It's not clear where this originates.
8-
#![allow(clippy::eval_order_dependence)]
95

106
mod test_env;
117

linkerd/app/integration/src/tests/transparency.rs

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// It's not clear where this originates.
2-
#![allow(clippy::redundant_closure_call)]
3-
41
use crate::*;
52
use std::error::Error as _;
63
use tokio::sync::mpsc;
@@ -345,7 +342,8 @@ macro_rules! http1_tests {
345342
let _trace = trace_init();
346343

347344
let srv = server::http1().route("/", "hello h1").run().await;
348-
let proxy = ($proxy)(srv).await;
345+
let mk = $proxy;
346+
let proxy = mk(srv).await;
349347
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
350348

351349
assert_eq!(client.get("/").await, "hello h1");
@@ -371,7 +369,8 @@ macro_rules! http1_tests {
371369
})
372370
.run()
373371
.await;
374-
let proxy = ($proxy)(srv).await;
372+
let mk = $proxy;
373+
let proxy = mk(srv).await;
375374
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
376375

377376
let res = client
@@ -415,7 +414,8 @@ macro_rules! http1_tests {
415414
})
416415
.run()
417416
.await;
418-
let proxy = ($proxy)(srv).await;
417+
let mk = $proxy;
418+
let proxy = mk(srv).await;
419419
let client = client::http1(proxy.inbound, host);
420420

421421
let res = client
@@ -450,7 +450,8 @@ macro_rules! http1_tests {
450450
})
451451
.run()
452452
.await;
453-
let proxy = ($proxy)(srv).await;
453+
let mk = $proxy;
454+
let proxy = mk(srv).await;
454455
let client = client::http1_absolute_uris(proxy.inbound, auth);
455456

456457
let res = client
@@ -520,7 +521,8 @@ macro_rules! http1_tests {
520521
})
521522
.run()
522523
.await;
523-
let proxy = ($proxy)(srv).await;
524+
let mk = $proxy;
525+
let proxy = mk(srv).await;
524526

525527
let client = client::tcp(proxy.inbound);
526528

@@ -561,7 +563,8 @@ macro_rules! http1_tests {
561563
})
562564
.run()
563565
.await;
564-
let proxy = ($proxy)(srv).await;
566+
let mk = $proxy;
567+
let proxy = mk(srv).await;
565568

566569
let host = "transparency.test.svc.cluster.local";
567570
let client = client::http1(proxy.inbound, host);
@@ -597,7 +600,8 @@ macro_rules! http1_tests {
597600
})
598601
.run()
599602
.await;
600-
let proxy = ($proxy)(srv).await;
603+
let mk = $proxy;
604+
let proxy = mk(srv).await;
601605

602606
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
603607

@@ -673,7 +677,8 @@ macro_rules! http1_tests {
673677
})
674678
.run()
675679
.await;
676-
let proxy = ($proxy)(srv).await;
680+
let mk = $proxy;
681+
let proxy = mk(srv).await;
677682

678683
let client = client::tcp(proxy.inbound);
679684

@@ -712,7 +717,8 @@ macro_rules! http1_tests {
712717
})
713718
.run()
714719
.await;
715-
let proxy = ($proxy)(srv).await;
720+
let mk = $proxy;
721+
let proxy = mk(srv).await;
716722

717723
// A TCP client is used since the HTTP client would stop these requests
718724
// from ever touching the network.
@@ -781,7 +787,8 @@ macro_rules! http1_tests {
781787
})
782788
.run()
783789
.await;
784-
let proxy = ($proxy)(srv).await;
790+
let mk = $proxy;
791+
let proxy = mk(srv).await;
785792
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
786793

787794
let req = client
@@ -816,7 +823,8 @@ macro_rules! http1_tests {
816823
})
817824
.run()
818825
.await;
819-
let proxy = ($proxy)(srv).await;
826+
let mk = $proxy;
827+
let proxy = mk(srv).await;
820828
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
821829

822830
let req = client
@@ -854,7 +862,8 @@ macro_rules! http1_tests {
854862
})
855863
.run()
856864
.await;
857-
let proxy = ($proxy)(srv).await;
865+
let mk = $proxy;
866+
let proxy = mk(srv).await;
858867
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
859868

860869
let methods = &["GET", "POST", "PUT", "DELETE", "HEAD", "PATCH"];
@@ -891,7 +900,8 @@ macro_rules! http1_tests {
891900
})
892901
.run()
893902
.await;
894-
let proxy = ($proxy)(srv).await;
903+
let mk = $proxy;
904+
let proxy = mk(srv).await;
895905
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
896906

897907
let methods = &["GET", "POST", "PUT", "DELETE", "HEAD", "PATCH"];
@@ -935,7 +945,8 @@ macro_rules! http1_tests {
935945
})
936946
.run()
937947
.await;
938-
let proxy = ($proxy)(srv).await;
948+
let mk = $proxy;
949+
let proxy = mk(srv).await;
939950
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
940951

941952
// https://tools.ietf.org/html/rfc7230#section-3.3.3
@@ -998,7 +1009,8 @@ macro_rules! http1_tests {
9981009
})
9991010
.run()
10001011
.await;
1001-
let proxy = ($proxy)(srv).await;
1012+
let mk = $proxy;
1013+
let proxy = mk(srv).await;
10021014
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
10031015

10041016
let resp = client
@@ -1039,7 +1051,8 @@ macro_rules! http1_tests {
10391051
})
10401052
.run()
10411053
.await;
1042-
let proxy = ($proxy)(srv).await;
1054+
let mk = $proxy;
1055+
let proxy = mk(srv).await;
10431056

10441057
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");
10451058

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ mod test {
317317

318318
/// Helper server that reads the l5d-orig-proto header on requests and uses it to set the header
319319
/// value in `WAS_ORIG_PROTO`.
320-
#[allow(clippy::unnecessary_wraps)]
321320
fn serve(version: ::http::Version) -> io::Result<io::BoxedIo> {
322321
let svc = hyper::service::service_fn(move |req: http::Request<_>| {
323322
tracing::debug!(?req);

linkerd/app/outbound/src/tcp/connect.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ impl<S> PreventLoopback<S> {
118118
#[cfg(feature = "allow-loopback")]
119119
// the Result is necessary to have the same type signature regardless of
120120
// whether or not the `allow-loopback` feature is enabled...
121-
#[allow(clippy::unnecessary_wraps)]
122121
fn check_loopback(_: Remote<ServerAddr>) -> io::Result<()> {
123122
Ok(())
124123
}

linkerd/duplex/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! This module uses unsafe code to implement [`BufMut`].
44
5-
#![deny(warnings, rust_2018_idioms)]
5+
#![deny(warnings, rust_2018_idioms, unsafe_code)]
66

77
use bytes::{Buf, BufMut};
88
use futures::ready;
@@ -315,6 +315,7 @@ impl Buf for CopyBuf {
315315
}
316316
}
317317

318+
#[allow(unsafe_code)]
318319
unsafe impl BufMut for CopyBuf {
319320
fn remaining_mut(&self) -> usize {
320321
self.buf.len() - self.write_pos

linkerd/http-retry/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
#![forbid(unsafe_code)]
3-
#![allow(clippy::type_complexity)]
43

54
use bytes::{Buf, BufMut, Bytes, BytesMut};
65
use http::HeaderMap;

linkerd/proxy/api-resolve/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
#![forbid(unsafe_code)]
3-
#![recursion_limit = "512"]
43

54
use linkerd2_proxy_api as api;
65
use linkerd_addr::NameAddr;

linkerd/proxy/transport/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
//!
33
//! Uses unsafe code to interact with socket options for SO_ORIGINAL_DST.
44
5-
#![deny(warnings, rust_2018_idioms)]
6-
// #![forbid(unsafe_code)]
5+
#![deny(warnings, rust_2018_idioms, unsafe_code)]
76

87
pub mod addrs;
98
mod connect;

linkerd/proxy/transport/src/orig_dst.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ where
7777
}
7878

7979
#[cfg(target_os = "linux")]
80+
#[allow(unsafe_code)]
8081
fn orig_dst_addr(sock: &TcpStream) -> io::Result<OrigDstAddr> {
8182
use std::os::unix::io::AsRawFd;
8283

@@ -94,6 +95,7 @@ fn orig_dst_addr(_: &TcpStream) -> io::Result<OrigDstAddr> {
9495
}
9596

9697
#[cfg(target_os = "linux")]
98+
#[allow(unsafe_code)]
9799
mod linux {
98100
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
99101
use std::os::unix::io::RawFd;

linkerd/system/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Unsafe code for accessing system-level counters for memory & CPU usage.
22
3-
#![deny(warnings, rust_2018_idioms)]
3+
#![deny(warnings, rust_2018_idioms, unsafe_code)]
44

55
#[cfg(target_os = "linux")]
66
mod linux;

0 commit comments

Comments
 (0)