Conversation
|
☔ The latest upstream changes (presumably #48411) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
left a comment
There was a problem hiding this comment.
This looks awesome! I left some suggestions, mostly nits of various kinds. I'm inclined to move forward quickly and do most of our iteration in tree rather than spending too much time in this PR, so we should feel free to mark some items as "follow-up work" (e.g., giving names and comments and things).
src/librustc/ich/impls_ty.rs
Outdated
There was a problem hiding this comment.
egads we should really extend the macro here
src/librustc/traits/mod.rs
Outdated
There was a problem hiding this comment.
I don't think we want poly trait predicates here. I think we want the binders to be moved out of WhereClauseAtom and into the Goal -- actually, in Chalk we get this mildly wrong, as I'll comment below.
src/librustc/traits/mod.rs
Outdated
There was a problem hiding this comment.
I think we should just call this DomainGoal, and forego the Leaf indirection
src/librustc/traits/mod.rs
Outdated
There was a problem hiding this comment.
So, this matches chalk, where we make the hypotheses a set of domain goals, but it's not as general as we could do. We really should use Clause<'tcx> here, which would match the following enum:
enum Clause<'tcx> {
Implies(Vec<Goal<'tcx>>, DomainGoal<'tcx>),
DomainGoal(DomainGoal<'tcx>),
ForAll(Box<ty::Binder<Clause<'tcx>>),
}This matches the definition from Page 7 of "A Proof Procedure for the Logic of Hereditary Harrop Formulas" pretty well. That definition is D = A | G => A | D ^ D | forall x. D -- where D is a clause, G is a goal, and A is a DomainGoal -- but we've moved the "and" case (D ^ D) into the vector. (There are broader definitions as well for clauses, but they can be normalized into this form.)
This would also entail a change to Environment to store these clauses instead of just domain goals.
The reason that this matters is that if we move the binder out of DomainGoal, we need somewhere to put it in the case of a clause!
There was a problem hiding this comment.
Also, I think we should use interners probably, and hence make this:
type Goal<'tcx> = &'tcx GoalKind<'tcx>;
enum GoalKind<'tcx> {
Implies(Vec<DomainGoal<'tcx>, Goal<'tcx>),
... // as today
}but we can do that in a follow-up. (We should open a FIXME for it before landing.)
There was a problem hiding this comment.
I opened rust-lang/chalk#94 to describe the change here in chalk
There was a problem hiding this comment.
Total nit: let's either keep the . on both sides or drop it on both sides. =)
src/test/ui/chalkify/lower_impl.rs
Outdated
There was a problem hiding this comment.
This is so nice =) I guess you intentionally omitted the details here? (We see them below in the stderr file...)
There was a problem hiding this comment.
Yes I skipped them here because it's a bit verbose :)
src/librustc/traits/lowering.rs
Outdated
There was a problem hiding this comment.
Nit; you don't need the *self anymore; you can add the feature(match_default_bindings) instead
src/librustc/traits/lowering.rs
Outdated
There was a problem hiding this comment.
Hmm. So, I think we should go through the rustc-guide reference on this topic and give names to each of these rules. Then we can reference those rules here to allow for easy cross-reference.
There was a problem hiding this comment.
This can be done later.
src/librustc/traits/lowering.rs
Outdated
There was a problem hiding this comment.
Nit: let's move this code into librustc_traits now that #48411 has landed
|
ok so I was talking to @scalexm on gitter. We agreed that we can leave most of the changes here for later. Here is the list of thing I wrote, I think:
|
|
@scalexm I'd like to review one last time tomorrow or whatever, but otherwise once nits are fixed I think we should land and then we can open up issues for follow-up work |
|
@bors r+ This is so exciting. 🎉 |
|
📌 Commit 4eaa85d has been approved by |
src/librustc_traits/lowering.rs
Outdated
| if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { | ||
| return Lrc::new(vec![]); | ||
| } | ||
|
|
There was a problem hiding this comment.
[00:06:08] tidy error: /checkout/src/librustc_traits/lowering.rs:120: trailing whitespace
[00:06:10] some tidy checks failed
|
@bors r- Tidy failed. |
|
@bors r=nikomatsakis |
|
📌 Commit ef3b4e1 has been approved by |
MVP for chalkification r? @nikomatsakis
|
☀️ Test successful - status-appveyor, status-travis |
r? @nikomatsakis