Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate needless compiler directives #1371

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions linkerd/app/integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

#![deny(warnings, rust_2018_idioms)]
#![forbid(unsafe_code)]
#![recursion_limit = "256"]
#![type_length_limit = "16289823"]
// It's not clear where this originates.
#![allow(clippy::eval_order_dependence)]

mod test_env;

Expand Down
51 changes: 32 additions & 19 deletions linkerd/app/integration/src/tests/transparency.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// It's not clear where this originates.
#![allow(clippy::redundant_closure_call)]

use crate::*;
use std::error::Error as _;
use tokio::sync::mpsc;
Expand Down Expand Up @@ -345,7 +342,8 @@ macro_rules! http1_tests {
let _trace = trace_init();

let srv = server::http1().route("/", "hello h1").run().await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

assert_eq!(client.get("/").await, "hello h1");
Expand All @@ -371,7 +369,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

let res = client
Expand Down Expand Up @@ -415,7 +414,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, host);

let res = client
Expand Down Expand Up @@ -450,7 +450,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1_absolute_uris(proxy.inbound, auth);

let res = client
Expand Down Expand Up @@ -520,7 +521,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;

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

Expand Down Expand Up @@ -561,7 +563,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;

let host = "transparency.test.svc.cluster.local";
let client = client::http1(proxy.inbound, host);
Expand Down Expand Up @@ -597,7 +600,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;

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

Expand Down Expand Up @@ -673,7 +677,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;

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

Expand Down Expand Up @@ -712,7 +717,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;

// A TCP client is used since the HTTP client would stop these requests
// from ever touching the network.
Expand Down Expand Up @@ -781,7 +787,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

let req = client
Expand Down Expand Up @@ -816,7 +823,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

let req = client
Expand Down Expand Up @@ -854,7 +862,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

let methods = &["GET", "POST", "PUT", "DELETE", "HEAD", "PATCH"];
Expand Down Expand Up @@ -891,7 +900,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

let methods = &["GET", "POST", "PUT", "DELETE", "HEAD", "PATCH"];
Expand Down Expand Up @@ -935,7 +945,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

// https://tools.ietf.org/html/rfc7230#section-3.3.3
Expand Down Expand Up @@ -998,7 +1009,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;
let client = client::http1(proxy.inbound, "transparency.test.svc.cluster.local");

let resp = client
Expand Down Expand Up @@ -1039,7 +1051,8 @@ macro_rules! http1_tests {
})
.run()
.await;
let proxy = ($proxy)(srv).await;
let mk = $proxy;
let proxy = mk(srv).await;

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

Expand Down
1 change: 0 additions & 1 deletion linkerd/app/outbound/src/http/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ mod test {

/// Helper server that reads the l5d-orig-proto header on requests and uses it to set the header
/// value in `WAS_ORIG_PROTO`.
#[allow(clippy::unnecessary_wraps)]
fn serve(version: ::http::Version) -> io::Result<io::BoxedIo> {
let svc = hyper::service::service_fn(move |req: http::Request<_>| {
tracing::debug!(?req);
Expand Down
1 change: 0 additions & 1 deletion linkerd/app/outbound/src/tcp/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl<S> PreventLoopback<S> {
#[cfg(feature = "allow-loopback")]
// the Result is necessary to have the same type signature regardless of
// whether or not the `allow-loopback` feature is enabled...
#[allow(clippy::unnecessary_wraps)]
fn check_loopback(_: Remote<ServerAddr>) -> io::Result<()> {
Ok(())
}
Expand Down
3 changes: 2 additions & 1 deletion linkerd/duplex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! This module uses unsafe code to implement [`BufMut`].

#![deny(warnings, rust_2018_idioms)]
#![deny(warnings, rust_2018_idioms, unsafe_code)]

use bytes::{Buf, BufMut};
use futures::ready;
Expand Down Expand Up @@ -315,6 +315,7 @@ impl Buf for CopyBuf {
}
}

#[allow(unsafe_code)]
unsafe impl BufMut for CopyBuf {
fn remaining_mut(&self) -> usize {
self.buf.len() - self.write_pos
Expand Down
1 change: 0 additions & 1 deletion linkerd/http-retry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(warnings, rust_2018_idioms)]
#![forbid(unsafe_code)]
#![allow(clippy::type_complexity)]

use bytes::{Buf, BufMut, Bytes, BytesMut};
use http::HeaderMap;
Expand Down
1 change: 0 additions & 1 deletion linkerd/proxy/api-resolve/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(warnings, rust_2018_idioms)]
#![forbid(unsafe_code)]
#![recursion_limit = "512"]

use linkerd2_proxy_api as api;
use linkerd_addr::NameAddr;
Expand Down
3 changes: 1 addition & 2 deletions linkerd/proxy/transport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
//!
//! Uses unsafe code to interact with socket options for SO_ORIGINAL_DST.

#![deny(warnings, rust_2018_idioms)]
// #![forbid(unsafe_code)]
#![deny(warnings, rust_2018_idioms, unsafe_code)]

pub mod addrs;
mod connect;
Expand Down
2 changes: 2 additions & 0 deletions linkerd/proxy/transport/src/orig_dst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ where
}

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

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

#[cfg(target_os = "linux")]
#[allow(unsafe_code)]
mod linux {
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use std::os::unix::io::RawFd;
Expand Down
2 changes: 1 addition & 1 deletion linkerd/system/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Unsafe code for accessing system-level counters for memory & CPU usage.

#![deny(warnings, rust_2018_idioms)]
#![deny(warnings, rust_2018_idioms, unsafe_code)]

#[cfg(target_os = "linux")]
mod linux;
Expand Down
1 change: 1 addition & 0 deletions linkerd/system/src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn max_fds() -> io::Result<Option<u64>> {
Ok(max_fds)
}

#[allow(unsafe_code)]
fn sysconf(num: libc::c_int, name: &'static str) -> Result<u64, io::Error> {
match unsafe { libc::sysconf(num) } {
e if e <= 0 => {
Expand Down
1 change: 0 additions & 1 deletion linkerd2-proxy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#![deny(warnings, rust_2018_idioms)]
#![forbid(unsafe_code)]
#![type_length_limit = "16289823"]

// Emit a compile-time error if no TLS implementations are enabled. When adding
// new implementations, add their feature flags here!
Expand Down
4 changes: 3 additions & 1 deletion opencensus-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#![deny(warnings, rust_2018_idioms)]
#![forbid(unsafe_code)]
#![allow(clippy::inconsistent_struct_constructor, rustdoc::bare_urls)]

pub mod agent {
pub mod trace {
Expand All @@ -15,6 +14,7 @@ pub mod agent {
));
}
}

pub mod common {
pub mod v1 {
include!(concat!(
Expand All @@ -24,11 +24,13 @@ pub mod agent {
}
}
}

pub mod trace {
pub mod v1 {
include!(concat!(env!("OUT_DIR"), "/opencensus.proto.trace.v1.rs"));
}
}

pub mod resource {
pub mod v1 {
include!(concat!(env!("OUT_DIR"), "/opencensus.proto.resource.v1.rs"));
Expand Down