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

Proc macro attribute with raw identifier causes ICE #71339

Closed
ethanhs opened this issue Apr 20, 2020 · 2 comments
Closed

Proc macro attribute with raw identifier causes ICE #71339

ethanhs opened this issue Apr 20, 2020 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ethanhs
Copy link

ethanhs commented Apr 20, 2020

Code

I have created the following repository with a minimal as I could think of reproduction of the ICE:

https://github.com/ethanhs/Rust-ICE-repro

This was discovered in the wild a while ago (I wanted to reduce it before reporting, sorry for the delay). PyO3/pyo3#743

Meta

I used the latest nightly version of rustc

rustc --version --verbose:

rustc 1.44.0-nightly (dbf8b6bf1 2020-04-19)
binary: rustc
commit-hash: dbf8b6bf116c7bece2987ff4bd2792f008a6ee77
commit-date: 2020-04-19
host: x86_64-pc-windows-msvc
release: 1.44.0-nightly
LLVM version: 9.0

Error output

   Compiling ex v0.1.0 (C:\Users\ethanhs\proctest\ex)
   Compiling proctest v0.1.0 (C:\Users\ethanhs\proctest)
thread 'rustc' panicked at '`"set_r#raw"` is not a valid identifier', src\librustc_expand\proc_macro_server.rs:329: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.44.0-nightly (dbf8b6bf1 2020-04-19) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: custom attribute panicked
 --> src\main.rs:2:1
  |
2 | #[hello]
  | ^^^^^^^^
  |
  = help: message: `"set_r#raw"` is not a valid identifier

error: aborting due to previous error

error: could not compile `proctest`.

To learn more, run the command again with --verbose.
Backtrace

   Compiling proctest v0.1.0 (C:\Users\ethanhs\proctest)
thread 'rustc' panicked at '`"set_r#raw"` is not a valid identifier', src\librustc_expand\proc_macro_server.rs:329:13
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSlice as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: rust_begin_unwind
   8: std::panicking::begin_panic_fmt
   9: rustc_expand::expand::AstFragment::make_variants
  10: <rustc_expand::config::StripUnconfigured as rustc_ast::mut_visit::MutVisitor>::visit_fn_decl
  11: <rustc_expand::mbe::TokenTree as core::fmt::Debug>::fmt
  12: <rustc_expand::mbe::TokenTree as core::fmt::Debug>::fmt
  13: proc_macro::bridge::scoped_cell::ScopedCell::replace
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\/src\libproc_macro\bridge\scoped_cell.rs:74
  14: proc_macro::bridge::client::{{impl}}::with::{{closure}}
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\/src\libproc_macro\bridge\client.rs:284
  15: std::thread::local::LocalKey::try_with
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\src\libstd\thread\local.rs:263
  16: std::thread::local::LocalKey::with
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\src\libstd\thread\local.rs:239
  17: proc_macro::bridge::client::BridgeState::with
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\/src\libproc_macro\bridge\client.rs:283
  18: proc_macro::bridge::Bridge::with
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\/src\libproc_macro\bridge\client.rs:314
  19: proc_macro::bridge::client::Ident::new
             at /rustc/dbf8b6bf116c7bece2987ff4bd2792f008a6ee77\/src\libproc_macro\bridge\client.rs:230
  20: ex::hello
             at .\ex\src\lib.rs:5
  21: core::ops::function::FnOnce::call_once<fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream,(proc_macro::TokenStream, proc_macro::TokenStream)>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libcore\ops\function.rs:232
  22: proc_macro::bridge::client::{{impl}}::expand2::run::{{closure}}<fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:409
  23: proc_macro::bridge::client::run_client::{{closure}}::{{closure}}<(proc_macro::bridge::client::TokenStream, proc_macro::bridge::client::TokenStream),proc_macro::bridge::client
::TokenStream,closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:362
  24: proc_macro::bridge::scoped_cell::{{impl}}::set::{{closure}}<proc_macro::bridge::client::BridgeStateL,(),closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\scoped_cell.rs:79
  25: proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>::replace<proc_macro::bridge::client::BridgeStateL,(),closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\scoped_cell.rs:74
  26: proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>::set<proc_macro::bridge::client::BridgeStateL,(),closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\scoped_cell.rs:79
  27: proc_macro::bridge::client::{{impl}}::enter::{{closure}}<(),closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:310
  28: std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>>::try_with<proc_macro::bridge::scoped_cell::ScopedCell<proc
_macro::bridge::client::BridgeStateL>,closure-1,()>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\thread\local.rs:263
  29: std::thread::local::LocalKey<proc_macro::bridge::scoped_cell::ScopedCell<proc_macro::bridge::client::BridgeStateL>>::with<proc_macro::bridge::scoped_cell::ScopedCell<proc_mac
ro::bridge::client::BridgeStateL>,closure-1,()>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\thread\local.rs:239
  30: proc_macro::bridge::Bridge::enter<(),closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:310
  31: proc_macro::bridge::client::run_client::{{closure}}<(proc_macro::bridge::client::TokenStream, proc_macro::bridge::client::TokenStream),proc_macro::bridge::client::TokenStream
,closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:355
  32: std::panic::{{impl}}::call_once<(),closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:318
  33: std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,()>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:331
  34: std::panicking::begin_panic::{{impl}}::take_box<str*>
  35: std::panicking::try<(),std::panic::AssertUnwindSafe<closure-0>>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:274
  36: std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,()>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:394
  37: proc_macro::bridge::client::run_client<(proc_macro::bridge::client::TokenStream, proc_macro::bridge::client::TokenStream),proc_macro::bridge::client::TokenStream,closure-0>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:354
  38: proc_macro::bridge::client::{{impl}}::expand2::run<fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream>
             at C:\Users\ethanhs\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libproc_macro\bridge\client.rs:408
  39: <rustc_expand::mbe::TokenTree as core::fmt::Debug>::fmt
  40: <rustc_expand::proc_macro::AttrProcMacro as rustc_expand::base::AttrProcMacro>::expand
  41: rustc_expand::expand::MacroExpander::fully_expand_fragment
  42: rustc_expand::expand::MacroExpander::expand_crate
  43: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::compile
  44: rustc_interface::passes::BoxedResolver::to_resolver_outputs
  45: rustc_interface::passes::BoxedResolver::complete
  46: rustc_interface::passes::BoxedResolver::complete
  47: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  48: rustc_interface::queries::Queries::expansion
  49: rustc_driver::pretty::print_after_hir_lowering
  50: <rustc_typeck::collect::ItemCtxt as rustc_typeck::astconv::AstConv>::re_infer
  51: <rustc_typeck::collect::ItemCtxt as rustc_typeck::astconv::AstConv>::re_infer
  52: <rustc_ast_passes::node_count::NodeCounter as rustc_ast::visit::Visitor>::visit_attribute
  53: rustc_driver::pretty::print_after_hir_lowering
  54: ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core
..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17
  55: std::sys::windows::thread::Thread::new
  56: BaseThreadInitThunk
  57: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.44.0-nightly (dbf8b6bf1 2020-04-19) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
end of query stack
error: custom attribute panicked
 --> src\main.rs:2:1
  |
2 | #[hello]
  | ^^^^^^^^
  |
  = help: message: `"set_r#raw"` is not a valid identifier

error: aborting due to previous error

error: could not compile `proctest`.

To learn more, run the command again with --verbose.

@ethanhs ethanhs added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 20, 2020
@petrochenkov
Copy link
Contributor

Duplicate of #59998.

@ethanhs
Copy link
Author

ethanhs commented Apr 20, 2020

Thanks, sorry for the dupe :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants