Skip to content

Commit 5ce6568

Browse files
committed
Add clippy lints
Adds a variety of clippy lints such that it doesn't interfere more than necessary with the current code style. Does not enable `shadow_unrelated` yet. Signed-off-by: Moritz Hoffmann <[email protected]>
1 parent ee10f84 commit 5ce6568

Some content is hidden

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

56 files changed

+391
-333
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
- master
66
pull_request:
77

8+
# Make sure CI fails on all warnings, including Clippy lints
9+
env:
10+
RUSTFLAGS: "-Dwarnings"
11+
812
jobs:
913
test:
1014
strategy:
@@ -25,6 +29,8 @@ jobs:
2529
toolchain: ${{ matrix.toolchain }}
2630
- name: Cargo test
2731
run: cargo test --workspace --all-targets
32+
- name: Cargo clippy
33+
run: cargo clippy --workspace --all-targets
2834

2935
# Check mdbook files for errors
3036
mdbook:

Cargo.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,70 @@ edition = "2021"
1515
[workspace.dependencies]
1616
columnar = "0.3"
1717

18+
[workspace.lints.clippy]
19+
type_complexity = "allow"
20+
option_map_unit_fn = "allow"
21+
wrong_self_convention = "allow"
22+
should_implement_trait = "allow"
23+
module_inception = "allow"
24+
25+
#as_conversions = "warn"
26+
bool_comparison = "warn"
27+
borrow_interior_mutable_const = "warn"
28+
borrowed_box = "warn"
29+
builtin_type_shadow = "warn"
30+
clone_on_ref_ptr = "warn"
31+
crosspointer_transmute = "warn"
32+
dbg_macro = "warn"
33+
deref_addrof = "warn"
34+
disallowed_macros = "warn"
35+
disallowed_methods = "warn"
36+
disallowed_types = "warn"
37+
double_must_use = "warn"
38+
double_neg = "warn"
39+
double_parens = "warn"
40+
duplicate_underscore_argument = "warn"
41+
excessive_precision = "warn"
42+
extra_unused_lifetimes = "warn"
43+
from_over_into = "warn"
44+
match_overlapping_arm = "warn"
45+
must_use_unit = "warn"
46+
mut_mutex_lock = "warn"
47+
needless_borrow = "warn"
48+
needless_pass_by_ref_mut = "warn"
49+
needless_question_mark = "warn"
50+
needless_return = "warn"
51+
no_effect = "warn"
52+
panicking_overflow_checks = "warn"
53+
partialeq_ne_impl = "warn"
54+
print_literal = "warn"
55+
redundant_closure = "warn"
56+
redundant_closure_call = "warn"
57+
redundant_field_names = "warn"
58+
redundant_pattern = "warn"
59+
redundant_slicing = "warn"
60+
redundant_static_lifetimes = "warn"
61+
same_item_push = "warn"
62+
#shadow_unrelated = "warn"
63+
single_component_path_imports = "warn"
64+
suspicious_assignment_formatting = "warn"
65+
suspicious_else_formatting = "warn"
66+
suspicious_unary_op_formatting = "warn"
67+
todo = "warn"
68+
transmutes_expressible_as_ptr_casts = "warn"
69+
unnecessary_cast = "warn"
70+
unnecessary_lazy_evaluations = "warn"
71+
unnecessary_mut_passed = "warn"
72+
unnecessary_unwrap = "warn"
73+
unused_async = "warn"
74+
useless_asref = "warn"
75+
useless_conversion = "warn"
76+
useless_format = "warn"
77+
wildcard_in_or_patterns = "warn"
78+
write_literal = "warn"
79+
zero_divided_by_zero = "warn"
80+
zero_prefixed_literal = "warn"
81+
1882
[profile.release]
1983
opt-level = 3
2084
debug = true

bytes/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ homepage = "https://github.com/TimelyDataflow/timely-dataflow"
1111
repository = "https://github.com/TimelyDataflow/timely-dataflow.git"
1212
keywords = ["timely", "dataflow", "bytes"]
1313
license = "MIT"
14+
15+
[lints]
16+
workspace = true

bytes/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub mod arc {
9494
let result = BytesMut {
9595
ptr: self.ptr,
9696
len: index,
97-
sequestered: self.sequestered.clone(),
97+
sequestered: Arc::clone(&self.sequestered),
9898
};
9999

100100
self.ptr = self.ptr.wrapping_add(index);
@@ -204,7 +204,7 @@ pub mod arc {
204204
let result = Bytes {
205205
ptr: self.ptr,
206206
len: index,
207-
sequestered: self.sequestered.clone(),
207+
sequestered: Arc::clone(&self.sequestered),
208208
};
209209

210210
self.ptr = self.ptr.wrapping_add(index);

communication/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ repository = "https://github.com/TimelyDataflow/timely-dataflow.git"
1313
keywords = ["timely", "dataflow"]
1414
license = "MIT"
1515

16+
[lints]
17+
workspace = true
18+
1619
[features]
1720
default = ["getopts"]
1821

communication/examples/comm_hello.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ fn main() {
3232
let (mut senders, mut receiver) = allocator.allocate(0);
3333

3434
// send typed data along each channel
35-
for i in 0 .. allocator.peers() {
36-
senders[i].send(Message { payload: format!("hello, {}", i)});
37-
senders[i].done();
35+
for (i, sender) in senders.iter_mut().enumerate() {
36+
sender.send(Message { payload: format!("hello, {}", i)});
37+
sender.done();
3838
}
3939

4040
// no support for termination notification,

communication/examples/lgalloc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ impl Drop for LgallocHandle {
5959
}
6060

6161
fn main() {
62-
let mut config = lgalloc::LgAlloc::new();
63-
config.enable().with_path(std::env::temp_dir());
64-
lgalloc::lgalloc_set_config(&config);
62+
let mut lgconfig = lgalloc::LgAlloc::new();
63+
lgconfig.enable().with_path(std::env::temp_dir());
64+
lgalloc::lgalloc_set_config(&lgconfig);
6565

6666
let refill = BytesRefill {
6767
logic: std::sync::Arc::new(|size| lgalloc_refill(size) as Box<dyn DerefMut<Target=[u8]>>),
@@ -79,9 +79,9 @@ fn main() {
7979
let (mut senders, mut receiver) = allocator.allocate(0);
8080

8181
// send typed data along each channel
82-
for i in 0 .. allocator.peers() {
83-
senders[i].send(Message { payload: format!("hello, {}", i)});
84-
senders[i].done();
82+
for (i, sender) in senders.iter_mut().enumerate() {
83+
sender.send(Message { payload: format!("hello, {}", i)});
84+
sender.done();
8585
}
8686

8787
// no support for termination notification,

communication/src/allocator/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub trait Allocate {
9494
(thread::ThreadPusher<T>,
9595
thread::ThreadPuller<T>)
9696
{
97-
thread::Thread::new_from(identifier, self.events().clone())
97+
thread::Thread::new_from(identifier, Rc::clone(self.events()))
9898
}
9999

100100
/// Allocates a broadcast channel, where each pushed message is received by all.

communication/src/allocator/process.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl PeerBuilder for Process {
102102
peers,
103103
buzzers_send: bsend,
104104
buzzers_recv: brecv,
105-
channels: channels.clone(),
105+
channels: Arc::clone(&channels),
106106
counters_send: counters_send.clone(),
107107
counters_recv: recv,
108108
}
@@ -173,7 +173,7 @@ impl Allocate for Process {
173173
.map(|s| Box::new(s) as Box<dyn Push<T>>)
174174
.collect::<Vec<_>>();
175175

176-
let recv = Box::new(CountPuller::new(recv, identifier, self.inner.events().clone())) as Box<dyn Pull<T>>;
176+
let recv = Box::new(CountPuller::new(recv, identifier, Rc::clone(self.inner.events()))) as Box<dyn Pull<T>>;
177177

178178
(sends, recv)
179179
}

communication/src/allocator/thread.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Allocate for Thread {
3030
fn index(&self) -> usize { 0 }
3131
fn peers(&self) -> usize { 1 }
3232
fn allocate<T: 'static>(&mut self, identifier: usize) -> (Vec<Box<dyn Push<T>>>, Box<dyn Pull<T>>) {
33-
let (pusher, puller) = Thread::new_from(identifier, self.events.clone());
33+
let (pusher, puller) = Thread::new_from(identifier, Rc::clone(&self.events));
3434
(vec![Box::new(pusher)], Box::new(puller))
3535
}
3636
fn events(&self) -> &Rc<RefCell<Vec<usize>>> {
@@ -59,8 +59,8 @@ impl Thread {
5959
-> (ThreadPusher<T>, ThreadPuller<T>)
6060
{
6161
let shared = Rc::new(RefCell::new((VecDeque::<T>::new(), VecDeque::<T>::new())));
62-
let pusher = Pusher { target: shared.clone() };
63-
let pusher = CountPusher::new(pusher, identifier, events.clone());
62+
let pusher = Pusher { target: Rc::clone(&shared) };
63+
let pusher = CountPusher::new(pusher, identifier, Rc::clone(&events));
6464
let puller = Puller { source: shared, current: None };
6565
let puller = CountPuller::new(puller, identifier, events);
6666
(pusher, puller)

0 commit comments

Comments
 (0)