-
Notifications
You must be signed in to change notification settings - Fork 183
Change Fold and Folder traits to take values #644
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
Conversation
chalk-ir/src/fold/boring_impls.rs
Outdated
folder: &mut dyn Folder<'i, I, TI>, | ||
outer_binder: DebruijnIndex, | ||
) -> Fallible<Self::Result> | ||
where | ||
I: 'i, | ||
TI: 'i, | ||
{ | ||
(**self).fold_with(folder, outer_binder) | ||
unimplemented!(); |
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.
Heads up: I think this implementation should be removed, but I haven't quite figured how to do that.
Or.. maybe not, since it broke every test?
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.
So this is a bit of a weird case, since self.fold_with()
would call this impl recursively.
This should be self.clone.fold_with()
instead.
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.
I think (*self).clone()
, but it fails to build because of some missing Clone
bounds.
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.
1: chalk_ir::fold::boring_impls::<impl chalk_ir::fold::Fold<I,TI> for &T>::fold_with
at ./chalk-ir/src/fold/boring_impls.rs:23:9
2: <T as chalk_ir::fold::shift::Shift<I>>::shifted_in_from
at ./chalk-ir/src/fold/shift.rs:32:9
3: <T as chalk_ir::fold::shift::Shift<I>>::shifted_in
at ./chalk-ir/src/fold/shift.rs:28:9
4: chalk_solve::coherence::solve::<impl chalk_solve::coherence::CoherenceSolver<I>>::disjoint::{{closure}}
at ./chalk-solve/src/coherence/solve.rs:104:26
folder: &mut dyn Folder<'i, I, TI>, | ||
outer_binder: DebruijnIndex, | ||
) -> ::chalk_ir::Fallible<Self::Result> | ||
where | ||
I: 'i, | ||
TI: 'i, | ||
{ | ||
let clause = self.data(folder.interner()); | ||
let clause = self.data(folder.interner()).clone(); |
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.
Heads up: clone()
here from borrowed data.
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.
Hmm.
@@ -80,7 +81,7 @@ pub trait UniverseMapExt { | |||
fn add(&mut self, universe: UniverseIndex); | |||
fn map_universe_to_canonical(&self, universe: UniverseIndex) -> Option<UniverseIndex>; | |||
fn map_universe_from_canonical(&self, universe: UniverseIndex) -> UniverseIndex; | |||
fn map_from_canonical<T, I>( | |||
fn map_from_canonical<T: Clone, I>( |
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.
Heads up: new Clone
bounds.
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.
Yeah, no way around this
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.
Well, if we take canonical_value
by value...
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.
Good poing, updated, but there are still two clone()
s needed in merge_answer_into_strand
.
c614895
to
88d3e30
Compare
chalk-recursive/src/fulfill.rs
Outdated
@@ -84,7 +84,7 @@ pub(super) trait RecursiveInferenceTable<I: Interner> { | |||
T: Fold<I>, | |||
T::Result: HasInterner<Interner = I>; | |||
|
|||
fn u_canonicalize<T>( | |||
fn u_canonicalize<T: Clone>( |
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.
Instead, should we just take value0
by value?
@@ -80,7 +81,7 @@ pub trait UniverseMapExt { | |||
fn add(&mut self, universe: UniverseIndex); | |||
fn map_universe_to_canonical(&self, universe: UniverseIndex) -> Option<UniverseIndex>; | |||
fn map_universe_from_canonical(&self, universe: UniverseIndex) -> UniverseIndex; | |||
fn map_from_canonical<T, I>( | |||
fn map_from_canonical<T: Clone, I>( |
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.
Well, if we take canonical_value
by value...
folder: &mut dyn Folder<'i, I, TI>, | ||
outer_binder: DebruijnIndex, | ||
) -> ::chalk_ir::Fallible<Self::Result> | ||
where | ||
I: 'i, | ||
TI: 'i, | ||
{ | ||
let clause = self.data(folder.interner()); | ||
let clause = self.data(folder.interner()).clone(); |
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.
Hmm.
☔ The latest upstream changes (presumably #648) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Closing this for now. I'm still not sure how to make it work, and I haven't had much time for it lately 😞. |
@lnicola thanks for trying regardless |
I dropped the changes adding extra To recap, there's this impl: impl<'a, T: Fold<I>, I: Interner> Fold<I> for &'a T {
type Result = T::Result;
fn fold_with<'i>(
self,
_folder: &mut dyn Folder<'i, I>,
_outer_binder: DebruijnIndex,
) -> Fallible<Self::Result>
where
I: 'i,
{
unreachable!();
// (*self).fold_with(folder, outer_binder)
}
}
|
Fixes #642