Skip to content

thread 'Worker' panicked at 'called Option::unwrap() on a None value', crates\hir-expand\src\db.rs:540:51 #15327

Closed
@Easyoakland

Description

@Easyoakland

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
rust-analyzer version: 0.3.1591-standalone (d824511 2023-07-16)
rustc version: (eg. output of rustc -V)
rustc 1.71.0 (8ede3aae2 2023-07-12)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
I have a repo that consistently crashes with this error (in vscode in windows). It continues to crash on reload. So consistently that it is very annoying. Open the repo in the rust-analyzer-crash branch as a folder/workspace and then open advent_lib/src/algorithms.rs. Immediate and repeated:

thread 'Worker' panicked at 'called `Option::unwrap()` on a `None` value', crates\hir-expand\src\db.rs:540:51
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library\std\src\panicking.rs:593
   1: core::panicking::panic_fmt
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library\core\src\panicking.rs:67
   2: core::panicking::panic
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library\core\src\panicking.rs:117
   3: <hir_expand::db::MacroExpandQuery as salsa::plumbing::QueryFunction>::execute
   4: salsa::runtime::Runtime::execute_query_implementation
   5: core::ptr::drop_in_place<salsa::derived::slot::Memo<hir_expand::db::MacroArgNodeQuery>>
   6: salsa::derived::slot::Slot<Q,MP>::read
   7: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
   8: <DB as hir_expand::db::ExpandDatabase>::macro_expand
   9: <hir_expand::db::ParseMacroExpansionQuery as salsa::plumbing::QueryFunction>::execute
  10: salsa::runtime::Runtime::execute_query_implementation
  11: core::ptr::drop_in_place<salsa::derived::slot::Memo<hir_expand::db::MacroArgNodeQuery>>
  12: salsa::derived::slot::Slot<Q,MP>::read
  13: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  14: <DB as hir_expand::db::ExpandDatabase>::parse_macro_expansion
  15: salsa::runtime::Runtime::execute_query_implementation
  16: core::ptr::drop_in_place<salsa::derived::slot::Memo<hir_expand::db::MacroArgNodeQuery>>
  17: salsa::derived::slot::Slot<Q,MP>::read
  18: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  19: <DB as hir_expand::db::ExpandDatabase>::parse_macro_expansion_error
  20: hir_def::nameres::collector::DefCollector::record_resolved_import
  21: hir_def::nameres::collector::collect_defs
  22: <hir_def::db::CrateDefMapQueryQuery as salsa::plumbing::QueryFunction>::execute
  23: salsa::runtime::Runtime::execute_query_implementation
  24: core::ptr::drop_in_place<salsa::derived::slot::Memo<hir_def::db::UnionDataWithDiagnosticsQuery>>
  25: salsa::derived::slot::Slot<Q,MP>::read
  26: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  27: <DB as hir_def::db::DefDatabase>::crate_def_map_query
  28: hir_def::db::crate_def_map_wait
  29: hir::semantics::source_to_def::SourceToDefCtx::file_to_def
  30: hir::semantics::source_to_def::SourceToDefCtx::find_container
  31: hir::semantics::SemanticsImpl::analyze_impl
  32: hir::semantics::SemanticsImpl::scope
  33: ide::inlay_hints::inlay_hints
  34: std::panicking::try
  35: rust_analyzer::handlers::request::handle_inlay_hints
  36: core::ops::function::FnOnce::call_once{{vtable.shim}}

It does stop crashing if the error (extra > on line 21 col 39) is removed.

@lowr has indicated this is not the same as #13531

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions