Skip to content
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

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

Closed
Easyoakland opened this issue Jul 22, 2023 · 6 comments · Fixed by #15357
Labels
A-macro macro expansion C-bug Category: bug

Comments

@Easyoakland
Copy link

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

@Easyoakland Easyoakland added the C-bug Category: bug label Jul 22, 2023
@lnicola lnicola added the A-ty type system / type inference / traits / method resolution label Jul 22, 2023
@lowr lowr added A-macro macro expansion and removed A-ty type system / type inference / traits / method resolution labels Jul 24, 2023
@Ivanbeethoven
Copy link

I meet the same error output with yours. I work in the windows-wsl, ubuntu20.04-LST.

  • rust-analyzer - v0.4.1600
  • rustc - rustc 1.69.0 (84c898d65 2023-04-16)

I really need a convenient solution for now. TAT
image

@lnicola
Copy link
Member

lnicola commented Jul 25, 2023

Minimized:

pub fn astar(
    neighbor_edge_weight: impl Fn() ->> i32,
)
where
    i32: Eq,
{
}

@lnicola
Copy link
Member

lnicola commented Jul 25, 2023

@Ivanbeethoven does your code compile? The report is for code with a typo (there's no extra > in the repository, but the original description indicates there should be one).

@Ivanbeethoven
Copy link

My code can be successfully compiled, but it keeps outputting errors. I changed to vscode under Windows, and the same code does not output errors when using plugins.
The code prompt function has also failed.
The Tooltip always pops up in the lower right corner of the interface.
image

@lnicola
Copy link
Member

lnicola commented Jul 25, 2023

@Ivanbeethoven can you try to minimize it? It's probably something in the file you're looking at, you can start by removing large chunks of code until it stops crashing.

@Ivanbeethoven
Copy link

Ivanbeethoven commented Jul 25, 2023

ok.
I have tried, but this matter is not easy. Fortunately, I will not encounter such issues on the Windows version.
thank u anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants