-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
traits: Implement interning for Goal and Clause #49800
Conversation
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
919e8ca
to
0ba778b
Compare
@ishitatsuyuki nice! I added a note about this PR to the WG-traits planning meeting document, btw |
☔ The latest upstream changes (presumably #49435) made this pull request unmergeable. Please resolve the merge conflicts. |
0ba778b
to
8720ded
Compare
☔ The latest upstream changes (presumably #49390) made this pull request unmergeable. Please resolve the merge conflicts. |
8720ded
to
7a66d2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! One change though -- foldable looks not right to me.
@@ -322,13 +323,13 @@ pub enum Clause<'tcx> { | |||
/// it with the reverse implication operator `:-` to emphasize the way | |||
/// that programs are actually solved (via backchaining, which starts | |||
/// with the goal to solve and proceeds from there). | |||
#[derive(Clone, PartialEq, Eq, Hash, Debug)] | |||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woohoo, copy types FTW 🐻
pub struct ProgramClause<'tcx> { | ||
/// This goal will be considered true... | ||
pub goal: DomainGoal<'tcx>, | ||
|
||
/// ...if we can prove these hypotheses (there may be no hypotheses at all): | ||
pub hypotheses: Vec<Goal<'tcx>>, | ||
pub hypotheses: &'tcx Slice<Goal<'tcx>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth a type alias? Goals<'tcx>
? Or, maybe not. Meh.
} | ||
|
||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> bool { | ||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait. This doesn't look right. I expect something more like the impl for Slice
. That is, super_fold_with
should do something like:
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self {
let goal: Goal<'tcx> = (*self).fold_with(folder);
self.tcx().mk_goal(goal)
}
and visit_with
:
fn super_visit_with(...) {
(*self).visit_with(visitor)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool { | ||
self.iter().any(|t| t.visit_with(visitor)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want an impl for &'tcx Clause<'tcx>
? Probably, though maybe we don't need it yet.
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<traits::Clause<'tcx>> { | ||
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { | ||
let v = self.iter().map(|t| t.fold_with(folder)).collect::<AccumulateVec<[_; 8]>>(); | ||
folder.tcx().intern_clauses(&v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we should think about making a macro for these "intern-wrapping impls"... but not, I suppose, in this PR.
} | ||
|
||
pub fn mk_goal(self, goal: Goal<'tcx>) -> &'tcx Goal { | ||
&self.mk_goals(iter::once(goal))[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is clever...
7a66d2f
to
b15df80
Compare
@bors r+ |
📌 Commit b15df80 has been approved by |
⌛ Testing commit b15df80 with merge f6af3b347421667028bda0ba004fb554dd706932... |
💔 Test failed - status-appveyor |
@bors retry 3 hour timeout in Timings
Top 10:
|
@bors p=9 |
traits: Implement interning for Goal and Clause r? @nikomatsakis Close #49054 Contains some refactoring for the interning mechanism, mainly aimed at reducing pain when changing types of interning map. This should be mostly good, although I'm not sure with the naming of `Goal::from_poly_domain_goal`.
☀️ Test successful - status-appveyor, status-travis |
r? @nikomatsakis
Close #49054
Contains some refactoring for the interning mechanism, mainly aimed at reducing pain when changing types of interning map.
This should be mostly good, although I'm not sure with the naming of
Goal::from_poly_domain_goal
.