Skip to content

Commit

Permalink
chore: fix lint, format errors for latest nightly version (without up…
Browse files Browse the repository at this point in the history
…dated pinned) (#822)

For nightly version (d9c13cd45 2023-07-05)
  • Loading branch information
MingweiSamuel authored Jul 7, 2023
1 parent 8710022 commit f60053f
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 32 deletions.
6 changes: 1 addition & 5 deletions benches/benches/fork_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ fn benchmark_hydroflow(c: &mut Criterion) {
send1,
send2,
|_ctx, recv1, recv2, send1, send2| {
for v in recv1
.take_inner()
.into_iter()
.chain(recv2.take_inner().into_iter())
{
for v in recv1.take_inner().into_iter().chain(recv2.take_inner()) {
if v % 2 == 0 {
send1.give(Some(v));
} else {
Expand Down
2 changes: 1 addition & 1 deletion hydroflow/examples/shopping/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub(crate) async fn run_driver(opts: Opts) {
let addr1 = ipv4_resolve("localhost:23430").unwrap();
let addr2 = ipv4_resolve("localhost:23431").unwrap();
let addr3 = ipv4_resolve("localhost:23432").unwrap();
let server_addrs = vec![addr1, addr2, addr3];
let server_addrs = [addr1, addr2, addr3];

// define the server addresses for gossip
let gossip_addr1 = ipv4_resolve("localhost:23440").unwrap();
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 @@ -36,7 +36,7 @@ pub fn main() {

// post-process: sort fields of each tuple by node ID
triangle -> map(|(x, y, z)| {
let mut v = vec![x, y, z];
let mut v = [x, y, z];
v.sort();
(v[0], v[1], v[2])
}) -> for_each(|e| println!("three_clique found: {:?}", e));
Expand Down
2 changes: 1 addition & 1 deletion hydroflow/src/scheduled/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Hydroflow {

// TODO(mingwei): queue may grow unbounded? Subtle rate matching concern.
// TODO(mingwei): put into state system.
message_queue.extend(recv.take_inner().into_iter());
message_queue.extend(recv.take_inner());
while !message_queue.is_empty() {
if let std::task::Poll::Ready(Ok(())) = Pin::new(&mut writer).poll_ready(&mut cx) {
let v = message_queue.pop_front().unwrap();
Expand Down
7 changes: 2 additions & 5 deletions hydroflow/src/scheduled/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ pub struct StateHandle<T> {
pub(crate) state_id: StateId,
pub(crate) _phantom: PhantomData<*mut T>,
}
impl<T> Copy for StateHandle<T> {}
impl<T> Clone for StateHandle<T> {
fn clone(&self) -> Self {
Self {
state_id: self.state_id,
_phantom: PhantomData,
}
*self
}
}
impl<T> Copy for StateHandle<T> {}
2 changes: 1 addition & 1 deletion hydroflow/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn test_cycle() {
union_rhs,
union_out,
|_ctx, recv1, recv2, send| {
for v in (recv1.take_inner().into_iter()).chain(recv2.take_inner().into_iter()) {
for v in (recv1.take_inner().into_iter()).chain(recv2.take_inner()) {
send.give(Some(v));
}
},
Expand Down
39 changes: 31 additions & 8 deletions hydroflow_lang/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ fn generate_op_docs() -> Result<()> {
.map_err(|syn_err| Error::new(ErrorKind::InvalidData, syn_err))?;

for item in op_parsed.items {
let Item::Const(item_const) = item else { continue; };
let Expr::Struct(expr_struct) = *item_const.expr else { continue; };
let Item::Const(item_const) = item else {
continue;
};
let Expr::Struct(expr_struct) = *item_const.expr else {
continue;
};
if identity::<Path>(parse_quote!(OperatorConstraints)) != expr_struct.path {
continue;
}
Expand All @@ -44,7 +48,11 @@ fn generate_op_docs() -> Result<()> {
.iter()
.find(|&field_value| identity::<Member>(parse_quote!(name)) == field_value.member)
.expect("Expected `name` field not found.");
let Expr::Lit(ExprLit { lit: Lit::Str(op_name), .. }) = &name_field.expr else {
let Expr::Lit(ExprLit {
lit: Lit::Str(op_name),
..
}) = &name_field.expr
else {
panic!("Unexpected non-literal or non-str `name` field value.")
};
let op_name = op_name.value();
Expand All @@ -60,11 +68,26 @@ fn generate_op_docs() -> Result<()> {

let mut in_hf_doctest = false;
for attr in item_const.attrs.iter() {
let AttrStyle::Outer = attr.style else { continue; };
let Meta::NameValue(MetaNameValue { path, eq_token: _, value }) = &attr.meta else { continue; };
let Some("doc") = path.get_ident().map(Ident::to_string).as_deref() else { continue; };
let Expr::Lit(ExprLit { attrs: _, lit }) = value else { continue; };
let Lit::Str(doc_lit_str) = lit else { continue; };
let AttrStyle::Outer = attr.style else {
continue;
};
let Meta::NameValue(MetaNameValue {
path,
eq_token: _,
value,
}) = &attr.meta
else {
continue;
};
let Some("doc") = path.get_ident().map(Ident::to_string).as_deref() else {
continue;
};
let Expr::Lit(ExprLit { attrs: _, lit }) = value else {
continue;
};
let Lit::Str(doc_lit_str) = lit else {
continue;
};
// At this point we know we have a `#[doc = "..."]`.
let doc_str = doc_lit_str.value();
let doc_str = doc_str.strip_prefix(' ').unwrap_or(&*doc_str);
Expand Down
8 changes: 6 additions & 2 deletions hydroflow_lang/src/graph/di_mul_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@ where
/// Returns `None` if `vertex` is not in the graph or does not have the right degree in/out.
pub fn remove_intermediate_vertex(&mut self, vertex: V) -> Option<(E, (E, E))> {
let preds = self.preds.remove(vertex)?;
let &[pred_edge] = &*preds else { return None; };
let &[pred_edge] = &*preds else {
return None;
};
let succs = self.succs.remove(vertex).unwrap();
let &[succ_edge] = &*succs else { return None; };
let &[succ_edge] = &*succs else {
return None;
};

let (src, _v) = self.edges.remove(pred_edge).unwrap();
let (_v, dst) = self.edges.remove(succ_edge).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion hydroflow_lang/src/graph/flat_graph_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ impl FlatGraphBuilder {
for (node_id, node) in self.flat_graph.nodes() {
match node {
Node::Operator(operator) => {
let Some(op_constraints) = find_op_op_constraints(operator) else { continue };
let Some(op_constraints) = find_op_op_constraints(operator) else {
continue;
};
// Check number of args
if op_constraints.num_args != operator.args.len() {
self.diagnostics.push(Diagnostic::spanned(
Expand Down
12 changes: 9 additions & 3 deletions hydroflow_lang/src/graph/hydroflow_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,12 @@ impl HydroflowGraph {

// Make corresponding operator instance (if `node` is an operator).
let op_inst_opt = 'oc: {
let Node::Operator(operator) = &new_node else { break 'oc None; };
let Some(op_constraints) = find_op_op_constraints(operator) else { break 'oc None; };
let Node::Operator(operator) = &new_node else {
break 'oc None;
};
let Some(op_constraints) = find_op_op_constraints(operator) else {
break 'oc None;
};
let (input_port, output_port) = self.ports.get(edge_id).cloned().unwrap();
let generics = get_operator_generics(
&mut Vec::new(), // TODO(mingwei) diagnostics
Expand Down Expand Up @@ -998,7 +1002,9 @@ impl HydroflowGraph {
let mut sg_varname_nodes =
SparseSecondaryMap::<GraphSubgraphId, BTreeMap<Varname, BTreeSet<GraphNodeId>>>::new();
for (node_id, varname) in self.node_varnames.iter() {
let Some(sg_id) = self.node_subgraph(node_id) else { continue; };
let Some(sg_id) = self.node_subgraph(node_id) else {
continue;
};
let varname_map = sg_varname_nodes.entry(sg_id).unwrap().or_default();
varname_map
.entry(varname.clone())
Expand Down
2 changes: 1 addition & 1 deletion hydroflow_lang/src/graph/ops/demux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn extract_closure_idents(arg2: &Pat) -> HashMap<Ident, usize> {
match tt {
TokenTree::Group(group) => {
let a = stack.len();
stack.extend(group.stream().into_iter());
stack.extend(group.stream());
let b = stack.len();
stack[a..b].reverse();
}
Expand Down
2 changes: 1 addition & 1 deletion lattices/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ where
changed = true;
}
// Merge intersecting indices.
for (self_val, other_val) in self.seq.iter_mut().zip(other.seq.into_iter()) {
for (self_val, other_val) in self.seq.iter_mut().zip(other.seq) {
changed |= self_val.merge(other_val);
}
changed
Expand Down
4 changes: 3 additions & 1 deletion multiplatform_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ fn multiplatform_test_impl(
output.extend(body);
} else {
let mut body_head = body.into_iter().collect::<Vec<_>>();
let Some(proc_macro2::TokenTree::Group(body_code)) = body_head.pop() else { panic!(); };
let Some(proc_macro2::TokenTree::Group(body_code)) = body_head.pop() else {
panic!();
};

output.extend(body_head);
output.extend(quote! {
Expand Down
2 changes: 1 addition & 1 deletion pusherator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mod tests {
let mut right = Vec::new();

let pivot = Pivot::new(
a.into_iter().chain(b.into_iter()),
a.into_iter().chain(b),
Partition::new(
|x| x % 2 == 0,
ForEach::new(|x| left.push(x)),
Expand Down

0 comments on commit f60053f

Please sign in to comment.