diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 571a02a..b29f285 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,8 @@ jobs: - name: Set Rust 1.65.0 as default run: rustup default nightly-2022-09-18 - name: Check MSRV + env: + RUSTFLAGS: --allow unknown_lints run: cargo check --all-features docsrs: diff --git a/Makefile.toml b/Makefile.toml index 10859a9..a6a5437 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -7,11 +7,17 @@ CLIPPY_FLAGS_LOOM = "${CFG_LOOM} ${CLIPPY_FLAGS}" [config] default_to_workspace = false +# Install a "no_std" target. +[tasks.install-no-std-target] +command = "rustup" +args = ["target", "add", "thumbv7m-none-eabi"] + # Build package for no_std environment. [tasks.no-std] command = "cargo" args = ["hack", "build", "--target", "thumbv7m-none-eabi", "--feature-powerset", "--no-dev-deps", "--skip", "yield,thread_local"] +dependencies = ["install-no-std-target"] # Build docs for docs.rs. [tasks.docsrs] @@ -28,7 +34,7 @@ args = ["rustdoc", "--all-features", "--open", "--", "--default-theme", "ayu"] # Link: https://blog.rust-lang.org/2022/06/22/sparse-registry-testing.html toolchain = "nightly-2022-09-18" command = "cargo" -env = { "CARGO_UNSTABLE_SPARSE_REGISTRY" = "true" } +env = { "CARGO_UNSTABLE_SPARSE_REGISTRY" = "true", "RUSTFLAGS" = "--allow unknown_lints" } args = ["check", "--all-features"] # Check semver viloations. diff --git a/rustfmt.toml b/rustfmt.toml index 65d48b6..32e1fa2 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,2 @@ -edition = "2021" +edition = "2024" use_small_heuristics = "Max" diff --git a/src/inner/raw/mod.rs b/src/inner/raw/mod.rs index e69c5cb..8c80ef5 100644 --- a/src/inner/raw/mod.rs +++ b/src/inner/raw/mod.rs @@ -117,10 +117,10 @@ impl MutexNodeInit { /// # Safety /// /// Pointer is required to be non-null and aligned, and the current thread - /// must have exclusive access over it. + /// must have exclusive access over its `next` pointer. unsafe fn get_next(this: *mut Self) -> *mut Self { // SAFETY: Caller guaranteed that `this` is valid and that the current - // thread has exclusive access over it. + // thread has exclusive access over its `next` pointer. unsafe { &mut (*this).next }.load_unsynced() } diff --git a/src/inner/raw/thread_local.rs b/src/inner/raw/thread_local.rs index 65fc190..3a650cf 100644 --- a/src/inner/raw/thread_local.rs +++ b/src/inner/raw/thread_local.rs @@ -77,7 +77,7 @@ impl Mutex { N: DerefMut>, Fn: FnOnce(Option<&mut T>) -> Ret, { - self.with_local_node_then_unchecked(node, |m, n| m.try_lock_with_then(n, f)) + unsafe { self.with_local_node_then_unchecked(node, |m, n| m.try_lock_with_then(n, f)) } } /// Attempts to acquire this mutex with a thread local node and then runs @@ -110,7 +110,7 @@ impl Mutex { N: DerefMut>, Fn: FnOnce(&mut T) -> Ret, { - self.with_local_node_then_unchecked(node, |m, n| m.lock_with_then(n, f)) + unsafe { self.with_local_node_then_unchecked(node, |m, n| m.lock_with_then(n, f)) } } /// Runs `f` over a raw mutex and a thread local node as arguments. diff --git a/src/lib.rs b/src/lib.rs index a330bbb..8ca3a73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ #![allow(clippy::module_name_repetitions)] #![allow(clippy::inline_always)] #![allow(clippy::doc_markdown)] -#![warn(rust_2021_compatibility)] +#![warn(rust_2024_compatibility)] #![warn(missing_docs)] #[cfg(feature = "thread_local")] diff --git a/src/raw/thread_local.rs b/src/raw/thread_local.rs index 3fc1763..8ca12f4 100644 --- a/src/raw/thread_local.rs +++ b/src/raw/thread_local.rs @@ -305,7 +305,7 @@ impl Mutex { where F: FnOnce(Option<&mut T>) -> Ret, { - self.inner.try_lock_with_local_then_unchecked(&node.inner, f) + unsafe { self.inner.try_lock_with_local_then_unchecked(&node.inner, f) } } /// Acquires this mutex and then runs the closure against the protected data. @@ -472,7 +472,7 @@ impl Mutex { where F: FnOnce(&mut T) -> Ret, { - self.inner.lock_with_local_then_unchecked(&node.inner, f) + unsafe { self.inner.lock_with_local_then_unchecked(&node.inner, f) } } /// Mutable borrows must not escape the closure.