refactor Program
to separating lowering from solving
#19
Labels
good first issue
A good issue to start working on Chalk with
Right now the
ir::Program
struct contains a lot of fields that encode the lowered Rust program:Since the trait solving routines in
solve
get access to anArc<Program>
, this suggests that they need all of this information. But in fact they do not. The goal is that they only needprogram_clauses
, although it may be useful to have a bit more (basically, it depends a bit on how much code we lower to explicit program-clauses and how much code we choose to keep in Rust code).However, these fields are used during lowering. And in particular we lower the input program and then, in the unit tests, save that state and come back and lower various goals.
I think we should introduce a new struct, let's call it the
SharedEnvironment
orProgramEnvironment
, which is used by the solving routines and contains only those fields needed by solving.Looking through the code that would be two fields:
program_clauses
trait_data
-- this one is needed because of our current approach to Elaborating where clauses on traits, structs #12, which I am not happy withSo we could refactor
Program
like so:Here I moved the
trait_data
field into the program-env. Another option would be to duplicate it. In that case, I suspect thatProgram
would not need to have a link to the program-env at all. Instead, lowering could return a pair of(Program, ProgramEnvironment)
.We would then also change the
solve
routines to take anArc<ProgramEnvironment>
instead ofArc<Program>
.I'm tagging this as help-wanted since it seems like a relatively good "intro bug".
The text was updated successfully, but these errors were encountered: