Skip to content

Commit

Permalink
chore: rust 2024 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromfedricci committed Jan 8, 2025
1 parent 09b20b7 commit 5d3dae6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
edition = "2021"
edition = "2024"
use_small_heuristics = "Max"
4 changes: 2 additions & 2 deletions src/inner/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ impl<L> MutexNodeInit<L> {
/// # 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()
}

Expand Down
4 changes: 2 additions & 2 deletions src/inner/raw/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T: ?Sized, L: Lock, W: Wait, F: Fairness> Mutex<T, L, W, F> {
N: DerefMut<Target = MutexNode<L>>,
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
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<T: ?Sized, L: Lock, W: Wait, F: Fairness> Mutex<T, L, W, F> {
N: DerefMut<Target = MutexNode<L>>,
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.
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 2 additions & 2 deletions src/raw/thread_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl<T: ?Sized, R: Relax> Mutex<T, R> {
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.
Expand Down Expand Up @@ -472,7 +472,7 @@ impl<T: ?Sized, R: Relax> Mutex<T, R> {
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.
Expand Down

0 comments on commit 5d3dae6

Please sign in to comment.