So @scalexm and I had a short meeting yesterday to try to plan out next steps in more detail. This post summarizes our thoughts – after writing it, I plan to go and open corresponding issues in the Rust tracker where appropriate.
(If you are interested, the meeting notes can be found here, but they aren’t really meant to be decipherable to anyone who wasn’t at the meeting.)
Ultimately, we came up with the following plan:
Minimal PR for lowering rules
First, to @scalexm is going to take a shot at creating a “minimal PR” that creates “lowering rules” in rustc, hopefully this weekend. The goal is to create “just enough” framework that we can make up an issue and others can start adding to it, and thus getting their hands dirty with the newer system.
The target of this PR is to have a system for lowering Rust items into traits. We are imagining a rustc query like program_clauses(DefId)
where DefId
identifies a trait, associated type declaration, etc – that would return back a set of clauses roughly as described in my rustc-guide PR. This would then be coupled with a unit test framework using #[rustc]
attributes; these attributes would run the lowering and emit the results as errors. This is a common trick in rustc that enables you to write compile-fail/ui unit tests like this:
#[rustc_program_clause]
trait Foo { }
//~^ ERROR forall<Self> { Implemented(Self: Foo) :- FromEnv(Self: Foo) }
fn main() { }
(Note: as part of this PR, we would wind up duplicating – private to the librustc_traits
crate, I believe – some portion of existing types. Notably, the types to represent goals and so forth. This is a bit of a shift from my previous plans, where I had expected to re-use the existing ty::Predicate
type, we are going to just create our own that matches the Chalk types more closely. This means that the grungy refactor in #48539 is just not needed (at least not yet). This seems fine for our purposes of spiking to a working system – of course eventually we’ll have to reconcile the two types.)
Other work items
In addition to that minimal PR, there are a number of other work items, some of which I think are ripe for mentoring. Some of them have issues on the rustc repo already and some don’t. I’ll try to open issues today for things that don’t and post back here when done.