Skip to content

rustc panics when encountering unknown node (hir_id=HirId { ... }) #81924

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

Closed
ZhangZhuoSJTU opened this issue Feb 9, 2021 · 2 comments
Closed
Labels
A-HIR Area: The high-level intermediate representation (HIR) C-bug Category: This is a bug. F-extended_key_value_attributes `#![feature(extended_key_value_attributes)] glacier ICE tracked in rust-lang/glacier. 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

@ZhangZhuoSJTU
Copy link

I found this also by studying #81886. Currently, I highly suspect they are the same root cause. It would be very appreciated if anyone can shed some light on this.

Code

#![a = {enum b {

playground

Meta

It affects nightly and beta.

rustc --version --verbose:

rustc 1.52.0-nightly (0fc6756b4 2021-02-08)
binary: rustc
commit-hash: 0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a
commit-date: 2021-02-08
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

rustc 1.50.0-beta.9 (2efd07024 2021-02-06)
binary: rustc
commit-hash: 2efd07024a6d1dc0d4ea0a538ddbcec7cc3a4eeb
commit-date: 2021-02-06
host: x86_64-unknown-linux-gnu
release: 1.50.0-beta.9

Error output

➜  playground rustc poc.rs
error: this file contains an unclosed delimiter
 --> test.rs:1:18
  |
1 | #![a = {enum b {
  |   -    -       - ^
  |   |    |       |
  |   |    |       unclosed delimiter
  |   |    unclosed delimiter
  |   unclosed delimiter

error: unexpected token: `{
    enum b { }
}`
 --> test.rs:1:8
  |
1 | #![a = {enum b {
  |        ^^^^^^^^^^

error: cannot find attribute `a` in this scope
 --> test.rs:1:4
  |
1 | #![a = {enum b {
  |    ^

error[E0658]: arbitrary expressions in key-value attributes are unstable
 --> test.rs:1:8
  |
1 | #![a = {enum b {
  |        ^^^^^^^^^^
  |
  = note: see issue #78835 <https://github.com/rust-lang/rust/issues/78835> for more information
  = help: add `#![feature(extended_key_value_attributes)]` to the crate attributes to enable

error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:772:18: expected item, found unknown node (hir_id=HirId { owner: DefId(0:3 ~ test[317d]::b), local_id: 0 })

thread 'rustc' panicked at 'Box<Any>', /rustc/0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.52.0-nightly (0fc6756b4 2021-02-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0658`.
Backtrace

thread 'rustc' panicked at 'Box<Any>', /rustc/0fc6756b42e0556cc2e18079f5fc6b4d58f4e81a/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_middle::hir::map::Map::expect_item
   8: rustc_middle::hir::map::Map::visit_item_likes_in_module
   9: rustc_passes::hir_id_validator::check_crate
  10: rustc_interface::passes::analysis
  11: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::force_query_with_job
  15: rustc_query_system::query::plumbing::get_query_impl
  16: rustc_interface::passes::QueryContext::enter
  17: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  18: rustc_span::with_source_map
  19: rustc_interface::interface::create_compiler_and_run
  20: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@ZhangZhuoSJTU ZhangZhuoSJTU 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 Feb 9, 2021
@jonas-schievink jonas-schievink added the A-HIR Area: The high-level intermediate representation (HIR) label Feb 9, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Feb 11, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 12, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 22, 2021

A reproduction with fewer errors:

#![feature(extended_key_value_attributes)]
#![doc = {enum b {}}]
error: unexpected token: `{
    enum b { }
}`
 --> src/main.rs:2:10
  |
2 | #![doc = {enum b {}}]
  |          ^^^^^^^^^^^

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/hir/map/mod.rs:299:38

@jyn514 jyn514 added the F-extended_key_value_attributes `#![feature(extended_key_value_attributes)] label Mar 22, 2021
@jyn514 jyn514 changed the title rustc panices when encountering unknown node (hir_id=HirId { ... }) rustc panics when encountering unknown node (hir_id=HirId { ... }) Mar 22, 2021
@jyn514
Copy link
Member

jyn514 commented Mar 22, 2021

I think this is a duplicate of #81886.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-HIR Area: The high-level intermediate representation (HIR) C-bug Category: This is a bug. F-extended_key_value_attributes `#![feature(extended_key_value_attributes)] glacier ICE tracked in rust-lang/glacier. 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

4 participants