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

Trait generic defaults cause panic on cycle #15008

Closed
Agapurnis opened this issue Jun 8, 2023 · 2 comments
Closed

Trait generic defaults cause panic on cycle #15008

Agapurnis opened this issue Jun 8, 2023 · 2 comments
Labels
C-bug Category: bug I-panic

Comments

@Agapurnis
Copy link

Agapurnis commented Jun 8, 2023

Trace

Click here to expand.
thread 'Worker' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/salsa-0.17.0-pre.2/src/runtime.rs:306:18
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   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_defaults::__shim
   7: <DB as hir_ty::db::HirDatabase>::generic_defaults
   8: hir_ty::lower::TyLoweringContext::substs_from_args_and_bindings
   9: hir_ty::lower::TyLoweringContext::lower_trait_ref_from_path
  10: hir_ty::lower::TyLoweringContext::lower_type_bound
  11: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  12: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  13: hir_ty::lower::TyLoweringContext::lower_dyn_trait
  14: hir_ty::lower::TyLoweringContext::lower_ty_ext
  15: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  16: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  17: hir_ty::lower::generic_defaults_query
  18: salsa::runtime::Runtime::execute_query_implementation
  19: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  20: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  21: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  22: salsa::derived::slot::MemoRevisions::validate_memoized_value
  23: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  24: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  25: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  26: salsa::derived::slot::MemoRevisions::validate_memoized_value
  27: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  28: salsa::derived::slot::Slot<Q,MP>::read
  29: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  30: <DB as hir_ty::db::HirDatabase>::trait_environment::__shim
  31: <DB as hir_ty::db::HirDatabase>::trait_environment
  32: hir_ty::lower::trait_environment_for_body_query
  33: <DB as hir_ty::db::HirDatabase>::trait_environment_for_body
  34: hir_ty::infer::infer_query
  35: salsa::runtime::Runtime::execute_query_implementation
  36: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  37: salsa::derived::slot::Slot<Q,MP>::read
  38: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  39: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  40: <DB as hir_ty::db::HirDatabase>::infer_query
  41: hir_ty::db::infer_wait
  42: <DB as hir_ty::db::HirDatabase>::infer
  43: hir::Local::ty
  44: ide::syntax_highlighting::highlight::highlight_def
  45: ide::syntax_highlighting::highlight::name_like
  46: ide::syntax_highlighting::highlight
  47: std::panicking::try
  48: rust_analyzer::handlers::request::handle_semantic_tokens_full_delta
  49: std::panicking::try
  50: core::ops::function::FnOnce::call_once{{vtable.shim}}

Reproduction Steps

pub trait Bar <T: ?Sized = dyn Foo<dyn std::any::Any>> {}
pub trait Foo <T: ?Sized + Bar = dyn Bar> {
    fn baz(&self) -> ! {
        unimplemented!();
    }
}

Hover on one of either: &self, baz, unimplemented!(), or Foo's T.

It will also occur when attempting to do other stuff that might end up needing details regarding one of the above traits.

Environment Details

  • rust-analyzer version: 0.3.1541-standalone (2f1b7cedc 2023-06-04)
  • rustc version: rustc 1.70.0 (90c541806 2023-05-31)

Related Issues

@Agapurnis Agapurnis added the C-bug Category: bug label Jun 8, 2023
@lowr
Copy link
Contributor

lowr commented Jun 9, 2023

I can reproduce this issue, but only when I type something and rust-analyzer reanalyzes. Because we do handle generic defaults cycles gracefully, and because the call stack shows we're panicking at salsa::runtime::Runtime::report_unexpected_cycle that was removed after salsa v0.17.0-pre.2 (the version we're using) was published, I'm beginning to suspect this is a salsa bug that was addressed by salsa-rs/salsa#285.

@lowr lowr added the I-panic label Jun 9, 2023
bors added a commit that referenced this issue Dec 7, 2023
internal: Bump salsa

Might f ix #15008, haven't tested
@Veykril
Copy link
Member

Veykril commented Jan 9, 2024

Seems to be fixed now with salsa bumped

@Veykril Veykril closed this as completed Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug I-panic
Projects
None yet
Development

No branches or pull requests

3 participants