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

Rust ICE when attribute is escaped like r#type #743

Closed
ethanhs opened this issue Jan 23, 2020 · 4 comments · Fixed by #745
Closed

Rust ICE when attribute is escaped like r#type #743

ethanhs opened this issue Jan 23, 2020 · 4 comments · Fixed by #745

Comments

@ethanhs
Copy link
Contributor

ethanhs commented Jan 23, 2020

💥 Reproducing

If you have code like

#[pyclass]
struct Test {
    #[pyo3(get, set)]
    r#type: i64
}

Rust ICEs:

  Compiling twitter v0.1.0 (C:\Users\ethanhs\abserde\build\abserde\twitter)
thread 'rustc' panicked at '`"set_r#type"` is not a valid identifier', src\librustc_expand\proc_macro_server.rs:333:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0-nightly (b5a3341f1 2020-01-20) running on x86_64-pc-windows-msvc

note: compiler flags: -C opt-level=3 -C lto -C codegen-units=1 -C target-cpu=native --crate-type cdylib

note: some of the compiler flags provided by cargo are hidden

error: could not compile `twitter`.

To learn more, run the command again with --verbose.
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit code: 101": `cargo rustc --message-format json --manifest-path Cargo.toml --lib --release --`

🔗 Found pyo3 bindings
🐍 Found CPython 3.7 at C:\Users\ethanhs\AppData\Local\pypoetry\Cache\virtualenvs\abserde-1LDqkpmO-py3.7\Scripts\python.exe
error: custom attribute panicked
   --> src\lib.rs:484:1
    |
484 | #[pyclass(dict)]
    | ^^^^^^^^^^^^^^^^
    |
    = help: message: `"set_r#type"` is not a valid identifier


error: aborting due to previous error

It seems that it can't handle identifiers like set_r#type. I will report the ICE upstream but I think pyo3 should be able to support escaped keywords as attributes.

ethanhs added a commit to ethanhs/abserde that referenced this issue Jan 23, 2020
This doesn't work exactly because of pyo3 get/set breaks this.
See PyO3/pyo3#743
@davidhewitt
Copy link
Member

Thanks, does indeed look like a bug in our proc macro code. I'll push a fix soon.

@ethanhs
Copy link
Contributor Author

ethanhs commented Jan 23, 2020

That would great! Thanks.

Do you know if it will make it into 0.9.0? I'm currently pulling from master but I'd like to use a release :)

@davidhewitt
Copy link
Member

davidhewitt commented Jan 23, 2020

That would be one for @kngwyu. They're quite busy atm so I'm not sure exactly when they plan to release 0.9.0.

I'm expecting to push the fix by the end of the weekend, which I would guess is before the release is done.

@kngwyu
Copy link
Member

kngwyu commented Jan 23, 2020

@ethanhs
Thank you for reporting that!
@davidhewitt
Thank you for the fix!

Do you know if it will make it into 0.9.0? I'm currently pulling from master but I'd like to use a release :)

0.9.0-alpha.1 is already released(just in case you didn't notice it...), but for non-alpha release, we have a milestone.

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

Successfully merging a pull request may close this issue.

3 participants