Skip to content

panicked at 'mismatched kinds in substitution`, chalk-ir-0.82.0/src/fold/subst.rs:109:22 #12004

@Dirbaio

Description

@Dirbaio

Create a new crate, paste the following into lib.rs:

#![feature(generic_associated_types)]

pub trait Driver {}

pub trait OutType {
    type Reader<D: Driver>;
}

pub enum Out<const OUT_N: usize> {}
impl<const OUT_N: usize> OutType for Out<OUT_N> {
    type Reader<D: Driver> = ();
}

pub struct HidClass<D: Driver, OUT: OutType> {
    output: OUT::Reader<D>,
}

impl<D: Driver> HidClass<D, Out<4>> {
    pub fn new() -> Self {
        Self { output: () }
    }
}

Then try to hover stuff, for example Self. This causes errors like:


thread '<unnamed>' panicked at 'mismatched kinds in substitution', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-ir-0.82.0/src/fold/subst.rs:109:22
stack backtrace:
   0: std::panicking::begin_panic
   1: <chalk_ir::fold::subst::Subst<I> as chalk_ir::fold::Folder<I>>::fold_free_var_const
   2: <chalk_ir::Const<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   3: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   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::Fold<I> for chalk_ir::Substitution<I>>::fold_with
   6: <chalk_ir::Ty<I> as chalk_ir::fold::SuperFold<I>>::super_fold_with
   7: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::GenericArg<I>>::fold_with
   8: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   9: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I> for chalk_ir::Substitution<I>>::fold_with
  10: chalk_ir::fold::subst::Subst<I>::apply
  11: chalk_ir::Binders<T>::substitute
  12: chalk_solve::split::Split::impl_parameters_and_projection_from_associated_ty_value
  13: chalk_solve::clauses::builder::ClauseBuilder<I>::push_binders
  14: chalk_solve::clauses::push_program_clauses_for_associated_type_values_in_impls_of
  15: chalk_recursive::solve::SolveIterationHelpers::solve_from_clauses
  16: chalk_recursive::solve::SolveIteration::solve_iteration
  17: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  18: chalk_recursive::fulfill::Fulfill<I,Solver>::prove
  19: chalk_recursive::fulfill::Fulfill<I,Solver>::solve
  20: chalk_recursive::solve::SolveIterationHelpers::solve_from_clauses
  21: chalk_recursive::solve::SolveIteration::solve_iteration
  22: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  23: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  24: <hir_ty::db::TraitSolveQueryQuery as salsa::plumbing::QueryFunction>::execute
  25: salsa::runtime::Runtime::execute_query_implementation
  26: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  27: salsa::derived::slot::Slot<Q,MP>::read
  28: salsa::QueryTable<Q>::get
  29: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  30: hir_ty::db::trait_solve_wait
  31: <DB as hir_ty::db::HirDatabase>::trait_solve
  32: hir_ty::infer::unify::InferenceTable::register_obligation_in_env
  33: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce
  34: hir_ty::infer::coerce::<impl hir_ty::infer::InferenceContext>::coerce
  35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  37: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  38: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
  39: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  40: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  41: hir_ty::infer::infer_query
  42: salsa::runtime::Runtime::execute_query_implementation
  43: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  44: salsa::derived::slot::Slot<Q,MP>::read
  45: salsa::QueryTable<Q>::get
  46: <DB as hir_ty::db::HirDatabase>::infer_query
  47: hir_ty::db::infer_wait
  48: hir::source_analyzer::SourceAnalyzer::new_for_body
  49: hir::semantics::SemanticsImpl::analyze_impl
  50: ide_db::defs::NameRefClass::classify
  51: ide_db::defs::IdentClass::classify_node
  52: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  53: <itertools::unique_impl::UniqueBy<I,V,F> as core::iter::traits::iterator::Iterator>::next
  54: ide::hover::hover
  55: std::panicking::try
  56: rust_analyzer::handlers::handle_hover
  57: std::panicking::try
  58: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 9:27:35 PM] Request textDocument/hover failed.
  Message: server panicked: mismatched kinds in substitution
  Code: -32603 

rust-analyzer version: 7ce3ca5 2022-04-15 nightly

rustc version: rustc 1.61.0-nightly (458262b 2022-03-09)

relevant settings: Nothing special

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-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