From e18c7520f8c0d01c84dd14d30ddedf5792cb90b4 Mon Sep 17 00:00:00 2001 From: Alex Martens Date: Fri, 20 Oct 2023 06:09:07 -0700 Subject: [PATCH 1/4] Update UI tests --- cfail/ui/freeze.stderr | 6 +-- cfail/ui/not-send.stderr | 84 ++++++++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/cfail/ui/freeze.stderr b/cfail/ui/freeze.stderr index 1b14d854..56c116e3 100644 --- a/cfail/ui/freeze.stderr +++ b/cfail/ui/freeze.stderr @@ -2,8 +2,8 @@ error[E0499]: cannot borrow `q` as mutable more than once at a time --> $DIR/freeze.rs:7:5 | 6 | let (_p, mut _c) = q.split(); - | --------- first mutable borrow occurs here + | - first mutable borrow occurs here 7 | q.enqueue(0).unwrap(); - | ^^^^^^^^^^^^ second mutable borrow occurs here + | ^ second mutable borrow occurs here 8 | _c.dequeue(); - | ------------ first borrow later used here + | -- first borrow later used here diff --git a/cfail/ui/not-send.stderr b/cfail/ui/not-send.stderr index c9c748f2..40645b7a 100644 --- a/cfail/ui/not-send.stderr +++ b/cfail/ui/not-send.stderr @@ -1,99 +1,123 @@ error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:19:15 + --> ui/not-send.rs:19:15 | 19 | is_send::>(); | ^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()` - = note: required because it appears within the type `PhantomData<*const ()>` +note: required because it appears within the type `PhantomData<*const ()>` + --> $RUST/core/src/marker.rs = note: required for `Consumer<'_, PhantomData<*const ()>, 4>` to implement `Send` note: required by a bound in `is_send` - --> $DIR/not-send.rs:14:8 + --> ui/not-send.rs:14:8 | 12 | fn is_send() - | ------- required by a bound in this + | ------- required by a bound in this function 13 | where 14 | T: Send, | ^^^^ required by this bound in `is_send` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:20:15 + --> ui/not-send.rs:20:15 | 20 | is_send::>(); | ^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | = help: within `PhantomData<*const ()>`, the trait `Send` is not implemented for `*const ()` - = note: required because it appears within the type `PhantomData<*const ()>` +note: required because it appears within the type `PhantomData<*const ()>` + --> $RUST/core/src/marker.rs = note: required for `Producer<'_, PhantomData<*const ()>, 4>` to implement `Send` note: required by a bound in `is_send` - --> $DIR/not-send.rs:14:8 + --> ui/not-send.rs:14:8 | 12 | fn is_send() - | ------- required by a bound in this + | ------- required by a bound in this function 13 | where 14 | T: Send, | ^^^^ required by this bound in `is_send` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:21:15 + --> ui/not-send.rs:21:15 | 21 | is_send::>(); | ^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | = help: within `Queue, 4>`, the trait `Send` is not implemented for `*const ()` - = note: required because it appears within the type `PhantomData<*const ()>` - = note: required because it appears within the type `ManuallyDrop>` - = note: required because it appears within the type `MaybeUninit>` - = note: required because it appears within the type `UnsafeCell>>` +note: required because it appears within the type `PhantomData<*const ()>` + --> $RUST/core/src/marker.rs +note: required because it appears within the type `ManuallyDrop>` + --> $RUST/core/src/mem/manually_drop.rs +note: required because it appears within the type `MaybeUninit>` + --> $RUST/core/src/mem/maybe_uninit.rs +note: required because it appears within the type `UnsafeCell>>` + --> $RUST/core/src/cell.rs = note: required because it appears within the type `[UnsafeCell>>; 4]` - = note: required because it appears within the type `Queue, 4>` +note: required because it appears within the type `Queue, 4>` + --> $HEAPLESS/src/spsc.rs + | + | pub struct Queue { + | ^^^^^ note: required by a bound in `is_send` - --> $DIR/not-send.rs:14:8 + --> ui/not-send.rs:14:8 | 12 | fn is_send() - | ------- required by a bound in this + | ------- required by a bound in this function 13 | where 14 | T: Send, | ^^^^ required by this bound in `is_send` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:22:15 + --> ui/not-send.rs:22:15 | 22 | is_send::>(); | ^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | = help: within `heapless::Vec, 4>`, the trait `Send` is not implemented for `*const ()` - = note: required because it appears within the type `PhantomData<*const ()>` - = note: required because it appears within the type `ManuallyDrop>` - = note: required because it appears within the type `MaybeUninit>` +note: required because it appears within the type `PhantomData<*const ()>` + --> $RUST/core/src/marker.rs +note: required because it appears within the type `ManuallyDrop>` + --> $RUST/core/src/mem/manually_drop.rs +note: required because it appears within the type `MaybeUninit>` + --> $RUST/core/src/mem/maybe_uninit.rs = note: required because it appears within the type `[MaybeUninit>; 4]` - = note: required because it appears within the type `heapless::Vec, 4>` +note: required because it appears within the type `Vec, 4>` + --> $HEAPLESS/src/vec.rs + | + | pub struct Vec { + | ^^^ note: required by a bound in `is_send` - --> $DIR/not-send.rs:14:8 + --> ui/not-send.rs:14:8 | 12 | fn is_send() - | ------- required by a bound in this + | ------- required by a bound in this function 13 | where 14 | T: Send, | ^^^^ required by this bound in `is_send` error[E0277]: `*const ()` cannot be sent between threads safely - --> $DIR/not-send.rs:23:15 + --> ui/not-send.rs:23:15 | 23 | is_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely | = help: within `HistoryBuffer, 4>`, the trait `Send` is not implemented for `*const ()` - = note: required because it appears within the type `PhantomData<*const ()>` - = note: required because it appears within the type `ManuallyDrop>` - = note: required because it appears within the type `MaybeUninit>` +note: required because it appears within the type `PhantomData<*const ()>` + --> $RUST/core/src/marker.rs +note: required because it appears within the type `ManuallyDrop>` + --> $RUST/core/src/mem/manually_drop.rs +note: required because it appears within the type `MaybeUninit>` + --> $RUST/core/src/mem/maybe_uninit.rs = note: required because it appears within the type `[MaybeUninit>; 4]` - = note: required because it appears within the type `HistoryBuffer, 4>` +note: required because it appears within the type `HistoryBuffer, 4>` + --> $HEAPLESS/src/histbuf.rs + | + | pub struct HistoryBuffer { + | ^^^^^^^^^^^^^ note: required by a bound in `is_send` - --> $DIR/not-send.rs:14:8 + --> ui/not-send.rs:14:8 | 12 | fn is_send() - | ------- required by a bound in this + | ------- required by a bound in this function 13 | where 14 | T: Send, | ^^^^ required by this bound in `is_send` From 3d876e2bf23084575d3a30f87acf77b1d84b16f2 Mon Sep 17 00:00:00 2001 From: Alex Martens Date: Fri, 20 Oct 2023 06:35:58 -0700 Subject: [PATCH 2/4] Fix dropping_references warning --- CHANGELOG.md | 2 ++ src/linear_map.rs | 31 +++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b34e84b..1e7f7011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed a `dropping_references` warning in `LinearMap`. + ### Removed - [breaking-change] this crate no longer has a Minimum Supported Rust Version (MSRV) guarantee and diff --git a/src/linear_map.rs b/src/linear_map.rs index d096f210..0a3b8a3e 100644 --- a/src/linear_map.rs +++ b/src/linear_map.rs @@ -461,15 +461,6 @@ impl<'a, K, V> Clone for Iter<'a, K, V> { } } -impl Drop for LinearMap { - fn drop(&mut self) { - // heapless::Vec implements drop right? - drop(&self.buffer); - // original code below - // unsafe { ptr::drop_in_place(self.buffer.as_mut_slice()) } - } -} - pub struct IterMut<'a, K, V> { iter: slice::IterMut<'a, (K, V)>, } @@ -540,5 +531,25 @@ mod test { } } - // TODO: drop test + #[test] + fn drop() { + droppable!(); + + { + let mut v: LinearMap = LinearMap::new(); + v.insert(0, Droppable::new()).ok().unwrap(); + v.insert(1, Droppable::new()).ok().unwrap(); + v.remove(&1).unwrap(); + } + + assert_eq!(Droppable::count(), 0); + + { + let mut v: LinearMap = LinearMap::new(); + v.insert(0, Droppable::new()).ok().unwrap(); + v.insert(1, Droppable::new()).ok().unwrap(); + } + + assert_eq!(Droppable::count(), 0); + } } From 199a8d88199ec2d282c9cc9198deb4f89793c046 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 20 Oct 2023 23:08:04 +0200 Subject: [PATCH 3/4] enable github merge queue. --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8793ed2f..f6f569e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: branches: [main] push: branches: [staging, trying] + workflow_dispatch: env: CARGO_TERM_COLOR: always @@ -338,8 +339,6 @@ jobs: - name: Run cargo run: cargo run - - # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149 # # ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB! From a4e8f821607644b164cc64193432d4f515e4ed48 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 20 Oct 2023 23:32:49 +0200 Subject: [PATCH 4/4] Fix tsan tests. from [this](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#threadsanitizer) > To work correctly ThreadSanitizer needs to be "aware" of all synchronization operations in a program. It generally achieves that through \[...\] and compile time instrumentation (e.g. atomic operations). Using it without instrumenting all the program code can lead to false positive reports. and the example uses -Zbuild-std ... of course, std has to be instrumented. Adding -Zbuild-std fixes it, indeed. --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6f569e4..4704d243 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -283,6 +283,7 @@ jobs: with: toolchain: ${{ matrix.toolchain }} target: ${{ matrix.target }} + components: rust-src override: true - name: Export variables @@ -295,7 +296,7 @@ jobs: with: use-cross: false command: test - args: --test tsan --target=${{ matrix.target }} --features=${{ matrix.features }} ${{ matrix.buildtype }} -- --test-threads=1 + args: -Zbuild-std --test tsan --target=${{ matrix.target }} --features=${{ matrix.features }} ${{ matrix.buildtype }} -- --test-threads=1 # Run cfail tests on MSRV testcfail: