Skip to content

Assertion failure in type inference #13352

Closed
@Veykril

Description

@Veykril

When putting the cursor on the Output ident in the trait impl it triggers the assertion

trait Trait {
    type Output;
}
impl Trait for () {
    type Output = ();
}
thread 'Worker' panicked at 'assertion failed: generics.parent_generics().is_some() == parent_subst.is_some()', crates\hir-ty\src\builder.rs:195:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\panicking.rs:142
   2: core::panicking::panic
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\panicking.rs:48
   3: hir_ty::builder::TyBuilder<()>::subst_for_def
   4: hir_ty::builder::TyBuilder<chalk_ir::Binders<chalk_ir::Ty<hir_ty::interner::Interner>>>::def_ty
   5: hir::TypeAlias::ty
   6: ide_db::search::def_to_ty
   7: ide_db::search::FindUsages::include_self_refs
   8: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   9: <hashbrown::map::HashMap<K,V,S,A> as core::iter::traits::collect::Extend<(K,V)>>::extend
  10: ide::highlight_related::highlight_related
  11: std::panicking::try
  12: rust_analyzer::handlers::handle_document_highlight
  13: std::panicking::try
  14: <F as threadpool::FnBox>::call_box

This is missing the trait impl case I assume?

let parent_subst = match ty_def {
TyDefId::TypeAliasId(id) => match id.lookup(db.upcast()).container {
ItemContainerId::TraitId(id) => {
let subst = TyBuilder::subst_for_def(db, id, None).fill_with_unknown().build();
Some(subst)
}
_ => None,
},
_ => None,
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionBroken WindowBugs / technical debt to be addressed immediately

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions