Skip to content

Commit 3aa551d

Browse files
committed
ci: deny warnings and add more checks
1 parent bb66eba commit 3aa551d

File tree

8 files changed

+54
-38
lines changed

8 files changed

+54
-38
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ jobs:
3939
toolchain: ${{ matrix.toolchain }}
4040
components: clippy
4141
- name: cargo clippy
42-
uses: actions-rs/clippy-check@v1
43-
with:
44-
token: ${{ secrets.GITHUB_TOKEN }}
42+
run: cargo clippy -- -D warnings
4543
doc:
4644
runs-on: ubuntu-latest
4745
name: nightly / doc

.github/workflows/nostd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ jobs:
2222
run: rustup target add ${{ matrix.target }}
2323
- name: cargo check
2424
run: cargo check --target ${{ matrix.target }} --no-default-features
25+
env:
26+
RUSTFLAGS: "-Dwarnings"

.github/workflows/safety.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,24 @@ jobs:
2828
run: cargo test --lib --tests --all-features --target x86_64-unknown-linux-gnu
2929
env:
3030
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
31-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address"
31+
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address -Dwarnings"
3232
- name: cargo test -Zsanitizer=leak
3333
if: always()
3434
run: cargo test --all-features --target x86_64-unknown-linux-gnu
3535
env:
3636
LSAN_OPTIONS: "suppressions=lsan-suppressions.txt"
37-
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak"
37+
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak -Dwarnings"
3838
miri:
3939
runs-on: ubuntu-latest
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
flags: [
44+
"",
45+
"-Zmiri-tree-borrows",
46+
"-Zmiri-strict-provenance",
47+
"-Zmiri-tree-borrows -Zmiri-strict-provenance"
48+
]
4049
steps:
4150
- uses: actions/checkout@v4
4251
with:
@@ -48,10 +57,11 @@ jobs:
4857
with:
4958
toolchain: ${{ env.NIGHTLY }}
5059
components: miri
51-
- name: cargo miri test
60+
- name: ${{ matrix.flags }} cargo miri test
5261
run: cargo miri test
5362
env:
54-
MIRIFLAGS: ""
63+
RUSTFLAGS: "-Dwarnings"
64+
MIRIFLAGS: ${{ matrix.flags }}
5565
# loom:
5666
# runs-on: ubuntu-latest
5767
# steps:

.github/workflows/scheduled.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
run: cargo generate-lockfile
2828
- name: cargo test --locked
2929
run: cargo test --locked --all-features --all-targets
30+
env:
31+
RUSTFLAGS: "-Dwarnings"
3032
# https://twitter.com/alcuadrado/status/1571291687837732873
3133
update:
3234
runs-on: ubuntu-latest
@@ -46,4 +48,4 @@ jobs:
4648
- name: cargo test
4749
run: cargo test --locked --all-features --all-targets
4850
env:
49-
RUSTFLAGS: -D deprecated
51+
RUSTFLAGS: -Ddeprecated -Dwarnings

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ jobs:
2929
# https://twitter.com/jonhoo/status/1571290371124260865
3030
- name: cargo test --locked
3131
run: cargo test --locked --all-features --all-targets
32+
env:
33+
RUSTFLAGS: "-Dwarnings"
3234
# https://github.com/rust-lang/cargo/issues/6669
3335
- name: cargo test --doc
3436
run: cargo test --locked --all-features --doc
37+
env:
38+
RUSTFLAGS: "-Dwarnings"
3539
os-check:
3640
runs-on: ${{ matrix.os }}
3741
name: ${{ matrix.os }} / nightly
@@ -53,4 +57,6 @@ jobs:
5357
if: hashFiles('Cargo.lock') == ''
5458
run: cargo generate-lockfile
5559
- name: cargo test
56-
run: cargo test --locked --all-features --all-targets
60+
run: cargo test --locked --all-features --all-targets
61+
env:
62+
RUSTFLAGS: "-Dwarnings"

tests/alloc_fail.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
11
#![feature(allocator_api)]
22

3-
use core::alloc::AllocError;
4-
use pinned_init::*;
5-
use std::sync::Arc;
6-
7-
#[path = "./ring_buf.rs"]
8-
mod ring_buf;
9-
use ring_buf::*;
10-
11-
#[cfg(all(not(miri), not(NO_ALLOC_FAIL_TESTS), not(target_os = "macos")))]
12-
#[test]
13-
fn too_big_pinned() {
14-
// should be too big with current hardware.
15-
assert!(matches!(
16-
Box::pin_init(RingBuffer::<u8, { 1024 * 1024 * 1024 * 1024 }>::new()),
17-
Err(AllocError)
18-
));
19-
// should be too big with current hardware.
20-
assert!(matches!(
21-
Arc::pin_init(RingBuffer::<u8, { 1024 * 1024 * 1024 * 1024 }>::new()),
22-
Err(AllocError)
23-
));
24-
}
25-
263
#[cfg(all(not(miri), not(NO_ALLOC_FAIL_TESTS), not(target_os = "macos")))]
274
#[test]
285
fn too_big_in_place() {
6+
use core::alloc::AllocError;
7+
use pinned_init::*;
8+
use std::sync::Arc;
299
// should be too big with current hardware.
3010
assert!(matches!(
3111
Box::init(zeroed::<[u8; 1024 * 1024 * 1024 * 1024]>()),

tests/ring_buf.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ use core::{
1212
use pinned_init::*;
1313
use std::sync::Arc;
1414

15-
#[path = "../examples/mutex.rs"]
16-
mod mutex;
17-
use mutex::*;
18-
1915
#[pin_data(PinnedDrop)]
2016
pub struct RingBuffer<T, const SIZE: usize> {
2117
buffer: [MaybeUninit<T>; SIZE],
@@ -239,6 +235,7 @@ fn with_failing_inner() {
239235
assert_eq!(buf.as_mut().pop(), None);
240236
}
241237

238+
#[cfg_attr(miri, allow(dead_code))]
242239
#[derive(Debug)]
243240
struct BigStruct {
244241
buf: [u8; 1024 * 1024],
@@ -263,6 +260,10 @@ fn big_struct() {
263260
#[cfg(not(miri))]
264261
#[test]
265262
fn with_big_struct() {
263+
#[path = "../examples/mutex.rs"]
264+
mod mutex;
265+
use mutex::*;
266+
266267
let buf = Arc::pin_init(CMutex::new(RingBuffer::<BigStruct, 64>::new())).unwrap();
267268
let mut buf = buf.lock();
268269
for _ in 0..63 {
@@ -285,3 +286,18 @@ fn with_big_struct() {
285286
assert!(matches!(buf.as_mut().pop_no_stack(), Some(_)));
286287
}
287288
}
289+
290+
#[cfg(all(not(miri), not(NO_ALLOC_FAIL_TESTS), not(target_os = "macos")))]
291+
#[test]
292+
fn too_big_pinned() {
293+
// should be too big with current hardware.
294+
assert!(matches!(
295+
Box::pin_init(RingBuffer::<u8, { 1024 * 1024 * 1024 * 1024 }>::new()),
296+
Err(AllocError)
297+
));
298+
// should be too big with current hardware.
299+
assert!(matches!(
300+
Arc::pin_init(RingBuffer::<u8, { 1024 * 1024 * 1024 * 1024 }>::new()),
301+
Err(AllocError)
302+
));
303+
}

tests/ui.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#[cfg_attr(not(any(miri, NO_UI_TESTS)), test)]
1+
#[cfg(not(any(miri, NO_UI_TESTS)))]
2+
#[test]
23
fn compile_fail() {
34
let test_cases = trybuild::TestCases::new();
45
test_cases.compile_fail("tests/ui/compile-fail/pinned_drop/*.rs");
@@ -7,7 +8,8 @@ fn compile_fail() {
78
test_cases.compile_fail("tests/ui/compile-fail/zeroable/*.rs");
89
}
910

10-
#[cfg_attr(not(any(miri, NO_UI_TESTS)), test)]
11+
#[cfg(not(any(miri, NO_UI_TESTS)))]
12+
#[test]
1113
fn expand() {
1214
macrotest::expand("tests/ui/expand/*.rs");
1315
}

0 commit comments

Comments
 (0)