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

ParseSyntaxError in wgpu-native #272

Open
kvark opened this issue Jan 18, 2019 · 4 comments
Open

ParseSyntaxError in wgpu-native #272

kvark opened this issue Jan 18, 2019 · 4 comments

Comments

@kvark
Copy link
Contributor

kvark commented Jan 18, 2019

Repro steps on Linux:

git clone https://github.com/kvark/wgpu -b swap-chain
cd wgpu
RUST_BACKTRACE=1 make

Error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseSyntaxError { crate_name: "wgpu-native", src_path: "", error: Error { start_span: Span, end_span: Span, message: "expected one of: `for`, parentheses, `fn`, `unsafe`, `extern`, identifier, `::`, `<`, square brackets, `*`, `&`, `!`, `impl`, `_`, lifetime" } }', src/libcore/result.rs:997:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   6: rust_begin_unwind
             at src/libstd/panicking.rs:312
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::result::unwrap_failed
             at /rustc/daa53a52a2667533d5fe59bfcc5b8614b79c3d31/src/libcore/macros.rs:16
   9: <core::result::Result<T, E>>::unwrap
             at /rustc/daa53a52a2667533d5fe59bfcc5b8614b79c3d31/src/libcore/result.rs:798
  10: wgpu_bindings::main
             at wgpu-bindings/src/main.rs:35
  11: std::rt::lang_start::{{closure}}
             at /rustc/daa53a52a2667533d5fe59bfcc5b8614b79c3d31/src/libstd/rt.rs:64
  12: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:297
  13: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:92
  14: std::rt::lang_start_internal
             at src/libstd/panicking.rs:276
             at src/libstd/panic.rs:388
             at src/libstd/rt.rs:48
  15: std::rt::lang_start
             at /rustc/daa53a52a2667533d5fe59bfcc5b8614b79c3d31/src/libstd/rt.rs:64
  16: main
  17: __libc_start_main
  18: _start
             at ../sysdeps/x86_64/start.S:120

@grovesNL
Copy link
Contributor

grovesNL commented Jan 18, 2019

I investigated this a bit last night. To get source for parsing, cbindgen runs:

cargo rustc --lib --manifest-path /Users/josh/Projects/wgpu-native/wgpu-native/Cargo.toml -p wgpu-native:0.1.0 -- -Z unstable-options --pretty=expanded

But the output of this command doesn't compile in Rust, because it fails on the $:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=90fb57da21a6a9ef22088c29048bc568

So I don't really expect syn to parse this because it doesn't even compile. It would be useful if somebody could help clarify whether the issue related to the rustc macro expansion, syn, or cbindgen?

@emilio
Copy link
Collaborator

emilio commented Jan 18, 2019

I would expect $crate to be expanded using --pretty=expanded the same way all the other macro $variables are expanded.

@grovesNL
Copy link
Contributor

It seems related to rustc changing behavior for macro expansion between 2018-12-27-fb86d604b and 2018-12-28-60e825389 nightlies.

I have an example here which displays the difference in output https://gist.github.com/grovesNL/5d3ddc7b95c1939be26c64ba09f1ac2f

I also mentioned it on a PR which appears to be related rust-lang/rust#57155

@cathaysia
Copy link

if you print something in macro, then this error will be raised.

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

No branches or pull requests

4 participants