Skip to content

Commit c5fb705

Browse files
committed
Re-establish feature resolver version 1 compatibility
1 parent e021ba4 commit c5fb705

File tree

18 files changed

+87
-160
lines changed

18 files changed

+87
-160
lines changed

.github/workflows/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ jobs:
6868
- run: cargo clippy --no-deps --all-features -p example-tests -- -D warnings
6969
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-externref-xform -- -D warnings
7070
- run: cargo clippy --no-deps --all-features --target wasm32-unknown-unknown -p wasm-bindgen-futures -- -D warnings
71-
- run: cargo clippy --no-deps --features spans,strict-macro -p wasm-bindgen-macro -- -D warnings
72-
- run: cargo clippy --no-deps --features extra-traits,spans,strict-macro -p wasm-bindgen-macro-support -- -D warnings
71+
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-macro -- -D warnings
72+
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-macro-support -- -D warnings
7373
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-multi-value-xform -- -D warnings
7474
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-shared -- -D warnings
7575
- run: cargo clippy --no-deps --all-features --target wasm32-unknown-unknown -p wasm-bindgen-test -- -D warnings
76-
- run: cargo clippy --no-deps -p wasm-bindgen-test-macro -- -D warnings
76+
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-test-macro -- -D warnings
7777
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-threads-xform -- -D warnings
7878
- run: cargo clippy --no-deps --all-features --target wasm32-unknown-unknown -p typescript-tests -- -D warnings
7979
- run: cargo clippy --no-deps --all-features -p wasm-bindgen-wasm-conventions -- -D warnings
@@ -540,7 +540,7 @@ jobs:
540540
path: docs.tar.gz
541541

542542
msrv-resolver:
543-
name: Check for feature resolver v1 error message
543+
name: Check feature resolver version 1 compatibility
544544
runs-on: ubuntu-latest
545545
strategy:
546546
fail-fast: false
@@ -565,7 +565,7 @@ jobs:
565565
cargo update -p bumpalo --precise 3.12.0
566566
cargo update -p log --precise 0.4.18
567567
cargo update -p scoped-tls --precise 1.0.0
568-
- run: diff <(cargo build --target ${{ matrix.target }} ${{ matrix.features }} --message-format json | jq -r "select(.reason == \"compiler-message\") | .message.message") error-${{ matrix.rust }}.txt
568+
- run: cargo build --target ${{ matrix.target }} ${{ matrix.features }}
569569

570570
msrv-lib:
571571
name: Check MSRV for libraries

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55

66
### Added
77

8-
* Add clear error message to communicate new feature resolver version requirements.
9-
[#4312](https://github.com/rustwasm/wasm-bindgen/pull/4312)
10-
118
* Add support for multi-threading in Node.js.
129
[#4318](https://github.com/rustwasm/wasm-bindgen/pull/4318)
1310

@@ -27,6 +24,9 @@
2724
* Fix macro-hygiene for calls to `std::thread_local!`.
2825
[#4315](https://github.com/rustwasm/wasm-bindgen/pull/4315)
2926

27+
* Fix feature resolver version 1 compatibility.
28+
[#4327](https://github.com/rustwasm/wasm-bindgen/pull/4327)
29+
3030
--------------------------------------------------------------------------------
3131

3232
## [0.2.97](https://github.com/rustwasm/wasm-bindgen/compare/0.2.96...0.2.97)

Cargo.toml

+1-16
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,6 @@ serde = { version = "1.0", optional = true }
4747
serde_json = { version = "1.0", optional = true }
4848
wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.97", default-features = false }
4949

50-
[target.'cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"), target_feature = "atomics"))'.dependencies]
51-
wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.97", default-features = false, features = [
52-
"atomics",
53-
] }
54-
55-
[target.'cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"), wasm_bindgen_unstable_test_coverage))'.dependencies]
56-
wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.97", default-features = false, features = [
57-
"coverage",
58-
] }
59-
60-
[target.'cfg(__wasm_bindgen_resolver_1)'.dependencies]
61-
wasm-bindgen-macro = { path = "crates/macro", version = "=0.2.97", default-features = false, features = [
62-
"xxx_resolver_1",
63-
] }
64-
6550
[dev-dependencies]
6651
wasm-bindgen-test = { path = 'crates/test' }
6752

@@ -90,7 +75,7 @@ too_many_arguments = "allow"
9075
type_complexity = "allow"
9176

9277
[workspace]
93-
exclude = ["crates/msrv"]
78+
exclude = ["crates/msrv/resolver", "crates/msrv/lib", "crates/msrv/cli"]
9479
members = [
9580
"benchmarks",
9681
"crates/cli",

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ Libraries that are released on [crates.io](https://crates.io) have a MSRV of v1.
114114

115115
CLI tools and their corresponding support libraries have a MSRV of v1.76. Changes to the MSRV will be accompanied by a patch version bump.
116116

117-
[Feature resolver version 2](https://doc.rust-lang.org/1.83.0/cargo/reference/resolver.html#feature-resolver-version-2) is required.
118-
119117
## License
120118

121119
This project is licensed under either of

crates/backend/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ rust-version = "1.57"
1414
version = "0.2.97"
1515

1616
[features]
17-
atomics = []
18-
coverage = []
1917
default = ["std"]
2018
extra-traits = ["syn/extra-traits"]
2119
spans = []
2220
std = []
23-
xxx_resolver_1 = []
2421

2522
[dependencies]
2623
bumpalo = "3.0.0"
2724
log = "0.4"
28-
once_cell = "1.12"
2925
proc-macro2 = "1.0"
3026
quote = '1.0'
3127
syn = { version = '2.0', features = ['full'] }

crates/backend/src/codegen.rs

+17-44
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ use crate::ast;
22
use crate::encode;
33
use crate::encode::EncodeChunk;
44
use crate::Diagnostic;
5-
use once_cell::sync::Lazy;
65
use proc_macro2::{Ident, Span, TokenStream};
76
use quote::format_ident;
87
use quote::quote_spanned;
98
use quote::{quote, ToTokens};
9+
use std::cell::RefCell;
1010
use std::collections::{HashMap, HashSet};
11-
use std::sync::Mutex;
1211
use syn::parse_quote;
1312
use syn::spanned::Spanned;
1413
use wasm_bindgen_shared as shared;
@@ -224,7 +223,6 @@ impl ToTokens for ast::Struct {
224223
let free_fn = Ident::new(&shared::free_function(&name_str), Span::call_site());
225224
let unwrap_fn = Ident::new(&shared::unwrap_function(&name_str), Span::call_site());
226225
let wasm_bindgen = &self.wasm_bindgen;
227-
let maybe_no_coverage = coverage();
228226
(quote! {
229227
#[automatically_derived]
230228
impl #wasm_bindgen::describe::WasmDescribe for #name {
@@ -296,11 +294,11 @@ impl ToTokens for ast::Struct {
296294
#[cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))]
297295
#[automatically_derived]
298296
const _: () = {
297+
#wasm_bindgen::__wbindgen_coverage! {
299298
#[no_mangle]
300299
#[doc(hidden)]
301300
// `allow_delayed` is whether it's ok to not actually free the `ptr` immediately
302301
// if it's still borrowed.
303-
#maybe_no_coverage
304302
pub unsafe extern "C" fn #free_fn(ptr: u32, allow_delayed: u32) {
305303
use #wasm_bindgen::__rt::alloc::rc::Rc;
306304

@@ -315,6 +313,7 @@ impl ToTokens for ast::Struct {
315313
let _ = <#name as #wasm_bindgen::convert::FromWasmAbi>::from_abi(ptr);
316314
}
317315
}
316+
}
318317
};
319318

320319
#[automatically_derived]
@@ -476,7 +475,6 @@ impl ToTokens for ast::StructField {
476475
quote! { assert_copy::<#ty>() }
477476
};
478477
let maybe_assert_copy = respan(maybe_assert_copy, ty);
479-
let maybe_no_coverage = coverage();
480478

481479
// Split this out so that it isn't affected by `quote_spanned!`.
482480
//
@@ -495,9 +493,9 @@ impl ToTokens for ast::StructField {
495493
(quote! {
496494
#[automatically_derived]
497495
const _: () = {
496+
#wasm_bindgen::__wbindgen_coverage! {
498497
#[cfg_attr(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")), no_mangle)]
499498
#[doc(hidden)]
500-
#maybe_no_coverage
501499
pub unsafe extern "C" fn #getter(js: u32)
502500
-> #wasm_bindgen::convert::WasmRet<<#ty as #wasm_bindgen::convert::IntoWasmAbi>::Abi>
503501
{
@@ -512,6 +510,7 @@ impl ToTokens for ast::StructField {
512510
let val = #val;
513511
<#ty as IntoWasmAbi>::into_abi(val).into()
514512
}
513+
}
515514
};
516515
})
517516
.to_tokens(tokens);
@@ -537,9 +536,9 @@ impl ToTokens for ast::StructField {
537536
#[cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))]
538537
#[automatically_derived]
539538
const _: () = {
539+
#wasm_bindgen::__wbindgen_coverage! {
540540
#[no_mangle]
541541
#[doc(hidden)]
542-
#maybe_no_coverage
543542
pub unsafe extern "C" fn #setter(
544543
js: u32,
545544
#(#args,)*
@@ -553,6 +552,7 @@ impl ToTokens for ast::StructField {
553552
let val = <#ty as FromWasmAbi>::from_abi(val);
554553
(*js).borrow_mut().#rust_name = val;
555554
}
555+
}
556556
};
557557
})
558558
.to_tokens(tokens);
@@ -788,23 +788,22 @@ impl TryToTokens for ast::Export {
788788
quote! {}
789789
};
790790

791-
let maybe_no_coverage = coverage();
792-
793791
(quote! {
794792
#[automatically_derived]
795793
const _: () = {
794+
#wasm_bindgen::__wbindgen_coverage! {
796795
#(#attrs)*
797796
#[cfg_attr(
798797
all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")),
799798
export_name = #export_name,
800799
)]
801-
#maybe_no_coverage
802800
pub unsafe extern "C" fn #generated_name(#(#args),*) -> #wasm_bindgen::convert::WasmRet<#projection::Abi> {
803801
#start_check
804802

805803
let #ret = #call;
806804
#convert_ret
807805
}
806+
}
808807
};
809808
})
810809
.to_tokens(into);
@@ -1159,8 +1158,6 @@ impl ToTokens for ast::StringEnum {
11591158
let hole = variant_count + 1;
11601159
let attrs = &self.rust_attrs;
11611160

1162-
let maybe_no_coverage = coverage();
1163-
11641161
let invalid_to_str_msg = format!(
11651162
"Converting an invalid string enum ({}) back to a string is currently not supported",
11661163
enum_name
@@ -1247,7 +1244,6 @@ impl ToTokens for ast::StringEnum {
12471244

12481245
#[automatically_derived]
12491246
impl #wasm_bindgen::describe::WasmDescribe for #enum_name {
1250-
#maybe_no_coverage
12511247
fn describe() {
12521248
use #wasm_bindgen::describe::*;
12531249
inform(STRING_ENUM);
@@ -1546,7 +1542,6 @@ impl ToTokens for ast::Enum {
15461542
} else {
15471543
quote! { u32 }
15481544
};
1549-
let maybe_no_coverage = coverage();
15501545
let cast_clauses = self.variants.iter().map(|variant| {
15511546
let variant_name = &variant.name;
15521547
quote! {
@@ -1594,7 +1589,6 @@ impl ToTokens for ast::Enum {
15941589

15951590
#[automatically_derived]
15961591
impl #wasm_bindgen::describe::WasmDescribe for #enum_name {
1597-
#maybe_no_coverage
15981592
fn describe() {
15991593
use #wasm_bindgen::describe::*;
16001594
inform(ENUM);
@@ -1778,20 +1772,9 @@ fn thread_local_import(
17781772
__inner: &_VAL,
17791773
}
17801774
};
1781-
#[cfg(all(not(feature = "std"), not(feature = "atomics")))]
1782-
let inner = quote! {
1783-
static _VAL: #wasm_bindgen::__rt::LazyCell<#actual_ty> = #wasm_bindgen::__rt::LazyCell::new(init);
1784-
#wasm_bindgen::JsThreadLocal {
1785-
__inner: &_VAL,
1786-
}
1787-
};
1788-
#[cfg(all(not(feature = "std"), feature = "atomics"))]
1775+
#[cfg(not(feature = "std"))]
17891776
let inner = quote! {
1790-
#[thread_local]
1791-
static _VAL: #wasm_bindgen::__rt::LazyCell<#actual_ty> = #wasm_bindgen::__rt::LazyCell::new(init);
1792-
#wasm_bindgen::JsThreadLocal {
1793-
__inner: || unsafe { #wasm_bindgen::__rt::LazyCell::force(&_VAL) as *const #actual_ty },
1794-
}
1777+
#wasm_bindgen::__wbindgen_thread_local!(#wasm_bindgen, #actual_ty)
17951778
};
17961779

17971780
quote! {
@@ -1847,20 +1830,16 @@ impl<T: ToTokens> ToTokens for Descriptor<'_, T> {
18471830
// It's up to the descriptors themselves to ensure they have unique
18481831
// names for unique items imported, currently done via `ShortHash` and
18491832
// hashing appropriate data into the symbol name.
1850-
static DESCRIPTORS_EMITTED: Lazy<Mutex<HashSet<String>>> = Lazy::new(Default::default);
1833+
thread_local! {
1834+
static DESCRIPTORS_EMITTED: RefCell<HashSet<String>> = RefCell::default();
1835+
}
18511836

18521837
let ident = self.ident;
18531838

1854-
if !DESCRIPTORS_EMITTED
1855-
.lock()
1856-
.unwrap()
1857-
.insert(ident.to_string())
1858-
{
1839+
if !DESCRIPTORS_EMITTED.with(|list| list.borrow_mut().insert(ident.to_string())) {
18591840
return;
18601841
}
18611842

1862-
let maybe_no_coverage = coverage();
1863-
18641843
let name = Ident::new(&format!("__wbindgen_describe_{}", ident), ident.span());
18651844
let inner = &self.inner;
18661845
let attrs = &self.attrs;
@@ -1869,16 +1848,17 @@ impl<T: ToTokens> ToTokens for Descriptor<'_, T> {
18691848
#[cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))]
18701849
#[automatically_derived]
18711850
const _: () = {
1851+
#wasm_bindgen::__wbindgen_coverage! {
18721852
#(#attrs)*
18731853
#[no_mangle]
18741854
#[doc(hidden)]
1875-
#maybe_no_coverage
18761855
pub extern "C" fn #name() {
18771856
use #wasm_bindgen::describe::*;
18781857
// See definition of `link_mem_intrinsics` for what this is doing
18791858
#wasm_bindgen::__rt::link_mem_intrinsics();
18801859
#inner
18811860
}
1861+
}
18821862
};
18831863
})
18841864
.to_tokens(tokens);
@@ -1963,10 +1943,3 @@ fn respan(input: TokenStream, span: &dyn ToTokens) -> TokenStream {
19631943
}
19641944
new_tokens.into_iter().collect()
19651945
}
1966-
1967-
fn coverage() -> Option<TokenStream> {
1968-
#[cfg(all(not(feature = "xxx_resolver_1"), feature = "coverage"))]
1969-
return Some(quote! { #[coverage(off)] });
1970-
#[cfg(any(feature = "xxx_resolver_1", not(feature = "coverage")))]
1971-
None
1972-
}

crates/macro-support/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ rust-version = "1.57"
1414
version = "0.2.97"
1515

1616
[features]
17-
atomics = ["wasm-bindgen-backend/atomics"]
18-
coverage = ["wasm-bindgen-backend/coverage"]
1917
default = ["std"]
2018
extra-traits = ["syn/extra-traits"]
2119
spans = ["wasm-bindgen-backend/spans"]
2220
std = ["wasm-bindgen-backend/std"]
2321
strict-macro = []
24-
xxx_resolver_1 = ["wasm-bindgen-backend/xxx_resolver_1"]
2522

2623
[dependencies]
2724
proc-macro2 = "1.0"

crates/macro/Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ version = "0.2.97"
1717
proc-macro = true
1818

1919
[features]
20-
atomics = ["wasm-bindgen-macro-support/atomics"]
21-
coverage = ["wasm-bindgen-macro-support/coverage"]
2220
default = ["std"]
2321
spans = ["wasm-bindgen-macro-support/spans"]
2422
std = ["wasm-bindgen-macro-support/std"]
2523
strict-macro = ["wasm-bindgen-macro-support/strict-macro"]
2624
xxx_debug_only_print_generated_code = []
27-
xxx_resolver_1 = ["wasm-bindgen-macro-support/xxx_resolver_1"]
2825

2926
[dependencies]
3027
quote = "1.0"

0 commit comments

Comments
 (0)