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

ICE on roman numeral macro example #63536

Closed
ghost opened this issue Aug 13, 2019 · 1 comment
Closed

ICE on roman numeral macro example #63536

ghost opened this issue Aug 13, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 13, 2019

Description of Problem

I'm trying to run the roman numeral compiler plugin code in the documentation (here). The compiler panics with this error:

thread 'rustc' panicked at 'cannot access a scoped thread local variable without calling `set` first', /Users/vsts/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:168:9

Code to Reproduce

My code is in this repo: github.com/mgoelzer/rust-macros-roman

Expected vs Actual Behavior

I run cargo build from the root of that repo. I expect the code to compile without errors.

Instead, the compiler panics like this:

$ cargo build
   Compiling roman-test v0.1.0 (/Users/mwg/code/rust-macros-roman-numerals/roman-test)
thread 'rustc' panicked at 'cannot access a scoped thread local variable without calling `set` first', /Users/vsts/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:168:9
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.38.0-nightly (b0e40bfba 2019-08-02) running on x86_64-apple-darwin

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

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

error: Could not compile `roman-test`.

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

Meta

$ rustc --version --verbose
rustc 1.38.0-nightly (b0e40bfba 2019-08-02)
binary: rustc
commit-hash: b0e40bfba44836ad30051ffb077c1cfc5bf4a59f
commit-date: 2019-08-02
host: x86_64-apple-darwin
release: 1.38.0-nightly
LLVM version: 9.0
$ cargo --version --verbose
cargo 1.38.0-nightly (26092da33 2019-07-31)
release: 1.38.0
commit-hash: 26092da337b948719549cd5ed3d1051fd847afd7
commit-date: 2019-07-31

Backtrace

$ RUST_BACKTRACE=1 cargo build
   Compiling roman-test v0.1.0 (/Users/mwg/code/rust-macros-roman-numerals/roman-test)
thread 'rustc' panicked at 'cannot access a scoped thread local variable without calling `set` first', /Users/vsts/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:168:9
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: std::panicking::begin_panic
   5: scoped_tls::ScopedKey<T>::with
   6: core::ptr::real_drop_in_place
   7: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   8: __rustc_plugin_registrar_7649699624c1ca169dcc2215a85ad889__
             at roman/src/lib.rs:60
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: <unknown>
query stack during panic:
end of query stack

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.38.0-nightly (b0e40bfba 2019-08-02) running on x86_64-apple-darwin

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

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

error: Could not compile `roman-test`.

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

Related Issues

Searching in Google, another issue with the same error is #53469

#27271 is another user trying to compile the roman numeral example, but his problem is different.

@petrochenkov
Copy link
Contributor

Duplicate of #62717.

The problem can be solved by linking to rustc_driver (extern crate rustc_driver;) from the crate that defines the plugin.
#62727 is currently trying to make sure that rustc_driver is always linked.

Note that #[plugin] in general is deprecated, and the preferred way to solve problems like implementing roman numerals is using stable proc_macro interface.

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

1 participant