Skip to content

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

Closed
@ZhangZhuoSJTU

Description

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.

Metadata

Assignees

No one assigned

    Labels

    A-HIRArea: The high-level intermediate representation (HIR)C-bugCategory: This is a bug.F-extended_key_value_attributes`#![feature(extended_key_value_attributes)]I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions