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

Assertion failure in type inference #13352

Closed
Veykril opened this issue Oct 5, 2022 · 0 comments · Fixed by #13353
Closed

Assertion failure in type inference #13352

Veykril opened this issue Oct 5, 2022 · 0 comments · Fixed by #13353
Labels
A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately

Comments

@Veykril
Copy link
Member

Veykril commented Oct 5, 2022

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,
};

@Veykril Veykril added A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately labels Oct 5, 2022
wildbook added a commit to wildbook/rust-analyzer that referenced this issue Oct 5, 2022
bors added a commit that referenced this issue Oct 5, 2022
Fix assertion failure in type inference (#13352)

Fixes #13352
@bors bors closed this as completed in a415fb4 Oct 6, 2022
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 Broken Window Bugs / technical debt to be addressed immediately
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant