Skip to content

Commit

Permalink
refactor: enable lints, cleanups for Rust 2024 hydro-project#1732
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Feb 22, 2025
1 parent 1ba4505 commit 6cc3022
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 36 deletions.
17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ opt-level = "s"
unused_qualifications = "warn"
unsafe_op_in_unsafe_fn = "warn"

# Lints for upgrading to the 2024 edition
boxed_slice_into_iter = "warn"
dependency_on_unit_never_type_fallback = "warn"
deprecated_safe_2024 = "warn"
edition_2024_expr_fragment_specifier = "allow" # ALLOW
if_let_rescope = "allow" # ALLOW
impl_trait_overcaptures = "warn"
keyword_idents_2024 = "warn"
missing_unsafe_on_extern = "warn"
never_type_fallback_flowing_into_unsafe = "warn"
rust_2024_guarded_string_incompatible_syntax = "warn"
rust_2024_incompatible_pat = "warn"
rust_2024_prelude_collisions = "warn"
static_mut_refs = "warn"
tail_expr_drop_order = "allow" # ALLOW
unsafe_attr_outside_unsafe = "warn"

[workspace.lints.clippy]
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
Expand Down
10 changes: 6 additions & 4 deletions dfir_lang/src/graph/ops/cross_singleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ pub const CROSS_SINGLETON: OperatorConstraints = OperatorConstraints {
let write_iterator = quote_spanned! {op_span=>
let #ident = {
#[inline(always)]
fn cross_singleton_guard<Singleton, Item>(
fn cross_singleton_guard<Singleton, Item, SingletonIter, Stream>(
mut singleton_state_mut: std::cell::RefMut<'_, Option<Singleton>>,
mut singleton_input: impl Iterator<Item = Singleton>,
stream_input: impl Iterator<Item = Item>,
) -> impl Iterator<Item = (Item, Singleton)>
mut singleton_input: SingletonIter,
stream_input: Stream,
) -> impl use<Item, Singleton, Stream, /*TODO: https://github.com/rust-lang/rust/issues/130043 */ SingletonIter> + Iterator<Item = (Item, Singleton)>
where
Singleton: ::std::clone::Clone,
SingletonIter: Iterator<Item = Singleton>,
Stream: Iterator<Item = Item>,
{
let singleton_value_opt = match &*singleton_state_mut {
::std::option::Option::Some(singleton_value) => Some(singleton_value.clone()),
Expand Down
4 changes: 2 additions & 2 deletions dfir_lang/src/graph/ops/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub const ZIP: OperatorConstraints = OperatorConstraints {
let #ident = {
// TODO(mingwei): performance issue - get_mut_default and std::mem::take reset the vecs, reallocs heap.
let mut zipbuf_borrow = #context.state_ref(#zipbuf_ident).borrow_mut();
let (ref mut lhs_buf, ref mut rhs_buf) = zipbuf_borrow.get_mut_default(#context.current_tick());
let (lhs_buf, rhs_buf) = zipbuf_borrow.get_mut_default(#context.current_tick());
#root::itertools::Itertools::zip_longest(
::std::mem::take(lhs_buf).into_iter().chain(#lhs),
::std::mem::take(rhs_buf).into_iter().chain(#rhs),
Expand All @@ -97,7 +97,7 @@ pub const ZIP: OperatorConstraints = OperatorConstraints {
Some((lhs, rhs))
} else {
let mut zipbuf_burrow = #context.state_ref(#zipbuf_ident).borrow_mut();
let (ref mut lhs_buf, ref mut rhs_buf) = zipbuf_burrow.get_mut_default(#context.current_tick());
let (lhs_buf, rhs_buf) = zipbuf_burrow.get_mut_default(#context.current_tick());
match either {
#root::itertools::EitherOrBoth::Left(lhs) => lhs_buf.push(lhs),
#root::itertools::EitherOrBoth::Right(rhs) => rhs_buf.push(rhs),
Expand Down
2 changes: 1 addition & 1 deletion dfir_rs/src/util/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl ProcessBuilderContext<'_> {
pub fn new_outbox<T: 'static>(
&mut self,
interface: InterfaceName,
) -> impl Sink<(T, Address), Error = Infallible> {
) -> impl use<T> + Sink<(T, Address), Error = Infallible> {
let (sender, receiver) = unbounded_channel::<(T, Address)>();

let receiver = receiver.map(|(msg, addr)| (Box::new(msg) as Box<dyn Any>, addr));
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 @@ -177,7 +177,7 @@ impl HydroflowCrateService {
self.launched_binary.as_ref().unwrap().exit_code()
}

fn build(&self) -> impl Future<Output = Result<&'static BuildOutput, BuildError>> {
fn build(&self) -> impl use<> + 'static + Future<Output = Result<&'static BuildOutput, BuildError>> {
// Memoized, so no caching in `self` is needed.
build_crate_memoized(self.build_params.clone())
}
Expand Down
4 changes: 4 additions & 0 deletions hydro_deploy/hydroflow_deploy_integration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ impl ConnectedSource for ConnectedDirect {
type Stream = DynStream;

fn into_source(mut self) -> DynStream {
#[allow(if_let_rescope)]
if let Some(s) = self.stream_sink.take() {
Box::pin(s)
} else {
Expand All @@ -466,6 +467,7 @@ impl ConnectedSink for ConnectedDirect {
type Sink = DynSink<Bytes>;

fn into_sink(mut self) -> DynSink<Self::Input> {
#[allow(if_let_rescope)]
if let Some(s) = self.stream_sink.take() {
Box::pin(s)
} else {
Expand Down Expand Up @@ -700,6 +702,7 @@ where
Connection::AsClient(ClientConnection::Merge(m)) => {
let mut sources = Vec::new();
for port in m {
#[allow(if_let_rescope)]
if let ClientConnection::Tagged(pipe, id) = port {
sources.push((
Box::pin(
Expand Down Expand Up @@ -731,6 +734,7 @@ where
Connection::AsServer(BoundServer::Merge(m)) => {
let mut sources = Vec::new();
for port in m {
#[allow(if_let_rescope)]
if let BoundServer::Tagged(pipe, id) = port {
sources.push((
Box::pin(
Expand Down
50 changes: 25 additions & 25 deletions hydro_lang/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,16 @@ impl HydroLeaf {
match self {
HydroLeaf::ForEach {
f: _,
ref mut input,
input,
}
| HydroLeaf::DestSink {
sink: _,
ref mut input,
input,
}
| HydroLeaf::CycleSink {
ident: _,
location_kind: _,
ref mut input,
input,
} => {
transform(input, seen_tees);
}
Expand Down Expand Up @@ -277,7 +277,7 @@ impl HydroLeaf {
Some(&stream_id.to_string()),
);
}
BuildersOrCallback::Callback(ref mut leaf_callback, _) => {
BuildersOrCallback::Callback(leaf_callback, _) => {
leaf_callback(self, stream_id);
}
}
Expand All @@ -303,7 +303,7 @@ impl HydroLeaf {
Some(&stream_id.to_string()),
);
}
BuildersOrCallback::Callback(ref mut leaf_callback, _) => {
BuildersOrCallback::Callback(leaf_callback, _) => {
leaf_callback(self, stream_id);
}
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ impl<'a> HydroNode {
Some(&persist_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, persist_id);
}
}
Expand Down Expand Up @@ -1064,7 +1064,7 @@ impl<'a> HydroNode {
Some(&delta_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, delta_id);
}
}
Expand Down Expand Up @@ -1122,7 +1122,7 @@ impl<'a> HydroNode {
let builder = graph_builders.entry(location_id).or_default();
builder.add_dfir(source_stmt, None, Some(&source_id.to_string()));
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, source_id);
}
}
Expand Down Expand Up @@ -1179,7 +1179,7 @@ impl<'a> HydroNode {
Some(&tee_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, tee_id);
}
}
Expand Down Expand Up @@ -1218,7 +1218,7 @@ impl<'a> HydroNode {
Some(&chain_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, chain_id);
}
}
Expand Down Expand Up @@ -1256,7 +1256,7 @@ impl<'a> HydroNode {
Some(&cross_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, cross_id);
}
}
Expand Down Expand Up @@ -1320,7 +1320,7 @@ impl<'a> HydroNode {
Some(&stream_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, stream_id);
}
}
Expand Down Expand Up @@ -1377,7 +1377,7 @@ impl<'a> HydroNode {
Some(&stream_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, stream_id);
}
}
Expand Down Expand Up @@ -1405,7 +1405,7 @@ impl<'a> HydroNode {
Some(&map_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, map_id);
}
}
Expand Down Expand Up @@ -1434,7 +1434,7 @@ impl<'a> HydroNode {
Some(&flat_map_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, flat_map_id);
}
}
Expand Down Expand Up @@ -1463,7 +1463,7 @@ impl<'a> HydroNode {
Some(&filter_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, filter_id);
}
}
Expand Down Expand Up @@ -1492,7 +1492,7 @@ impl<'a> HydroNode {
Some(&filter_map_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, filter_map_id);
}
}
Expand Down Expand Up @@ -1520,7 +1520,7 @@ impl<'a> HydroNode {
Some(&sort_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, sort_id);
}
}
Expand Down Expand Up @@ -1549,7 +1549,7 @@ impl<'a> HydroNode {
Some(&defer_tick_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, defer_tick_id);
}
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ impl<'a> HydroNode {
Some(&enumerate_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, enumerate_id);
}
}
Expand Down Expand Up @@ -1614,7 +1614,7 @@ impl<'a> HydroNode {
Some(&inspect_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, inspect_id);
}
}
Expand Down Expand Up @@ -1643,7 +1643,7 @@ impl<'a> HydroNode {
Some(&unique_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, unique_id);
}
}
Expand Down Expand Up @@ -1694,7 +1694,7 @@ impl<'a> HydroNode {
Some(&fold_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, fold_id);
}
}
Expand Down Expand Up @@ -1742,7 +1742,7 @@ impl<'a> HydroNode {
Some(&reduce_id.to_string()),
);
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, reduce_id);
}
}
Expand Down Expand Up @@ -1822,7 +1822,7 @@ impl<'a> HydroNode {
);
}
}
BuildersOrCallback::Callback(_, ref mut node_callback) => {
BuildersOrCallback::Callback(_, node_callback) => {
node_callback(self, stream_id);
}
}
Expand Down
2 changes: 1 addition & 1 deletion stageleft_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub fn entry(
runtime_data_params.push(quote! {
#pat: #runtime_tpe
});
runtime_data_locals.push(quote!(##pat));
runtime_data_locals.push(quote!(# #pat));

out.push(quote_spanned! {input.span()=>
let #pat: &#root::internal::syn::Expr = &input_parsed[#i];
Expand Down
5 changes: 3 additions & 2 deletions variadics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::any::Any;

use sealed::sealed;

#[allow(edition_2024_expr_fragment_specifier)]
#[doc = include_str!("../var_expr.md")]
#[macro_export]
macro_rules! var_expr {
Expand Down Expand Up @@ -498,7 +499,7 @@ where
Rest: CopyRefVariadic,
{
fn copy_var(&self) -> Self::UnRefVar {
let var_args!(&item, ...rest) = self;
let &var_args!(&item, ...ref rest) = self;
var_expr!(item, ...rest.copy_var())
}
}
Expand All @@ -509,7 +510,7 @@ where
Rest: CopyRefVariadic,
{
fn copy_var(&self) -> Self::UnRefVar {
let var_args!(&mut item, ...rest) = self;
let &var_args!(&mut item, ...ref rest) = self;
var_expr!(item, ...rest.copy_var())
}
}
Expand Down

0 comments on commit 6cc3022

Please sign in to comment.