You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Visibility tokens on types in extern { ... } blocks are no longer given to procedural macros #69315
I had wasm-bindgen/wasm-bindgen#2009 opened up on a project recently but this looks to be a regression I think. This regressed between nightly-2020-02-19 and nightly-2020-02-20, and bisecting further by commit reveals #69271 as the culprit. I'm not sure which of the PRs in that rollup though are the culprit here.
This can be reproduced by running cargo check from the crates/js-sys folder in the wasm-bindgen repository. Unfortunately this one probably isn't super easy to reproduce, so I'm hoping that someone more knowledgeable can hopefully take a look at this and have a better idea about what's going on.
There's definitely macros going on in #[wasm_bindgen] (the Memory type is synthesized by a macro), which leads me to think that #69211 may be the culprit? (cc @petrochenkov)
Ok, wanted to get a gut-check to see if it was known what was happening. Did some reduction and it looks like the macro no longer gets the pub token for the input type.
externcrate proc_macro;use proc_macro::*;#[proc_macro_attribute]pubfnthe_macro(_attr:TokenStream,body:TokenStream) -> TokenStream{let g = match body.clone().into_iter().nth(2){Some(TokenTree::Group(g)) => g,
_ => panic!("unexpected input"),};let tokens = g.stream().into_iter().collect::<Vec<_>>();assert_eq!(tokens[0].to_string(),"pub");return body;}
it fails with:
$ cargo +nightly build
Compiling wut v0.1.0 (/home/alex/code/wut)
error: custom attribute panicked
--> src/main.rs:2:5
|
2 | #[the_macro::the_macro]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: assertion failed: `(left == right)`
left: `"type"`,
right: `"pub"`
error: aborting due to previous error
error: could not compile `wut`.
To learn more, run the command again with --verbose.
On stable it yields the expected error[E0658]: extern types are experimental error which indicates that the pub token was fed to the macro.
If the #[wasm_bindgen] macro doesn't see the pub token it doesn't make the final result public, which is why the privacy error happened in the first place.
changed the title [-]Macro-expanded public struct no longer considered public[/-][+]Visibility tokens on types in `extern { ... }` blocks are no longer given to procedural macros[/+]on Feb 20, 2020
Activity
petrochenkov commentedon Feb 20, 2020
The large parser PR from @Centril (#69194) could also cause something like this.
petrochenkov commentedon Feb 20, 2020
I'll be able to look at this during the weekend, but it would be great if someone could come up with a minimal reproduction before that.
alexcrichton commentedon Feb 20, 2020
Ok, wanted to get a gut-check to see if it was known what was happening. Did some reduction and it looks like the macro no longer gets the
pubtoken for the input type.Given this input:
then with this macro:
it fails with:
On stable it yields the expected
error[E0658]: extern types are experimentalerror which indicates that thepubtoken was fed to the macro.If the
#[wasm_bindgen]macro doesn't see thepubtoken it doesn't make the final result public, which is why the privacy error happened in the first place.[-]Macro-expanded public struct no longer considered public[/-][+]Visibility tokens on types in `extern { ... }` blocks are no longer given to procedural macros[/+]alexcrichton commentedon Feb 20, 2020
(updated the issue title to reflect what appears to be the actual bug)
Centril commentedon Feb 21, 2020
Fixed by #69334.
Auto merge of #69334 - Centril:nested-item-vis-def, r=petrochenkov
Auto merge of #69334 - Centril:nested-item-vis-def, r=petrochenkov