rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.58k stars 12.48k forks source link

Rustc paniced after enum rename #97906

Closed leakingtapan closed 2 years ago

leakingtapan commented 2 years ago

Code

I have an enum like below

#[derive(Debug)]
pub enum Task {
    WriteFile { digest: Digest, path: PathBuf },

    WriteBlob { digest: Digest, buff: Vec<u8> },
}

I rename the enum to:

#[derive(Debug)]
pub enum WriteTask {
    WriteFile { digest: Digest, path: PathBuf },

    WriteBlob { digest: Digest, buff: Vec<u8> },
}

That's the only change I made. After the rename, I recompiled my code and rustc paniced. See below for stack trace. The panic happens consistently afterwards.

I tried several ways to reproduce the bug:

  1. copy the whole source tree (with the new enum name) to a new cargo project, but this doesn't reproduce
  2. cargo clean and cargo build the problem is gone too.

So I suspect this has something to do with the local build caches regarding the symbol name for Task enum before and after the rename.

Sorry I don't have a way to create a minimum repro for this given the nature of this bug.

Meta

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Error output

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:18:85
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: core::panicking::panic
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:50:5
   3: rustc_metadata::rmeta::decoder::cstore_impl::<impl rustc_session::cstore::CrateStore for rustc_metadata::creader::CStore>::def_path_hash_to_def_id
   4: <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_hash_to_def_id
   5: rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc_middle::ty::context::TyCtxt> for rustc_span::def_id::DefId>::recover
   6: rustc_query_system::query::plumbing::force_query
   7: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
   8: rustc_query_system::query::plumbing::ensure_must_run
   9: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_liveness
  10: rustc_middle::hir::map::Map::for_each_module
  11: rustc_session::utils::<impl rustc_session::session::Session>::time
  12: rustc_interface::passes::analysis
  13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  14: rustc_data_structures::stack::ensure_sufficient_stack
  15: rustc_query_system::query::plumbing::try_execute_query
  16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  17: rustc_interface::passes::QueryContext::enter
  18: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  19: rustc_span::with_source_map
  20: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.57.0 (f1edd0429 2021-11-29) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
warning: `cfs` (bin "casctl") generated 1 warning
error: could not compile `cfs`; 1 warning emitted
Backtrace

``` ```

eggyal commented 2 years ago

@rustbot label +A-incr-comp

JohnTitor commented 2 years ago

Seems you're using an old Rust, and it looks like a duplicate of #94185 and similar issues.

leakingtapan commented 2 years ago

My version is the same as https://github.com/rust-lang/rust/issues/94185 and the exception also looks similar, close this and will upgrade the rust version.