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

thread 'main' panicked at 'expected identifier' #494

Closed
adetaylor opened this issue May 14, 2021 · 4 comments · Fixed by #519
Closed

thread 'main' panicked at 'expected identifier' #494

adetaylor opened this issue May 14, 2021 · 4 comments · Fixed by #519
Labels
bug Something isn't working

Comments

@adetaylor
Copy link
Collaborator

Follow instructions in #468 now that #470 is fixed.

Get

  thread 'main' panicked at 'expected identifier', /Users/adetaylor/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.68/src/parse_quote.rs:96:21
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/42816d61ead7e46d462df997958ccfd514f8c21c/library/std/src/panicking.rs:493:5
     1: std::panicking::begin_panic_fmt
               at /rustc/42816d61ead7e46d462df997958ccfd514f8c21c/library/std/src/panicking.rs:435:5
     2: syn::parse_quote::parse
               at /Users/adetaylor/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.68/src/parse_quote.rs:96:21
     3: autocxx_engine::conversion::codegen_rs::fun_codegen::gen_function
               at /Users/adetaylor/dev/autocxx/engine/src/conversion/codegen_rs/fun_codegen.rs:133:45
     4: autocxx_engine::conversion::codegen_rs::RsCodeGenerator::generate_rs_for_api
               at /Users/adetaylor/dev/autocxx/engine/src/conversion/codegen_rs/mod.rs:424:17
     5: autocxx_engine::conversion::codegen_rs::RsCodeGenerator::rs_codegen::{{closure}}
               at /Users/adetaylor/dev/autocxx/engine/src/conversion/codegen_rs/mod.rs:156:27
     6: core::iter::adapters::map::map_fold::{{closure}}
               at /Users/adetaylor/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:82:28
     7: core::iter::traits::iterator::Iterator::fold
               at /Users/adetaylor/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2147:21
     8: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
               at /Users/adetaylor/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:122:9
     9: core::iter::traits::iterator::Iterator::unzip
               at /Users/adetaylor/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2821:9
    10: autocxx_engine::conversion::codegen_rs::RsCodeGenerator::rs_codegen
               at /Users/adetaylor/dev/autocxx/engine/src/conversion/codegen_rs/mod.rs:152:91
    11: autocxx_engine::conversion::codegen_rs::RsCodeGenerator::generate_rs_code
               at /Users/adetaylor/dev/autocxx/engine/src/conversion/codegen_rs/mod.rs:141:9
    12: autocxx_engine::conversion::BridgeConverter::convert
               at /Users/adetaylor/dev/autocxx/engine/src/conversion/mod.rs:150:26
    13: autocxx_engine::IncludeCppEngine::generate
               at /Users/adetaylor/dev/autocxx/engine/src/lib.rs:389:26
    14: autocxx_engine::parse_file::ParsedFile::resolve_all
               at /Users/adetaylor/dev/autocxx/engine/src/parse_file.rs:178:13
    15: autocxx_engine::builder::build_to_custom_directory
               at /Users/adetaylor/dev/autocxx/engine/src/builder.rs:141:5
    16: autocxx_engine::builder::build
               at /Users/adetaylor/dev/autocxx/engine/src/builder.rs:76:5
    17: autocxx_build::build
               at /Users/adetaylor/dev/autocxx/gen/build/src/lib.rs:37:5
    18: build_script_build::main
               at ./build.rs:21:17
    19: core::ops::function::FnOnce::call_once
               at /Users/adetaylor/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@adetaylor adetaylor added the bug Something isn't working label May 14, 2021
@adetaylor
Copy link
Collaborator Author

This seems to be because there's a function called move

@adetaylor
Copy link
Collaborator Author

Reducing like this, for my records.

nohup ~/autocxx/target/release/autocxx-reduce -h sample.hpp -I . -p 'expected identifier' -d 'generate_all!()' -c-fblocks -k -- --n 64 

@adetaylor
Copy link
Collaborator Author

Minimized test case...

enum

Sigh.

@adetaylor
Copy link
Collaborator Author

It transpires that bindgen already tries hard to avoid this problem, but then we reintroduce it during subsequent autocxx processing.

For functions, we do the right thing. Bindgen generates a function named (for instance) move_ with an original_name attribute of move, which is perfect.

For methods, bindgen generates A_move, and then an impl called move_ which calls A_move. That's where things go wrong. So the fix in #498 should probably be discarded and replaced with one that is simply cleverer when dealing with method names, specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant