Fix crash

This commit is contained in:
Florian Diebold 2020-01-29 22:32:37 +01:00 committed by Florian Diebold
parent a5554dcb17
commit a9430865b3

View File

@ -140,10 +140,13 @@ pub fn from_hir(ctx: &TyLoweringContext<'_, impl HirDatabase>, type_ref: &TypeRe
ImplTraitLoweringMode::Variable => {
let idx = ctx.impl_trait_counter.get();
ctx.impl_trait_counter.set(idx + 1);
let generics =
generics(ctx.db, ctx.resolver.generic_def().expect("generics in scope"));
let (self_params, list_params, impl_trait_params) = generics.provenance_split();
assert!((idx as usize) < impl_trait_params);
let (self_params, list_params, _impl_trait_params) = if let Some(def) = ctx.resolver.generic_def() {
let generics = generics(ctx.db, def);
generics.provenance_split()
} else {
(0, 0, 0)
};
// assert!((idx as usize) < impl_trait_params); // TODO return position impl trait
Ty::Bound(idx as u32 + self_params as u32 + list_params as u32)
}
ImplTraitLoweringMode::Disallowed => {