Skip to content

Commit f709901

Browse files
committed
Handle multiple leaf goals in LowerGoal
1 parent a532519 commit f709901

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ir/lowering/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use lalrpop_intern::intern;
66
use cast::{Cast, Caster};
77
use errors::*;
88
use ir::{self, Anonymize, ToParameter};
9+
use itertools::Itertools;
910
use solve::SolverChoice;
1011

1112
mod test;
@@ -995,10 +996,11 @@ impl<'k> LowerGoal<Env<'k>> for Goal {
995996
}
996997
Goal::Not(g) => Ok(Box::new(ir::Goal::Not(g.lower(env)?))),
997998
Goal::Leaf(wc) => {
998-
let leaf = wc.lower(env)?;
999-
assert_eq!(1, leaf.len());
1000-
let leaf = leaf.into_iter().next().unwrap();
1001-
Ok(Box::new(ir::Goal::Leaf(leaf)))
999+
// A where clause can lower to multiple leaf goals; wrap these in Goal::And.
1000+
let leaves = wc.lower(env)?.into_iter().map(ir::Goal::Leaf);
1001+
let goal = leaves.fold1(|goal, leaf| ir::Goal::And(Box::new(goal), Box::new(leaf)))
1002+
.expect("at least one goal");
1003+
Ok(Box::new(goal))
10021004
}
10031005
}
10041006
}

0 commit comments

Comments
 (0)