-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't emit unexpected cfgs in proc-macros #4284
Conversation
79c6457
to
b650488
Compare
b650488
to
c197908
Compare
AFAIK, this is the kind of cfg that is set globally on the user side, so the warning itself is not something we need to be concerned about except that it will break the build if we deny the warning. Therefore, I wonder if it would be fine to simply allow unexpected_cfg in the generated code. |
Indeed, however this workaround isn't required. In #4306 I simply used something like this: fn coverage() -> Option<TokenStream> {
#[cfg(wasm_bindgen_unstable_test_coverage)]
return Some(quote! { #[coverage(off)] });
#[cfg(not(wasm_bindgen_unstable_test_coverage))]
None
} The problem is not this PR, but #4277. wasm-bindgen/crates/macro/src/lib.rs Lines 27 to 34 in 94b2dc6
Because there is no no_std version of thread_local! we have to use the unstable #[thread_local] feature. This is okay because it only concerns targeting target_feature = "atomics" , which requires nightly to compile to begin with.
There are various possible workarounds:
I don't see a way to make this happen without demoting While I do understand that this is annoying and has affected various projects (surprisingly less than I would have expected), I haven't really seen anybody actually arguing for feature resolver version 1 support. So my impression so far is that this is a CI issue and not a real-world-usage one. Which is still an issue, don't get me wrong! But I decided that so far this seems like a good price to pay. If you do have some input on feature resolver version 1 support, please leave it in #4304. |
Thanks for the clarification.
The problem here is that the proc-macro side does not know which cfg is set on the library side, right? In that case, I think we could use an approach like |
The problem is not the proc-macro output, the problem is setting those unstable features that enable the proc-macro output to compile. These have to be set on the proc-macro itself and at top-level inside the proc-macro crate. These Moving the proc-macro output that requires these unstable features to a macro doesn't help either. The whole workaround is |
allow_internal_unstable is also supported on |
Oh, interesting! I will look into that then. |
Thanks @taiki-e, its works and I'm working on a PR now! |
This issue has been caused by recent changes in nightly: rust-lang/rust#132577.
unexpected_cfg
is now emitted from proc-macros as well.This PR simply avoids this by checking thecfg
check in the macro itself, which is required anyway to enable the corresponding unstable features.This changes when the
#[coverage]
attribute is emitted by adding an internalcoverage
crate feature to the proc-macro and their utility crates. This crate feature is enabled bywasm-bindgen
andwasm-bindgen-test
whencfg(wasm_bindgen_unstable_test_coverage)
is enabled.