Skip to content

'called Option::unwrap() on a None value' when editing KAS GUI applications #10386

@nyanpasu64

Description

@nyanpasu64

When I clone kas (https://github.com/kas-gui/kas) and open an example file, every edit or lookup triggers a rust-analyzer panic:

Output log and stack trace
Panic context:
> 
version: 009e6ceb1 2021-09-27 stable
request: textDocument/semanticTokens/full/delta SemanticTokensDeltaParams {
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/nyanpasu64/code/kas/examples/counter.rs",
            query: None,
            fragment: None,
        },
    },
    previous_result_id: "2",
}

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/salsa-0.17.0-pre.1/src/runtime.rs:324:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: salsa::runtime::Runtime::report_unexpected_cycle
   4: salsa::derived::slot::Slot<Q,MP>::read
   5: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
   6: <DB as hir_ty::db::HirDatabase>::generic_predicates_for_param
   7: hir_ty::lower::TyLoweringContext::lower_ty_relative_path
   8: hir_ty::lower::TyLoweringContext::lower_partly_resolved_path
   9: hir_ty::lower::TyLoweringContext::lower_ty_ext
  10: hir_ty::lower::TyLoweringContext::substs_from_path_segment
  11: hir_ty::lower::TyLoweringContext::lower_trait_ref_from_path
  12: hir_ty::lower::TyLoweringContext::lower_type_bound
  13: hir_ty::lower::TyLoweringContext::lower_where_predicate
  14: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  15: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  16: hir_ty::lower::generic_predicates_for_param_query
  17: salsa::runtime::Runtime::execute_query_implementation
  18: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  19: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  20: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  21: salsa::derived::slot::MemoRevisions::validate_memoized_value
  22: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  23: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  24: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  25: salsa::derived::slot::MemoRevisions::validate_memoized_value
  26: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  27: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  28: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  29: salsa::derived::slot::MemoRevisions::validate_memoized_value
  30: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  31: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  32: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  33: salsa::derived::slot::MemoRevisions::validate_memoized_value
  34: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  35: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  36: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  37: salsa::derived::slot::MemoRevisions::validate_memoized_value
  38: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  39: salsa::derived::slot::Slot<Q,MP>::read
  40: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  41: <DB as hir_ty::db::HirDatabase>::infer_query
  42: hir_ty::db::infer_wait
  43: hir::source_analyzer::SourceAnalyzer::new_for_body
  44: hir::semantics::SemanticsImpl::analyze_impl
  45: ide_db::defs::NameClass::classify
  46: ide::syntax_highlighting::highlight::element
  47: ide::syntax_highlighting::traverse
  48: ide::syntax_highlighting::highlight
  49: std::panicking::try
  50: rust_analyzer::handlers::handle_semantic_tokens_full_delta
  51: std::panicking::try
  52: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 12:41:02 AM] Request textDocument/semanticTokens/full/delta failed.
  Message: server panicked: called `Option::unwrap()` on a `None` value
  Code: -32603 

I think this is related to #5001. I think kas is valid code, but I'm getting report_unexpected_cycle crashes anyway.

The error goes away when I disable rust-analyzer.procMacro.enable or remove all methods from the make_widget! { impl { block.

Currently on vscode 1.60.2 and rust-analyzer extension v0.2.760 (both latest I think).
rust-analyzer version: 009e6ce 2021-09-27 stable

Is there anything that needs to be done to expand macros or minify the test case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionBroken WindowBugs / technical debt to be addressed immediatelyC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions