rust-lang / rust

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

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs:18:85 #93607

Open That3Percent opened 2 years ago

That3Percent commented 2 years ago

Note: This may have something to do with incremental compilation. I had just moved a struct to another file, and some code which should not have passed cargo check because it referenced that struct by the old path still compiled. Only after I saved the file referencing the invalid path with the fixed path did the panic occur.

Code

This commit: https://github.com/graphprotocol/stable-hash/commit/ea3b6beedfac362f55393004c59ee60e72ee045c

Meta

rustc --version --verbose:

rustc 1.58.0 (02072b482 2022-01-11)
binary: rustc
commit-hash: 02072b482a8b5357f7fb5e5637444ae30e423c40
commit-date: 2022-01-11
host: x86_64-apple-darwin
release: 1.58.0
LLVM version: 13.0.0

Error output

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
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_metadata::creader::CStore as rustc_session::cstore::CrateStore>::def_path_hash_to_def_id
   4: <rustc_middle::ty::context::TyCtxt>::def_path_hash_to_def_id
   5: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id
   6: rustc_query_impl::query_callbacks::adt_def::force_from_dep_node
   7: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
   8: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl::plumbing::QueryCtxt>
  10: rustc_query_system::query::plumbing::ensure_must_run::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, rustc_span::def_id::LocalDefId>
  11: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_liveness, rustc_query_impl::plumbing::QueryCtxt>
  12: <rustc_middle::hir::map::Map>::for_each_module::<rustc_interface::passes::analysis::{closure#1}::{closure#1}::{closure#0}::{closure#0}>
  13: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#1}>
  14: rustc_interface::passes::analysis
  15: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
  16: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  19: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  20: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  21: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  22: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
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.58.0 (02072b482 2022-01-11) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental -C target-cpu=native

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

``` stack backtrace: 0: _rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::panic 3: ::def_path_hash_to_def_id 4: ::def_path_hash_to_def_id 5: as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id 6: rustc_query_impl::query_callbacks::adt_def::force_from_dep_node 7: ::try_force_from_dep_node 8: >::try_mark_previous_green:: 9: >::try_mark_green:: 10: rustc_query_system::query::plumbing::ensure_must_run:: 11: rustc_query_system::query::plumbing::get_query:: 12: ::for_each_module:: 13: ::time::<(), rustc_interface::passes::analysis::{closure#1}> 14: rustc_interface::passes::analysis 15: >::with_task::> 16: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job>::{closure#3}> 17: rustc_query_system::query::plumbing::try_execute_query::>> 18: ::analysis 19: ::enter::> 20: ::enter::, rustc_errors::ErrorReported>> 21: rustc_span::with_source_map::, rustc_interface::interface::create_compiler_and_run, rustc_driver::run_compiler::{closure#1}>::{closure#1}> 22: >::set::, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>> ```

Aaron1011 commented 2 years ago

Are you able to reproduce this after running cargo clean by repeating the modifications and cargo build invocations that you made?

poliorcetics commented 2 years ago

Not author but I encountered this twice already when compiling rust-analyzer. Always with incremental compilation, cleaning and rebuilding fixes the problem

qarmin commented 2 years ago

Looks like duplicate of ~50 other issues - https://github.com/rust-lang/rust/issues?page=1&q=is%3Aissue+is%3Aopen+def_path_hash_to_def_id

Aaron1011 commented 2 years ago

While this issue is related, it might not be a duplicate

gimbling-away commented 2 years ago

Mostly seems like an incremental build problem, yeah -- cargo clean and rebuilding should fix it.

That3Percent commented 2 years ago

Sorry for the belated reply. I'm swamped at work and unable to investigate further. I can confirm though that cleaning and rebuilding did solve the issue.