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

js-sys fails to build with nightlies on and after 2020-05-25 #2158

Closed
rrbutani opened this issue May 26, 2020 · 5 comments · Fixed by #2159
Closed

js-sys fails to build with nightlies on and after 2020-05-25 #2158

rrbutani opened this issue May 26, 2020 · 5 comments · Fixed by #2159
Labels

Comments

@rrbutani
Copy link
Contributor

Describe the Bug

js-sys fails to build with rustc nightlies on and after nightly-2020-05-25.

error: return value of constructor must be a bare path
    --> <snipped>/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/js-sys-0.3.39/src/lib.rs:4795:13
     |
4795 | /             /// The
4796 | |             #[doc = $ctor]
4797 | |             /// constructor creates an array of unsigned 8-bit integers.
4798 | |             ///
...    |
4802 | |             #[wasm_bindgen(constructor)]
4803 | |             pub fn new(constructor_arg: &JsValue) -> $name;
     | |___________________________________________________________^
...
4999 | / arrays! {
5000 | |     /// `Int8Array()`
5001 | |     /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
5002 | |     Int8Array: i8,
...    |
5034 | |     Float64Array: f64,
5035 | | }
     | |_- in this macro invocation
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: return value of constructor must be a bare path
    --> <snipped>/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/js-sys-0.3.39/src/lib.rs:4805:13
     |
4805 | /             /// An
4806 | |             #[doc = $ctor]
4807 | |             /// which creates an array with an internal buffer large
4808 | |             /// enough for `length` elements.
...    |
4813 | |             #[wasm_bindgen(constructor)]
4814 | |             pub fn new_with_length(length: u32) -> $name;
     | |_________________________________________________________^

Steps to Reproduce

  1. Build js-sys with a toolchain newer than nightly-2020-05-24:
  • rustup install nightly-2020-05-25
  • cargo +nightly-2020-05-25 build -p js-sys

Expected Behavior

The build succeeds!

Actual Behavior

The build does not succeed.

Additional Context

Running cargo-bisect-rustc pins it down to this rollup and from there it's fairly straightforward to pick out rust-lang/rust#72388.

Here's the output from cargo-bisect-rustc if it helps:

bisected with cargo-bisect-rustc v0.5.1

searched nightlies: from nightly-2020-05-24 to nightly-2020-05-26
regressed nightly: nightly-2020-05-25
searched commits: from rust-lang/rust@8970e8b to rust-lang/rust@46e85b4
regressed commit: rust-lang/rust@7726070

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc -- check --target x86_64-unknown-linux-gnu 

The cause of this error, as best as I can tell, is that $name in this macro goes from being passed to #[wasm_bindgen] as a syn::Type::Path to being passed in as a syn::Group containing the syn::Type::Path that the macro wants (as in the span that $name is in isn't discarded). wasm_bindgen's parser doesn't know to handle this (here and here) and so we get the errors above.

There's already an issue open in rust-lang/rust for this: rust-lang/rust#72545. For that specific issue the crate in question was using proc-macro-hack but as shown the same change can also break proc macros that don't use it.

@alexcrichton
Copy link
Contributor

Not actually fixed yet, opened #2161 to track the errors after #2159 landed.

@rrbutani
Copy link
Contributor Author

rrbutani commented May 26, 2020

I opened an issue on syn for the last error: dtolnay/syn#833.

@rrbutani
Copy link
Contributor Author

@alexcrichton the issue was fixed by dtolnay/syn#834; with syn 1.0.27 I no longer get the error (locally).

I think if the CI jobs on #2161 run again things should Just Work.

@alexcrichton
Copy link
Contributor

Awesome, thanks so much for your help here @rrbutani!

@Pauan
Copy link
Contributor

Pauan commented May 27, 2020

(Nice sleuthing by the way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants