Skip to content

Commit

Permalink
chore: update pinned rust version, clippy lints, remove some dead code (
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel authored Sep 6, 2024
1 parent c752aff commit d567760
Show file tree
Hide file tree
Showing 130 changed files with 810 additions and 261 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[build]
rustflags = [
"-Zproc-macro-backtrace",
"-Wunused_qualifications",
"-Wclippy::upper_case_acronyms",
# Flag to make build.rs scripts generate docs. Should only be used in this repository
# internally, not by dependants.
'--cfg=HYDROFLOW_GENERATE_DOCS',
Expand Down
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ debug-assertions = false

[profile.release.package.website_playground]
opt-level = "s"

[workspace.lints.rust]
unused_qualifications = "warn"

[workspace.lints.clippy]
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
explicit_into_iter_loop = "warn"
let_and_return = "allow"
upper_case_acronyms = "warn"
3 changes: 3 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ version = "0.0.0"
edition = "2021"
license = "Apache-2.0"

[lints]
workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion benches/benches/fork_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn benchmark_hydroflow(c: &mut Criterion) {
send1,
send2,
|_ctx, recv, send1, send2| {
for v in recv.take_inner().into_iter() {
for v in recv.take_inner() {
if v % 2 == 0 {
send1.give(Some(v));
} else {
Expand Down
1 change: 0 additions & 1 deletion benches/benches/micro_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ fn ops(c: &mut Criterion) {
let dist = Uniform::new(0, 100);
let input0: Vec<usize> = (0..NUM_INTS).map(|_| dist.sample(&mut rng)).collect();

#[allow(clippy::unnecessary_fold)]
{
hydroflow_syntax! {
source_iter(black_box(input0)) -> fold::<'tick>(|| 0, |accum: &mut _, elem| { *accum += elem }) -> for_each(|x| { black_box(x); });
Expand Down
1 change: 0 additions & 1 deletion benches/benches/reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ fn benchmark_hydroflow(c: &mut Criterion) {
});
}

#[allow(clippy::map_clone)]
fn benchmark_hydroflow_surface_cheating(c: &mut Criterion) {
c.bench_function("reachability/hydroflow/surface_cheating", |b| {
b.iter_batched(
Expand Down
4 changes: 4 additions & 0 deletions hydro_deploy/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "Apache-2.0"
documentation = "https://docs.rs/hydro_deploy/"
description = "Hydro Deploy"

[lints]
workspace = true

[dependencies]
anyhow = { version = "1.0.82", features = [ "backtrace" ] }
async-process = "2.0.0"
Expand Down Expand Up @@ -34,3 +37,4 @@ tempfile = "3.0.0"
tokio = { version = "1.29.0", features = [ "full" ] }
tokio-stream = { version = "0.1.3", default-features = false }
tokio-util = { version = "0.7.5", features = [ "compat", "io-util" ] }

6 changes: 2 additions & 4 deletions hydro_deploy/core/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ impl Deployment {
ret
}

#[allow(non_snake_case)]
#[expect(non_snake_case, reason = "constructor-esque")]
pub fn Localhost(&self) -> Arc<LocalhostHost> {
self.localhost_host.clone().unwrap()
}

#[allow(non_snake_case)]
#[expect(non_snake_case, reason = "constructor-esque")]
pub fn CustomService(
&mut self,
on: Arc<dyn Host>,
Expand Down Expand Up @@ -201,7 +201,6 @@ impl Deployment {
/// Buildstructor methods.
#[buildstructor::buildstructor]
impl Deployment {
#[allow(clippy::too_many_arguments)]
#[builder(entry = "GcpComputeEngineHost", exit = "add")]
pub fn add_gcp_compute_engine_host(
&mut self,
Expand All @@ -227,7 +226,6 @@ impl Deployment {
})
}

#[allow(clippy::too_many_arguments)]
#[builder(entry = "AzureHost", exit = "add")]
pub fn add_azure_host(
&mut self,
Expand Down
5 changes: 4 additions & 1 deletion hydro_deploy/core/src/gcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ pub struct GcpComputeEngineHost {
}

impl GcpComputeEngineHost {
#[allow(clippy::too_many_arguments)] // TODO(mingwei)
#[expect(
clippy::too_many_arguments,
reason = "internal code called by builder elsewhere"
)]
pub fn new(
id: usize,
project: impl Into<String>,
Expand Down
2 changes: 1 addition & 1 deletion hydro_deploy/core/src/hydroflow_crate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct BuildParams {
}
impl BuildParams {
/// Creates a new `BuildParams` and canonicalizes the `src` path.
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments, reason = "internal code")]
pub fn new(
src: impl AsRef<Path>,
bin: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion hydro_deploy/core/src/hydroflow_crate/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct HydroflowCrateService {
}

impl HydroflowCrateService {
#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments, reason = "internal code")]
pub fn new(
id: usize,
src: PathBuf,
Expand Down
2 changes: 0 additions & 2 deletions hydro_deploy/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::let_and_return)]

use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion hydro_deploy/core/src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ impl<T: LaunchedSshHost> LaunchedHost for T {
let port = addr.port();

tokio::spawn(async move {
#[allow(clippy::never_loop)]
#[expect(clippy::never_loop, reason = "tcp accept loop pattern")]
while let Ok((mut local_stream, _)) = local_port.accept().await {
let mut channel = session
.channel_direct_tcpip(&internal_ip, port, None)
Expand Down
3 changes: 3 additions & 0 deletions hydro_deploy/hydro_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "Apache-2.0"
documentation = "https://docs.rs/hydro_cli/"
description = "Hydro Deploy Command Line Interface"

[lints]
workspace = true

[lib]
name = "hydro_cli"
# "cdylib" is necessary to produce a shared library for Python to import from.
Expand Down
21 changes: 12 additions & 9 deletions hydro_deploy/hydro_cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// TODO(mingwei): For pyo3 generated code.
#![allow(unused_qualifications, non_local_definitions)]
#![expect(
unused_qualifications,
non_local_definitions,
reason = "for pyo3 generated code"
)]

use core::hydroflow_crate::ports::HydroflowSource;
use std::cell::OnceCell;
Expand Down Expand Up @@ -159,7 +162,7 @@ impl Deployment {
}
}

#[allow(non_snake_case)]
#[expect(non_snake_case, reason = "pymethods")]
fn Localhost(&self, py: Python<'_>) -> PyResult<Py<PyAny>> {
let arc = self.underlying.blocking_read().Localhost();

Expand All @@ -173,7 +176,7 @@ impl Deployment {
.into_py(py))
}

#[allow(non_snake_case, clippy::too_many_arguments)]
#[expect(non_snake_case, clippy::too_many_arguments, reason = "pymethods")]
fn GcpComputeEngineHost(
&self,
py: Python<'_>,
Expand Down Expand Up @@ -208,7 +211,7 @@ impl Deployment {
.into_py(py))
}

#[allow(non_snake_case, clippy::too_many_arguments)]
#[expect(non_snake_case, clippy::too_many_arguments, reason = "pymethods")]
fn AzureHost(
&self,
py: Python<'_>,
Expand All @@ -233,7 +236,7 @@ impl Deployment {
.into_py(py))
}

#[allow(non_snake_case)]
#[expect(non_snake_case, reason = "pymethods")]
fn CustomService(
&self,
py: Python<'_>,
Expand All @@ -257,7 +260,7 @@ impl Deployment {
.into_py(py))
}

#[allow(non_snake_case, clippy::too_many_arguments)]
#[expect(non_snake_case, clippy::too_many_arguments, reason = "pymethods")]
fn HydroflowCrate(
&self,
py: Python<'_>,
Expand Down Expand Up @@ -725,7 +728,7 @@ impl ServerPort {
pythonize(py, &self.underlying).unwrap()
}

#[allow(clippy::wrong_self_convention)]
#[expect(clippy::wrong_self_convention, reason = "pymethods")]
fn into_source<'p>(&self, py: Python<'p>) -> PyResult<&'p PyAny> {
let realized = with_tokio_runtime(|| ServerOrBound::Server((&self.underlying).into()));

Expand All @@ -738,7 +741,7 @@ impl ServerPort {
})
}

#[allow(clippy::wrong_self_convention)]
#[expect(clippy::wrong_self_convention, reason = "pymethods")]
fn into_sink<'p>(&self, py: Python<'p>) -> PyResult<&'p PyAny> {
let realized = with_tokio_runtime(|| ServerOrBound::Server((&self.underlying).into()));

Expand Down
3 changes: 3 additions & 0 deletions hydro_deploy/hydro_cli_examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ publish = false
version = "0.0.0"
edition = "2021"

[lints]
workspace = true

[[example]]
name = "empty_program"

Expand Down
3 changes: 3 additions & 0 deletions hydro_deploy/hydroflow_deploy_integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "Apache-2.0"
documentation = "https://docs.rs/hydroflow_deploy_integration/"
description = "`hydro_deploy` integration for Hydroflow"

[lints]
workspace = true

[dependencies]
async-recursion = "1.0.0"
async-trait = "0.1.54"
Expand Down
8 changes: 3 additions & 5 deletions hydro_deploy/hydroflow_deploy_integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ use tokio_util::codec::{Framed, LengthDelimitedCodec};
pub type InitConfig = (HashMap<String, ServerBindConfig>, Option<String>);

#[cfg(not(unix))]
#[allow(dead_code)]
type UnixStream = ();
type UnixStream = std::convert::Infallible;

#[cfg(not(unix))]
#[allow(dead_code)]
type UnixListener = ();
#[expect(dead_code, reason = "conditional compilation placeholder")]
type UnixListener = std::convert::Infallible;

/// Describes how to connect to a service which is listening on some port.
#[allow(unreachable_code)]
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum ServerPort {
UnixSocket(PathBuf),
Expand Down
3 changes: 3 additions & 0 deletions hydro_deploy/hydroflow_plus_deploy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "Apache-2.0"
documentation = "https://docs.rs/hydroflow_plus_deploy/"
description = "Library for working with hydro_deploy and hydroflow_plus"

[lints]
workspace = true

[features]
deploy = [ "hydro_deploy", "trybuild-internals-api", "toml", "prettyplease" ]
stageleft_devel = []
Expand Down
6 changes: 3 additions & 3 deletions hydro_deploy/hydroflow_plus_deploy/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl<'a> Deploy<'a> for HydroDeploy {
pub trait DeployCrateWrapper {
fn underlying(&self) -> Arc<RwLock<HydroflowCrateService>>;

#[allow(async_fn_in_trait)]
#[expect(async_fn_in_trait, reason = "no auto trait bounds needed")]
async fn create_sender(
&self,
port: &str,
Expand All @@ -246,12 +246,12 @@ pub trait DeployCrateWrapper {
sender_port
}

#[allow(async_fn_in_trait)]
#[expect(async_fn_in_trait, reason = "no auto trait bounds needed")]
async fn stdout(&self) -> tokio::sync::mpsc::UnboundedReceiver<String> {
self.underlying().read().await.stdout()
}

#[allow(async_fn_in_trait)]
#[expect(async_fn_in_trait, reason = "no auto trait bounds needed")]
async fn stderr(&self) -> tokio::sync::mpsc::UnboundedReceiver<String> {
self.underlying().read().await.stderr()
}
Expand Down
2 changes: 1 addition & 1 deletion hydro_deploy/hydroflow_plus_deploy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) mod trybuild;

pub use runtime::*;

#[allow(unused)]
#[allow(clippy::allow_attributes, unused, reason = "stageleft")]
pub(crate) mod deploy_runtime;

#[cfg(feature = "deploy")]
Expand Down
3 changes: 3 additions & 0 deletions hydroflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ license = "Apache-2.0"
documentation = "https://docs.rs/hydroflow/"
description = "Hydro's low-level dataflow runtime and IR"

[lints]
workspace = true

[features]
default = [ "macros", "nightly", "debugging" ]

Expand Down
2 changes: 1 addition & 1 deletion hydroflow/examples/deadlock_detector/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) async fn run_detector(opts: Opts, peer_list: Vec<String>) {
let reader = tokio::io::BufReader::new(tokio::io::stdin());
let stdin_lines = LinesStream::new(reader.lines());

#[allow(clippy::map_identity)]
#[expect(clippy::map_identity, reason = "helps type inference?")]
let mut hf: Hydroflow = hydroflow_syntax! {
// fetch peers from file, convert ip:port to a SocketAddr, and tee
peers = source_iter(peer_list)
Expand Down
2 changes: 1 addition & 1 deletion hydroflow/examples/example_syntax_empty.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused_mut, unused_variables)]
#![expect(unused_mut, unused_variables, reason = "example code")]

use hydroflow::hydroflow_syntax;

Expand Down
2 changes: 1 addition & 1 deletion hydroflow/examples/kvs_bench/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum KvsResponse<const SIZE: usize> {
_PutResponse {
key: u64,
},
#[allow(dead_code)]
#[expect(dead_code, reason = "benchmark discards responses")]
GetResponse {
key: u64,
reg: MyLastWriteWins<SIZE>,
Expand Down
2 changes: 1 addition & 1 deletion hydroflow/examples/three_clique/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn main() {
// An edge in the input data = a pair of `usize` vertex IDs.
let (edges_send, edges_recv) = hydroflow::util::unbounded_channel::<(usize, usize)>();

#[allow(clippy::map_identity)]
#[expect(clippy::map_identity, reason = "code symmetry")]
let mut df = hydroflow_syntax! {
edges = source_stream(edges_recv) -> tee();

Expand Down
2 changes: 1 addition & 1 deletion hydroflow/src/compiled/pull/cross_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
self.state.draw_from_left = !self.state.draw_from_left;

// try to fetch from the specified side
#[allow(clippy::collapsible_else_if)]
#[expect(clippy::collapsible_else_if, reason = "code symmetry")]
if self.state.draw_from_left {
if let Some(l) = self.lhs.next() {
self.state.draw_from_left = true;
Expand Down
2 changes: 1 addition & 1 deletion hydroflow/src/compiled/pull/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Pull-based operator helpers, i.e. [`Iterator`] helpers.
#![allow(missing_docs)] // TODO(mingwei)
#![allow(missing_docs, reason = "// TODO(mingwei)")]

mod cross_join;
pub use cross_join::*;
Expand Down
5 changes: 0 additions & 5 deletions hydroflow/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#![cfg_attr(feature = "nightly", feature(never_type))]
#![allow(type_alias_bounds)]
#![allow(clippy::let_and_return)]
#![allow(clippy::iter_with_drain)]
#![allow(clippy::explicit_auto_deref)]
#![warn(missing_docs)]

//! Hydroflow is a low-level dataflow-based runtime system for the [Hydro Project](https://hydro.run/).
Expand All @@ -22,7 +18,6 @@
//! For more examples, check out the [`examples` folder on Github](https://github.com/hydro-project/hydroflow/tree/main/hydroflow/examples).
pub mod compiled;
pub mod props;
pub mod scheduled;
pub mod util;

Expand Down
Loading

0 comments on commit d567760

Please sign in to comment.