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

Request textDocument/semanticTokens/full/delta failed. #17017

Closed
CryZe opened this issue Apr 5, 2024 · 11 comments · Fixed by #17160
Closed

Request textDocument/semanticTokens/full/delta failed. #17017

CryZe opened this issue Apr 5, 2024 · 11 comments · Fixed by #17160
Assignees
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug I-panic

Comments

@CryZe
Copy link
Contributor

CryZe commented Apr 5, 2024

I bisected this to: #16805

rust-analyzer version: 0.3.1906-standalone (e4a405f 2024-03-31)
rustc version: rustc 1.77.0 (aedd173a2 2024-03-17)

editor or extension: VSCode

repository link (if public, optional): https://github.com/LiveSplit/livesplit-core

code snippet to reproduce:
I don't have a particular code snippet. I'll try to minimize it soon.

Panic:

thread 'Worker' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\chalk-ir-0.96.0\src\fold\subst.rs:59:22:
mismatched kinds in substitution
stack backtrace:
   0: std::panicking::begin_panic
   1: <std::panicking::begin_panic::Payload<A> as core::panic::PanicPayload>::take_box
   2: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   3: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
   4: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   5: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
   6: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   7: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
   8: chalk_ir::fold::binder_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Binders<T>>::try_fold_with
   9: chalk_ir::Binders<T>::substitute
  10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_assignee_expr
  11: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_assignee_expr
  12: hir_ty::infer::coerce::auto_deref_adjust_steps
  13: hir_ty::infer::coerce::auto_deref_adjust_steps
  14: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_assignee_expr
  15: hir_ty::infer::coerce::auto_deref_adjust_steps
  16: hir_ty::infer::coerce::auto_deref_adjust_steps
  17: hir_ty::infer::infer_query
  18: salsa::Cycle::catch
  19: salsa::derived::slot::Slot<Q,MP>::evict
  20: salsa::derived::slot::Slot<Q,MP>::read
  21: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  22: <DB as hir_ty::db::HirDatabase>::infer
  23: hir::source_analyzer::SourceAnalyzer::new_for_body
  24: hir::semantics::SemanticsImpl::analyze_impl
  25: ide_db::defs::NameClass::classify
  26: ide::syntax_highlighting::highlight::name_like
  27: ide::syntax_highlighting::highlight
  28: ide::syntax_highlighting::highlight
  29: salsa::Cancelled::catch
  30: ide::Analysis::highlight
  31: rust_analyzer::handlers::request::handle_semantic_tokens_full_delta
  32: std::panicking::try
  33: core::ops::function::FnOnce::call_once{{vtable.shim}}
@CryZe CryZe added the C-bug Category: bug label Apr 5, 2024
@lnicola
Copy link
Member

lnicola commented Apr 5, 2024

CC @dfireBird

@dfireBird
Copy link
Contributor

@CryZe
I'll look for anything with lifetimes in that repo but it would be helpful if you could point to a specific file in that repo where the panic happened.

@rustbot claim

@CryZe
Copy link
Contributor Author

CryZe commented Apr 5, 2024

@dfireBird hovering basically anything here in main crashes it immediately: https://github.com/CryZe/livesplit-icon-generator

@dfireBird
Copy link
Contributor

Thanks I was able to get the error now.

@dfireBird
Copy link
Contributor

Thanks to that I was able to create minimal code to reproduce:

pub struct Writer {}

pub trait Value {}

impl Writer {
    pub fn tag_with_content<
        'a,
        I: IntoIterator<Item = (&'a str, impl Value)>,
    >(
        &mut self,
        tag: &str,
        attributes: I,
    ) {
    }
}

fn foo() {
    let writer: Writer = Writer;
    writer.tag_with_content(tag, attributes);
    //^ the r-a panics here while inferring this method call
}

and I also found the reason why the error happens, it's because of improper index set for lifetimes and generics (both have same index when it should be different). Unfortunately, I don't have a solution yet, once I do I'll try to create a PR.

@Edgeworth
Copy link

I am also getting this (pretty much constantly) but my stack is a bit different:

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.96.0/src/lib.rs:1449:33:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/panicking.rs:144:5
   3: core::option::unwrap_failed
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/option.rs:1978:5
   4: <chalk_ir::SubstFolder<I,A> as chalk_ir::fold::TypeFolder<I>>::fold_free_var_lifetime
   5: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   6: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::DynTy<I>>::try_fold_with
   7: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   8: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
   9: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
  10: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  11: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  12: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  13: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
  14: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
  15: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  16: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  17: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  18: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
  19: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
  20: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  21: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  22: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  23: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
  24: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  25: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::QuantifiedWhereClauses<I>>::try_fold_with
  26: chalk_solve::infer::instantiate::<impl chalk_solve::infer::InferenceTable<I>>::instantiate_binders_existentially
  27: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_binders
  28: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  29: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  30: chalk_ir::zip::Zipper::zip_substs
  31: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  32: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  33: chalk_ir::zip::Zipper::zip_substs
  34: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  35: chalk_solve::infer::unify::Unifier<I>::relate_var_ty
  36: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  37: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  38: chalk_ir::zip::Zipper::zip_substs
  39: chalk_ir::_::<impl chalk_ir::zip::Zip<I> for chalk_ir::WhereClause<I>>::zip_with
  40: chalk_solve::infer::unify::Unifier<I>::relate
  41: chalk_solve::infer::unify::<impl chalk_solve::infer::InferenceTable<I>>::relate
  42: chalk_recursive::solve::SolveIterationHelpers::solve_from_clauses
  43: chalk_recursive::solve::SolveIteration::solve_iteration
  44: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  45: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  46: hir_ty::traits::solve::{{closure}}
  47: hir_ty::traits::trait_solve_query
  48: std::panicking::try
  49: salsa::derived::slot::Slot<Q,MP>::execute
  50: salsa::derived::slot::Slot<Q,MP>::read
  51: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  52: <DB as hir_ty::db::HirDatabase>::trait_solve
  53: hir_ty::infer::unify::InferenceTable::try_resolve_obligation
  54: hir_ty::infer::unify::InferenceTable::register_obligation_in_env
  55: hir_ty::infer::InferenceContext::resolve_associated_type_with_params
  56: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  57: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  58: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  59: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
  60: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  61: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  62: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  63: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  64: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
  65: hir_ty::infer::infer_query
  66: salsa::Cycle::catch
  67: salsa::derived::slot::Slot<Q,MP>::execute
  68: salsa::derived::slot::Slot<Q,MP>::read
  69: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  70: <DB as hir_ty::db::HirDatabase>::infer
  71: hir::source_analyzer::SourceAnalyzer::new_for_body
  72: hir::semantics::SemanticsImpl::analyze_impl
  73: ide_db::defs::NameRefClass::classify
  74: ide_db::defs::IdentClass::classify_node
  75: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  76: <hashbrown::map::HashMap<K,V,S,A> as core::iter::traits::collect::Extend<(K,V)>>::extend
  77: ide::highlight_related::highlight_related
  78: std::panicking::try
  79: ide::Analysis::highlight_related
  80: rust_analyzer::handlers::request::handle_document_highlight
  81: std::panicking::try
  82: core::ops::function::FnOnce::call_once{{vtable.shim}}

rust-analyzer version: 0.4.1909-standalone
rustc 1.79.0-nightly (88c2f4f5f 2024-04-02)

@dfireBird
Copy link
Contributor

Can you please provide a minimal code where the error/panic happens?

@Edgeworth
Copy link

Unfortunately that's going to be pretty difficult to do but I think it's reasonable to assume it's the same root cause as the other stack which you've already got a repro for.

@jnicholls
Copy link

jnicholls commented Apr 10, 2024

I too am getting the

`Option::unwrap()` on a `None` value

error constantly. Stack trace below, same file and line/col numbers for origination at least but that might just be a common entry point or something. Where @Edgeworth's stack trace is from "highlighting", mine seems to be on "diagnostics".

Reproducible code might be a problem as it's occurring in a proprietary/closed-source repository.

thread 'Worker' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.96.0/src/lib.rs:1449:33:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <chalk_ir::SubstFolder<I,A> as chalk_ir::fold::TypeFolder<I>>::fold_free_var_lifetime
   5: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   6: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::DynTy<I>>::try_fold_with
   7: chalk_ir::fold::TypeSuperFoldable::super_fold_with
   8: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
   9: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
  10: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  11: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  12: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  13: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::GenericArg<I>>::try_fold_with
  14: <core::iter::adapters::GenericShunt<I,R> as core::iter::traits::iterator::Iterator>::next
  15: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  16: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::Substitution<I>>::try_fold_with
  17: chalk_ir::fold::TypeSuperFoldable::super_fold_with
  18: chalk_ir::_::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::WhereClause<I>>::try_fold_with
  19: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  20: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::TypeFoldable<I> for chalk_ir::QuantifiedWhereClauses<I>>::try_fold_with
  21: chalk_solve::infer::instantiate::<impl chalk_solve::infer::InferenceTable<I>>::instantiate_binders_existentially
  22: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_binders
  23: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  24: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  25: chalk_ir::zip::Zipper::zip_substs
  26: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  27: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  28: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  29: chalk_solve::infer::unify::Unifier<I>::relate_var_ty
  30: chalk_solve::infer::unify::Unifier<I>::relate_ty_ty
  31: <chalk_solve::infer::unify::Unifier<I> as chalk_ir::zip::Zipper<I>>::zip_tys
  32: chalk_ir::zip::Zipper::zip_substs
  33: chalk_ir::_::<impl chalk_ir::zip::Zip<I> for chalk_ir::WhereClause<I>>::zip_with
  34: chalk_solve::infer::unify::Unifier<I>::relate
  35: chalk_solve::infer::unify::<impl chalk_solve::infer::InferenceTable<I>>::relate
  36: chalk_recursive::solve::SolveIterationHelpers::solve_from_clauses
  37: chalk_recursive::solve::SolveIteration::solve_iteration
  38: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  39: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  40: hir_ty::traits::solve::{{closure}}
  41: hir_ty::traits::trait_solve_query
  42: std::panicking::try
  43: salsa::derived::slot::Slot<Q,MP>::execute
  44: salsa::derived::slot::Slot<Q,MP>::read
  45: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  46: <DB as hir_ty::db::HirDatabase>::trait_solve
  47: hir_ty::infer::unify::InferenceTable::callable_sig
  48: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  49: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  50: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  51: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  52: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  53: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  54: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  55: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  56: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  57: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  58: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
  59: hir_ty::infer::infer_query
  60: salsa::Cycle::catch
  61: salsa::derived::slot::Slot<Q,MP>::execute
  62: salsa::derived::slot::Slot<Q,MP>::read
  63: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::fetch
  64: <DB as hir_ty::db::HirDatabase>::infer
  65: hir::DefWithBody::diagnostics
  66: hir::Module::diagnostics
  67: hir::Module::diagnostics
  68: hir::Module::diagnostics
  69: hir::Module::diagnostics
  70: ide_diagnostics::diagnostics
  71: salsa::Cancelled::catch
  72: <core::iter::adapters::copied::Copied<I> as core::iter::traits::iterator::Iterator>::try_fold
  73: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  74: core::ops::function::FnOnce::call_once{{vtable.shim}}

@jnicholls
Copy link

I installed v0.3.1877 (release 1 month ago) and I'm much more stable. I think @CryZe is right, that commit he linked to is the source of the errors, which is definitely not a part of v0.3.1877.

@Veykril
Copy link
Member

Veykril commented Apr 11, 2024

Yes, the issue can be triggered by a variety of server features, a fix is work in progress so if this impacts you please downgrade to an earlier version for the time being.

@Veykril Veykril added A-ty type system / type inference / traits / method resolution I-panic labels Apr 16, 2024
@bors bors closed this as completed in 1bf1f6e Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug I-panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants