Skip to content

Commit e9f2dd8

Browse files
committed
refactor: cleanup and changes to satisfy Clippy
Signed-off-by: Richard Zak <[email protected]>
1 parent 9da9bd7 commit e9f2dd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+606
-760
lines changed

.github/workflows/rust.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ env:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
16-
1715
steps:
1816
- uses: actions/checkout@v3
1917
- name: UpdateRust
@@ -22,3 +20,12 @@ jobs:
2220
run: rustup -V && cargo build --verbose
2321
# - name: Run tests
2422
# run: cargo test --verbose
23+
24+
clippy:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: UpdateRust
29+
run: rustup update stable
30+
- name: Clippy
31+
run: cargo clippy --workspace --all-features -- -D warnings

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ custom_derive = "0.1.7"
4444
glob = "0.3.0"
4545
thread_local = "1.1.4"
4646
tokio = { version = "1.35.1", features = ["full"] , optional = true}
47+
tracing = "0.1"
4748
libc = { version = "0.2.137", optional = true }
4849
async-global-executor = "2.4.1"
4950
envy = "0.4.2"
@@ -58,7 +59,6 @@ hostname = "0.3"
5859
nix = "0.23"
5960
assert_cmd = "2.0.4"
6061
serial_test = "0.6.0"
61-
tracing-subscriber = "0.3"
6262
#packed_simd = { version = "0.3.4", package = "packed_simd_2" } #uncomment if using nightly tool chain and want to run the am_flops example
6363

6464
[workspace]

impl/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ quote = "1.0.21"
2222
syn = { version = "2.0.17", features = ["full","extra-traits","fold","visit-mut",] }
2323
async-trait = "0.1.58"
2424
futures = "0.3.25"
25+
26+
[dev-dependencies]
27+
lamellar = "0.7"

impl/src/am_data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use quote::{quote, ToTokens};
99
use syn::parse_macro_input;
1010
use syn::punctuated::Punctuated;
1111

12-
fn check_attrs(attrs: &Vec<syn::Attribute>) -> (bool, bool, Vec<syn::Attribute>) {
12+
fn check_attrs(attrs: &[syn::Attribute]) -> (bool, bool, Vec<syn::Attribute>) {
1313
let mut static_field = false;
1414
let attrs = attrs
1515
.iter()
@@ -167,7 +167,7 @@ fn process_fields(
167167
}
168168
} else if !t.contains("serde::Serialize")
169169
&& !t.contains("serde::Deserialize")
170-
&& t.trim().len() > 0
170+
&& !t.trim().is_empty()
171171
{
172172
let temp = quote::format_ident!("{}", t.trim());
173173
trait_strs
@@ -262,7 +262,7 @@ pub(crate) fn derive_am_data(
262262
&traits,
263263
&attrs,
264264
&vis,
265-
&name,
265+
name,
266266
&full_fields,
267267
&full_ser,
268268
&full_des,
@@ -276,7 +276,7 @@ pub(crate) fn derive_am_data(
276276
&group_traits,
277277
&group_attrs,
278278
&vis,
279-
&name,
279+
name,
280280
&fields,
281281
&static_fields,
282282
&lamellar,

impl/src/array_ops.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::type_complexity)]
2+
13
use proc_macro::TokenStream;
24
// use proc_macro_error::abort;
35
use proc_macro2::Ident;
@@ -255,7 +257,7 @@ fn gen_array_names(
255257
) -> (Ident, Ident, Ident, Ident, Ident, Ident, Ident, Ident) {
256258
let base = quote::format_ident!(
257259
"{array_type}_{}_{val_type}_val_{idx_type}_idx",
258-
type_to_string(&typeident)
260+
type_to_string(typeident)
259261
);
260262

261263
let am_buf_name = quote::format_ident!("{base}_am_buf");
@@ -552,16 +554,11 @@ fn create_buf_ops(
552554
quote! {}, //no lock since its native atomic
553555
quote! { #slice },
554556
)
555-
} else if array_type == "LocalLockArray" {
557+
} else if array_type == "LocalLockArray" || array_type == "GlobalLockArray" {
556558
(
557559
quote! {}, //no explicit lock since the slice handle is a lock guard
558560
quote! {let mut slice = self.data.write_local_data().await; }, //this is the lock
559561
)
560-
} else if array_type == "GlobalLockArray" {
561-
(
562-
quote! {}, //no explicit lock since the slice handle is a lock guard
563-
quote! {let mut slice = self.data.write_local_data().await;}, //this is the lock
564-
)
565562
} else if array_type == "ReadOnlyArray" {
566563
(
567564
quote! {}, //no explicit lock since the slice handle is a lock guard
@@ -1533,10 +1530,10 @@ pub(crate) fn __generate_ops_for_type_rt(item: TokenStream) -> TokenStream {
15331530
}
15341531
val.value
15351532
} else {
1536-
panic! ("third argument of generate_ops_for_type expects 'true' or 'false' specifying whether types implement eq");
1533+
panic!("third argument of generate_ops_for_type expects 'true' or 'false' specifying whether types implement eq");
15371534
};
15381535
for t in items[3..].iter() {
1539-
let the_type = syn::parse_str::<syn::Type>(&t).unwrap();
1536+
let the_type = syn::parse_str::<syn::Type>(t).unwrap();
15401537
let typeident = quote::format_ident!("{:}", t.trim());
15411538
output.extend(quote! {
15421539
impl Dist for #typeident {}

impl/src/field_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl FieldInfo {
2424
ser.extend(self.ser_path(field, *darc_iter, false));
2525
}
2626
syn::Type::Tuple(ty) => {
27-
ser.extend(self.ser_tuple(field, &ty, false));
27+
ser.extend(self.ser_tuple(field, ty, false));
2828
}
2929
_ => {
3030
abort!(
@@ -46,7 +46,7 @@ impl FieldInfo {
4646
ser.extend(self.ser_path(field, *darc_iter, true));
4747
}
4848
syn::Type::Tuple(ty) => {
49-
ser.extend(self.ser_tuple(field, &ty, true));
49+
ser.extend(self.ser_tuple(field, ty, true));
5050
}
5151
_ => {
5252
abort!(
@@ -131,7 +131,7 @@ impl FieldInfo {
131131
des.extend(self.des_path(field, *darc_iter, false));
132132
}
133133
syn::Type::Tuple(ty) => {
134-
des.extend(self.des_tuple(field, &ty, false));
134+
des.extend(self.des_tuple(field, ty, false));
135135
}
136136
_ => {
137137
abort!(
@@ -153,7 +153,7 @@ impl FieldInfo {
153153
des.extend(self.des_path(field, *darc_iter, true));
154154
}
155155
syn::Type::Tuple(ty) => {
156-
des.extend(self.des_tuple(field, &ty, true));
156+
des.extend(self.des_tuple(field, ty, true));
157157
}
158158
_ => {
159159
abort!(

impl/src/gen_am.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ pub(crate) fn impl_lamellar_serde_trait(
6969
quote! {
7070
impl #impl_generics #lamellar::active_messaging::LamellarSerde for #am_name #ty_generics #where_clause {
7171
fn serialized_size(&self)->usize{
72-
#lamellar::serialized_size(self,true)
72+
#lamellar::serialized_size(self)
7373
}
7474
fn serialize_into(&self,buf: &mut [u8]){
75-
#lamellar::serialize_into(buf,self,true).expect("can serialize and enough space in buf");
75+
#lamellar::serialize_into(buf,self).expect("can serialize and enough space in buf");
7676
}
7777
fn serialize(&self)->Vec<u8>{
78-
#lamellar::serialize(self,true).expect("can serialize")
78+
#lamellar::serialize(self).expect("can serialize")
7979
}
8080
}
8181
}
@@ -90,13 +90,13 @@ fn impl_return_lamellar_serde_trait(
9090
quote! {
9191
impl #impl_generics #lamellar::active_messaging::LamellarSerde for #am_name #ty_generics #where_clause {
9292
fn serialized_size(&self)->usize{
93-
#lamellar::serialized_size(&self.val,true)
93+
#lamellar::serialized_size(&self.val)
9494
}
9595
fn serialize_into(&self,buf: &mut [u8]){
96-
#lamellar::serialize_into(buf,&self.val,true).expect("can serialize and enough space in buf");
96+
#lamellar::serialize_into(buf,&self.val).expect("can serialize and enough space in buf");
9797
}
9898
fn serialize(&self)->Vec<u8>{
99-
#lamellar::serialize(self,true).expect("can serialize")
99+
#lamellar::serialize(self).expect("can serialize")
100100
}
101101
}
102102
}
@@ -113,11 +113,11 @@ pub(crate) fn impl_lamellar_result_serde_trait(
113113
impl #impl_generics #lamellar::active_messaging::LamellarResultSerde for #am_name #ty_generics #where_clause {
114114
fn serialized_result_size(&self,result: & Box<dyn std::any::Any + Sync + Send>)->usize{
115115
let result = result.downcast_ref::<#ret_type>().expect("can downcast result box");
116-
#lamellar::serialized_size(result,true)
116+
#lamellar::serialized_size(result)
117117
}
118118
fn serialize_result_into(&self,buf: &mut [u8],result: & Box<dyn std::any::Any + Sync + Send>){
119119
let result = result.downcast_ref::<#ret_type>().expect("can downcast result box");
120-
#lamellar::serialize_into(buf,result,true).expect("can serialize and enough size in buf");
120+
#lamellar::serialize_into(buf,result).expect("can serialize and enough size in buf");
121121
}
122122
}
123123
}
@@ -157,7 +157,7 @@ fn impl_unpack_and_register_function(
157157
let am_name_unpack = quote::format_ident!("{}_unpack", am_name.clone());
158158
quote! {
159159
fn #am_name_unpack #impl_generics (bytes: &[u8], cur_pe: Result<usize,#lamellar::IdError>) -> std::sync::Arc<dyn #lamellar::active_messaging::RemoteActiveMessage + Sync + Send> {
160-
let __lamellar_data: std::sync::Arc<#am_name #ty_generics> = std::sync::Arc::new(#lamellar::deserialize(&bytes,true).expect("can deserialize into remote active message"));
160+
let __lamellar_data: std::sync::Arc<#am_name #ty_generics> = std::sync::Arc::new(#lamellar::deserialize(&bytes).expect("can deserialize into remote active message"));
161161
<#am_name #ty_generics as #lamellar::active_messaging::DarcSerde>::des(&__lamellar_data,cur_pe);
162162
__lamellar_data
163163
}
@@ -252,7 +252,7 @@ fn gen_am_body(
252252
let mut stmts = exec_fn.stmts;
253253

254254
let (ret_statement, bytes_buf) = if let Some(stmt) = stmts.pop() {
255-
gen_return_stmt(am_type, &stmt, &ret_struct_name, &lamellar, local)
255+
gen_return_stmt(am_type, &stmt, ret_struct_name, lamellar, local)
256256
} else {
257257
(
258258
quote! {#lamellar::active_messaging::LamellarReturn::Unit},
@@ -283,7 +283,7 @@ fn gen_return_stmt(
283283
#lamellar::active_messaging::LamellarReturn::Unit
284284
},
285285
AmType::ReturnData(ref ret) => {
286-
let last_expr = get_expr(&last_stmt)
286+
let last_expr = get_expr(last_stmt)
287287
.expect("failed to get exec return value (try removing the last \";\")");
288288
let last_expr =
289289
quote_spanned! {last_stmt.span()=> let __lamellar_last_expr: #ret = #last_expr; };
@@ -318,7 +318,7 @@ fn gen_return_stmt(
318318
}
319319
}
320320
AmType::ReturnAm(ret, _) => {
321-
let last_expr = get_expr(&last_stmt)
321+
let last_expr = get_expr(last_stmt)
322322
.expect("failed to get exec return value (try removing the last \";\")");
323323
let last_expr =
324324
quote_spanned! {last_stmt.span()=> let __lamellar_last_expr: #ret = #last_expr; };
@@ -406,7 +406,7 @@ pub(crate) fn generate_am(
406406

407407
let generics = input.generics.clone();
408408

409-
let (am_body, bytes_buf) = gen_am_body(&input, &am_type, &return_struct_name, &lamellar, local);
409+
let (am_body, bytes_buf) = gen_am_body(input, &am_type, &return_struct_name, lamellar, local);
410410

411411
let (return_type, return_struct) = {
412412
match am_type {
@@ -415,10 +415,10 @@ pub(crate) fn generate_am(
415415
let return_type = quote! {#output};
416416
let return_struct = impl_return_struct(
417417
&generics,
418-
&am_data_header,
418+
am_data_header,
419419
&return_struct_name,
420420
&return_type,
421-
&lamellar,
421+
lamellar,
422422
bytes_buf,
423423
local,
424424
);
@@ -429,10 +429,10 @@ pub(crate) fn generate_am(
429429
};
430430

431431
let lamellar_active_message =
432-
impl_lamellar_active_message_trait(&generics, &orig_name, &am_body, &lamellar);
433-
let local_am = impl_local_am_trait(&generics, &orig_name, &return_type, &lamellar);
432+
impl_lamellar_active_message_trait(&generics, &orig_name, &am_body, lamellar);
433+
let local_am = impl_local_am_trait(&generics, &orig_name, &return_type, lamellar);
434434
let remote_trait_impls =
435-
impl_remote_traits(&generics, &orig_name, &return_type, &lamellar, local);
435+
impl_remote_traits(&generics, &orig_name, &return_type, lamellar, local);
436436

437437
let expanded = quote_spanned! {am_body.span()=>
438438
#lamellar_active_message
@@ -467,6 +467,7 @@ pub(crate) fn generate_am(
467467
}
468468
}
469469

470+
#[allow(clippy::too_many_arguments)]
470471
pub(crate) fn create_am_struct(
471472
generics: &syn::Generics,
472473
attributes: &proc_macro2::TokenStream,

impl/src/gen_am_group.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ fn gen_am_group_return_stmt(
184184
}
185185
}
186186

187+
#[allow(clippy::too_many_arguments)]
187188
fn impl_am_group_remote(
188189
generics: &syn::Generics,
189190
am_group_am_name: &syn::Ident,
@@ -440,7 +441,7 @@ pub(crate) fn generate_am_group(
440441
}
441442
};
442443

443-
let am_group_remote_body = gen_am_group_remote_body2(&orig_name, &input);
444+
let am_group_remote_body = gen_am_group_remote_body2(&orig_name, input);
444445

445446
let (ret_contatiner, ret_push, ret_stmt) =
446447
gen_am_group_return_stmt(&am_type, &am_group_return_name, lamellar, false);
@@ -453,15 +454,15 @@ pub(crate) fn generate_am_group(
453454
&ret_contatiner,
454455
&ret_push,
455456
&ret_stmt,
456-
&lamellar,
457+
lamellar,
457458
);
458459

459460
let am_group_return = impl_return_struct(
460461
&generics,
461-
&am_data_header,
462+
am_data_header,
462463
&am_group_return_name,
463464
&ret_type,
464-
&lamellar,
465+
lamellar,
465466
false,
466467
local,
467468
);
@@ -473,7 +474,7 @@ pub(crate) fn generate_am_group(
473474
&am_group_am_name,
474475
&am_group_user_name,
475476
&inner_ret_type,
476-
&lamellar,
477+
lamellar,
477478
);
478479

479480
let mut am_user_generics = generics.clone();
@@ -537,6 +538,7 @@ pub(crate) fn generate_am_group(
537538
}
538539
}
539540

541+
#[allow(clippy::too_many_arguments)]
540542
fn create_am_group_remote(
541543
generics: &syn::Generics,
542544
attributes: &proc_macro2::TokenStream,
@@ -592,7 +594,7 @@ fn create_am_group_remote(
592594
}
593595
});
594596

595-
let my_len = if fields.names().len() > 0 {
597+
let my_len = if !fields.names().is_empty() {
596598
let f = &fields.names()[0];
597599
quote! {
598600
self.#f.len()
@@ -638,6 +640,7 @@ fn create_am_group_remote(
638640
)
639641
}
640642

643+
#[allow(clippy::too_many_arguments)]
641644
pub(crate) fn create_am_group_structs(
642645
generics: &syn::Generics,
643646
attributes: &proc_macro2::TokenStream,
@@ -653,7 +656,7 @@ pub(crate) fn create_am_group_structs(
653656
let am_group_user_struct = generate_am_group_user_struct(
654657
generics,
655658
vis,
656-
&get_am_group_user_name(&name),
659+
&get_am_group_user_name(name),
657660
&get_am_group_name(&format_ident!("{}", name)),
658661
);
659662

0 commit comments

Comments
 (0)