Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate critical-section feature selection into portable-atomic; other minor updates for v1.20.0 #260

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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

-

## 1.20.0

- propagate `critical-section` feature selection into `portable-atomic`; other minor updates [#260](https://github.com/matklad/once_cell/pull/260)

## 1.19.0

- Use `portable-atomic` instead of `atomic-polyfill`, [#251](https://github.com/matklad/once_cell/pull/251).
Expand Down
117 changes: 65 additions & 52 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "once_cell"
version = "1.19.0"
version = "1.20.0"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2021"
Expand All @@ -20,13 +20,13 @@ exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "rustfmt.toml"]
members = ["xtask"]

[dependencies]
parking_lot_core = { version = "0.9.3", optional = true, default_features = false }
portable-atomic = { version = "1", optional = true }
critical-section = { version = "1", optional = true }
parking_lot_core = { version = "0.9.10", optional = true, default-features = false }
portable-atomic = { version = "1.7", optional = true }
critical-section = { version = "1.1.3", optional = true }

[dev-dependencies]
regex = "1.2.0"
critical-section = { version = "1.1.1", features = ["std"] }
regex = "1.10.6"
critical-section = { version = "1.1.3", features = ["std"] }

[features]
default = ["std"]
Expand All @@ -48,7 +48,7 @@ parking_lot = ["dep:parking_lot_core"]
# Uses `critical-section` to implement `sync` and `race` modules. in
# `#![no_std]` mode. Please read `critical-section` docs carefully
# before enabling this feature.
critical-section = ["dep:critical-section", "portable-atomic" ]
critical-section = ["dep:critical-section", "portable-atomic/critical-section"]

# Enables semver-exempt APIs of this crate.
# At the moment, this feature is unused.
Expand Down
2 changes: 1 addition & 1 deletion src/imp_cs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::panic::{RefUnwindSafe, UnwindSafe};

use portable_atomic::{AtomicBool, Ordering};
use critical_section::{CriticalSection, Mutex};
use portable_atomic::{AtomicBool, Ordering};

use crate::unsync;

Expand Down
4 changes: 2 additions & 2 deletions src/race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
//! `Acquire` and `Release` have very little performance overhead on most
//! architectures versus `Relaxed`.

#[cfg(feature = "critical-section")]
use portable_atomic as atomic;
#[cfg(not(feature = "critical-section"))]
use core::sync::atomic;
#[cfg(feature = "critical-section")]
use portable_atomic as atomic;

use atomic::{AtomicPtr, AtomicUsize, Ordering};
use core::cell::UnsafeCell;
Expand Down
7 changes: 7 additions & 0 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ fn main() -> xshell::Result<()> {
{
let _s = section("TEST");

cmd!(sh, "cargo test --workspace").run()?;

for &release in &[None, Some("--release")] {
cmd!(sh, "cargo test --features unstable {release...}").run()?;
cmd!(
Expand All @@ -41,6 +43,11 @@ fn main() -> xshell::Result<()> {
{
let _s = section("TEST_BETA");
let _e = push_toolchain(&sh, "beta")?;
// TEMPORARY WORKAROUND for Rust compiler issue ref:
// - https://github.com/rust-lang/rust/issues/129352
// - https://github.com/matklad/once_cell/issues/261
let _e = sh.push_env("RUSTFLAGS", "-A unreachable_patterns");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I didn't realize this percolated all the way up to the beta! But, anyway, you've found the perfect solution here, which places the fine-grained work-around where it belongs, thanks a bunch for this!


cmd!(sh, "cargo test --features unstable").run()?;
}

Expand Down
Loading