Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,13 @@ jobs:

steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
name: Install Rust
with:
profile: minimal
toolchain: stable
override: true
- name: Build
run: RUSTFLAGS="-D warnings" cargo build --verbose --all-targets --all-features
- name: Run tests
run: make test
- name: Build Documentation
run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
- name: Run rustfmt
run: cargo fmt -- --check
- name: Run clippy
- name: Install rust
run: |
cargo clippy --all-targets --all-features -- --deny warnings
RUSTFLAGS='--cfg loom' cargo clippy --all-targets --all-features -- --deny warnings
rustup install nightly
rustup component add --toolchain nightly miri
rustup show
- name: Run tests
run: make ci
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = ["development-tools", "embedded"]
rust-version = "1.79"

[target.'cfg(loom)'.dependencies]
loom = "0.5"
loom = "0.7"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(loom)"] }
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
.PHONY= test, clippy
.PHONY= test, clippy, test-miri, lint

test:
cargo t
RUSTFLAGS='--cfg loom' cargo t loom

test-miri:
cargo +nightly miri test

check-fmt:
cargo fmt -- --check

clippy:
cargo clippy --all-targets --all-features
RUSTFLAGS='--cfg loom' cargo clippy --all-targets --all-features

lint:
cargo clippy --all-targets
cargo clippy --all-targets --all-features
cargo doc --all-features --no-deps
cargo fmt --check
RUSTFLAGS="$(RUSTFLAGS) --cfg loom" cargo clippy --all-targets --all-features

ci: test test-miri lint
11 changes: 3 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +994,10 @@ impl<'alloc, Rq, Rp> InterchangeRef<'alloc, Rq, Rp> {
let index = self.last_claimed.fetch_add(1, Ordering::Relaxed);
let n = self.channels.len();

for i in (index % n)..n {
let tmp = self.channels[i].split();
if tmp.is_some() {
return tmp;
}
}
let (channels_start, channels_end) = self.channels.split_at(index % n);

for i in 0..(index % n) {
let tmp = self.channels[i].split();
for channel in channels_end.iter().chain(channels_start) {
let tmp = channel.split();
if tmp.is_some() {
return tmp;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/loom.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(not(miri))]

#[cfg(loom)]
use loom::thread;
#[cfg(not(loom))]
Expand Down Expand Up @@ -29,6 +31,8 @@ fn loom_interchange() {

// This is tested even with the standard library to ensure that the Send/Sync traits are implemented as necessary
// Loom's thread::spawn doesn't require the function to be `Send`
//
// miri doesn't like the box being dropped.
#[cfg_attr(not(loom), test)]
fn test_function() {
// thread closures must be 'static
Expand Down
Loading