Skip to content

Test no_std MSRV in CI #4292

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

Merged
merged 3 commits into from
Nov 28, 2024
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
13 changes: 11 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,22 @@ jobs:
msrv-lib:
name: Check MSRV for libraries
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- wasm32-unknown-unknown
features:
- --no-default-features
- ""
defaults:
run:
working-directory: crates/msrv/lib
steps:
- uses: actions/checkout@v4
- run: rustup update --no-self-update 1.57 && rustup default 1.57
- run: cargo build
- run: rustup update --no-self-update 1.57 && rustup default 1.57 && rustup target add ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} ${{ matrix.features }}

msrv-cli:
name: Check MSRV for CLI tools
Expand Down
6 changes: 0 additions & 6 deletions crates/msrv/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ version = "0.0.0"

[dependencies]
wasm-bindgen-cli = { path = "../../cli" }
wasm-bindgen-cli-support = { path = "../../cli-support" }
wasm-bindgen-externref-xform = { path = "../../externref-xform" }
wasm-bindgen-multi-value-xform = { path = "../../multi-value-xform" }
wasm-bindgen-threads-xform = { path = "../../threads-xform" }
wasm-bindgen-wasm-conventions = { path = "../../wasm-conventions" }
wasm-bindgen-wasm-interpreter = { path = "../../wasm-interpreter" }
31 changes: 17 additions & 14 deletions crates/msrv/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ name = "msrv-library-test"
publish = false
version = "0.0.0"

[features]
default = ["std"]
std = [
"wasm-bindgen/std",
"js-sys/std",
"wasm-bindgen-futures/std",
"web-sys/std",
"wasm-bindgen-test/std",
]

[dependencies]
js-sys = { path = "../../js-sys" }
wasm-bindgen = { path = "../../../" }
wasm-bindgen-backend = { path = "../../backend" }
wasm-bindgen-futures = { path = "../../futures" }
wasm-bindgen-macro = { path = "../../macro" }
wasm-bindgen-macro-support = { path = "../../macro-support" }
wasm-bindgen-shared = { path = "../../shared" }
wasm-bindgen-test = { path = "../../test" }
wasm-bindgen-test-macro = { path = "../../test-macro" }
web-sys = { path = "../../web-sys" }
js-sys = { path = "../../js-sys", default-features = false }
wasm-bindgen = { path = "../../../", default-features = false }
wasm-bindgen-futures = { path = "../../futures", default-features = false }
wasm-bindgen-test = { path = "../../test", default-features = false }
web-sys = { path = "../../web-sys", default-features = false }

# Pinned sub-dependencies for MSRV
bumpalo = "=3.12.0"
log = "=0.4.18"
scoped-tls = "=1.0.0"

[patch.crates-io]
wasm-bindgen = { path = "../../../" }
scoped-tls = { version = "=1.0.0", optional = false }
2 changes: 1 addition & 1 deletion crates/test/src/rt/scoped_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T> ScopedKey<T> {
#[doc(hidden)]
/// # Safety
/// `inner` must only be accessed through `ScopedKey`'s API
pub const unsafe fn new(inner: &'static Wrapper<Cell<*const ()>>) -> Self {
pub(super) const unsafe fn new(inner: &'static Wrapper<Cell<*const ()>>) -> Self {
Self {
inner,
_marker: PhantomData,
Expand Down
13 changes: 8 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1595,20 +1595,23 @@ pub mod __rt {
/// Wrapper around [`::once_cell::unsync::Lazy`] adding some compatibility methods with
/// [`std::thread::LocalKey`] and adding `Send + Sync` when `atomics` is not enabled.
#[cfg(not(feature = "std"))]
pub struct LazyCell<T>(::once_cell::unsync::Lazy<T>);
pub struct LazyCell<T, F = fn() -> T>(::once_cell::unsync::Lazy<T, F>);

#[cfg(all(not(target_feature = "atomics"), not(feature = "std")))]
unsafe impl<T> Sync for LazyCell<T> {}
unsafe impl<T, F> Sync for LazyCell<T, F> {}

#[cfg(all(not(target_feature = "atomics"), not(feature = "std")))]
unsafe impl<T> Send for LazyCell<T> {}
unsafe impl<T, F> Send for LazyCell<T, F> {}

#[cfg(not(feature = "std"))]
impl<T> LazyCell<T> {
pub const fn new(init: fn() -> T) -> LazyCell<T> {
impl<T, F> LazyCell<T, F> {
pub const fn new(init: F) -> LazyCell<T, F> {
Self(::once_cell::unsync::Lazy::new(init))
}
}

#[cfg(not(feature = "std"))]
impl<T, F: FnOnce() -> T> LazyCell<T, F> {
pub(crate) fn try_with<R>(
&self,
f: impl FnOnce(&T) -> R,
Expand Down