diff --git a/chalk-solve/src/clauses/builtin_traits/discriminant_kind.rs b/chalk-solve/src/clauses/builtin_traits/discriminant_kind.rs index 27d49df7597..b30a441872d 100644 --- a/chalk-solve/src/clauses/builtin_traits/discriminant_kind.rs +++ b/chalk-solve/src/clauses/builtin_traits/discriminant_kind.rs @@ -39,25 +39,27 @@ pub fn add_discriminant_clauses( | TyKind::InferenceVar(..) => false, }; - if !can_determine_discriminant { - return Err(Floundered); - } - - let disc_ty = db.discriminant_type(self_ty.clone()); - let trait_id = db .well_known_trait_id(WellKnownTrait::DiscriminantKind) .unwrap(); let trait_datum = db.trait_datum(trait_id); let associated_ty_id = trait_datum.associated_ty_ids[0]; - let substitution = Substitution::from1(interner, self_ty); + let substitution = Substitution::from1(interner, self_ty.clone()); let trait_ref = TraitRef { trait_id, substitution: substitution.clone(), }; + builder.push_fact(trait_ref); + + if !can_determine_discriminant { + return Ok(()); + } + + let disc_ty = db.discriminant_type(self_ty); + let normalize = Normalize { alias: AliasTy::Projection(ProjectionTy { associated_ty_id, @@ -66,7 +68,6 @@ pub fn add_discriminant_clauses( ty: disc_ty, }; - builder.push_fact(trait_ref); builder.push_fact(normalize); Ok(()) diff --git a/tests/test/discriminant_kind.rs b/tests/test/discriminant_kind.rs index 334bca9be2c..d4d37e47592 100644 --- a/tests/test/discriminant_kind.rs +++ b/tests/test/discriminant_kind.rs @@ -156,11 +156,11 @@ fn discriminant_kind_assoc() { goal { forall { exists { - Normalize(::Discriminant -> U) + ::Discriminant = U } } } yields { - expect![["Ambiguous; no inference guidance"]] + expect![["Unique; substitution [?0 := (DiscriminantKind::Discriminant)]"]] } } }