Skip to content

Commit da900a1

Browse files
authored
Merge pull request #30 from thomcc/clippo
Fix clippy, improve CI
2 parents de2fd5d + 98f43c3 commit da900a1

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
# Run daily to catch when Rust updates cause problems to happen.
7+
schedule:
8+
- cron: '00 01 * * *'
49

510
jobs:
611
rust:
@@ -78,3 +83,4 @@ jobs:
7883
uses: actions-rs/cargo@v1
7984
with:
8085
command: clippy
86+
args: --workspace -- -D warnings

libmimalloc-sys/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::collapsible_if)]
12
use cmake::Config;
23
use std::env;
34

src/lib.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ unsafe impl GlobalAlloc for MiMalloc {
6767
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
6868
mi_malloc(layout.size()) as *mut u8
6969
} else {
70-
if cfg!(target_os = "macos") {
71-
if layout.align() > (1 << 31) {
72-
return core::ptr::null_mut();
73-
}
70+
if cfg!(target_os = "macos") && layout.align() > (1 << 31) {
71+
return core::ptr::null_mut();
7472
}
7573

7674
mi_malloc_aligned(layout.size(), layout.align()) as *mut u8
@@ -82,10 +80,8 @@ unsafe impl GlobalAlloc for MiMalloc {
8280
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
8381
mi_zalloc(layout.size()) as *mut u8
8482
} else {
85-
if cfg!(target_os = "macos") {
86-
if layout.align() > (1 << 31) {
87-
return core::ptr::null_mut();
88-
}
83+
if cfg!(target_os = "macos") && layout.align() > (1 << 31) {
84+
return core::ptr::null_mut();
8985
}
9086

9187
mi_zalloc_aligned(layout.size(), layout.align()) as *mut u8
@@ -117,7 +113,7 @@ mod tests {
117113
let layout = Layout::from_size_align(8, 8).unwrap();
118114
let alloc = MiMalloc;
119115

120-
let ptr = alloc.alloc(layout.clone());
116+
let ptr = alloc.alloc(layout);
121117
alloc.dealloc(ptr, layout);
122118
}
123119
}
@@ -128,7 +124,7 @@ mod tests {
128124
let layout = Layout::from_size_align(8, 8).unwrap();
129125
let alloc = MiMalloc;
130126

131-
let ptr = alloc.alloc_zeroed(layout.clone());
127+
let ptr = alloc.alloc_zeroed(layout);
132128
alloc.dealloc(ptr, layout);
133129
}
134130
}
@@ -139,8 +135,8 @@ mod tests {
139135
let layout = Layout::from_size_align(8, 8).unwrap();
140136
let alloc = MiMalloc;
141137

142-
let ptr = alloc.alloc(layout.clone());
143-
let ptr = alloc.realloc(ptr, layout.clone(), 16);
138+
let ptr = alloc.alloc(layout);
139+
let ptr = alloc.realloc(ptr, layout, 16);
144140
alloc.dealloc(ptr, layout);
145141
}
146142
}

0 commit comments

Comments
 (0)