Skip to content

Commit 0b391f8

Browse files
committed
Forbid inference vars when getting program clauses
1 parent d719618 commit 0b391f8

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

chalk-engine/src/logic.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,12 @@ impl<I: Interner> Forest<I> {
322322
goal.canonical,
323323
);
324324
let mut infer = TruncatingInferenceTable::new(context.max_size(), infer);
325-
// `canonical_goal` is a goal. We can simplify it
326-
// into a series of *literals*, all of which must be
327-
// true. Thus, in EWFS terms, we are effectively
328-
// creating a single child of the `A :- A` goal that
329-
// is like `A :- B, C, D` where B, C, and D are the
330-
// simplified subgoals. You can think of this as
331-
// applying built-in "meta program clauses" that
325+
// The goal for this table is not a domain goal, so we instead
326+
// simplify it into a series of *literals*, all of which must be
327+
// true. Thus, in EWFS terms, we are effectively creating a
328+
// single child of the `A :- A` goal that is like `A :- B, C, D`
329+
// where B, C, and D are the simplified subgoals. You can think
330+
// of this as applying built-in "meta program clauses" that
332331
// reduce goals into Domain goals.
333332
match Self::simplify_goal(context, &mut infer, subst, environment, goal) {
334333
FallibleOrFloundered::Ok(ex_clause) => {

chalk-solve/src/clauses.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ fn program_clauses_that_could_match<I: Interner>(
403403
let trait_datum = db.trait_datum(trait_id);
404404

405405
match self_ty.kind(interner) {
406+
TyKind::InferenceVar(_, _) => {
407+
panic!("Inference vars not allowed when getting program clauses")
408+
}
406409
TyKind::Alias(alias) => {
407410
// An alias could normalize to anything, including `dyn trait`
408411
// or an opaque type, so push a clause that asks for the
@@ -590,6 +593,9 @@ fn program_clauses_that_could_match<I: Interner>(
590593
let trait_datum = db.trait_datum(trait_id);
591594

592595
let self_ty = alias.self_type_parameter(interner);
596+
if let TyKind::InferenceVar(_, _) = self_ty.kind(interner) {
597+
panic!("Inference vars not allowed when getting program clauses");
598+
}
593599

594600
// Flounder if the self-type is unknown and the trait is non-enumerable.
595601
//
@@ -847,6 +853,9 @@ fn match_ty<I: Interner>(
847853
) -> Result<(), Floundered> {
848854
let interner = builder.interner();
849855
Ok(match ty.kind(interner) {
856+
TyKind::InferenceVar(_, _) => {
857+
panic!("Inference vars not allowed when getting program clauses")
858+
}
850859
TyKind::Adt(adt_id, _) => builder
851860
.db
852861
.adt_datum(*adt_id)
@@ -890,7 +899,7 @@ fn match_ty<I: Interner>(
890899
TyKind::Function(_quantified_ty) => {
891900
builder.push_fact(WellFormed::Ty(ty.clone()));
892901
}
893-
TyKind::BoundVar(_) | TyKind::InferenceVar(_, _) => return Err(Floundered),
902+
TyKind::BoundVar(_) => return Err(Floundered),
894903
TyKind::Dyn(dyn_ty) => {
895904
// FIXME(#203)
896905
// - Object safety? (not needed with RFC 2027)

0 commit comments

Comments
 (0)