-
Notifications
You must be signed in to change notification settings - Fork 39
Implement Default
on SnapshotVec
, UnificationTable
and unification stores.
#11
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
Implement Default
on SnapshotVec
, UnificationTable
and unification stores.
#11
Conversation
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 can merge as is, but do you want to tweak the new
stuff?
src/unify/backing_vec.rs
Outdated
@@ -17,6 +17,8 @@ pub trait UnificationStore: ops::Index<usize, Output = VarValue<Key<Self>>> + Cl | |||
type Value: UnifyValue; | |||
type Snapshot; | |||
|
|||
// FIXME(eddyb) (not backwards-compat) this should | |||
// use a `Default` bound on the trait 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.
You might as well change this to use Default
if you want. We can always issue a new major version.
@@ -75,13 +75,20 @@ pub trait SnapshotVecDelegate { | |||
fn reverse(values: &mut Vec<Self::Value>, action: Self::Undo); | |||
} | |||
|
|||
impl<D: SnapshotVecDelegate> SnapshotVec<D> { | |||
pub fn new() -> SnapshotVec<D> { | |||
// HACK(eddyb) manual impl avoids `Default` bound on `D`. |
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.
Nit: I don't like the capital HACK -- using a manual impl isn't a hack -- using derive
would be, given the way that Rust works right now, since it'd be easy but wrong.
I'd rather say "Use a manual impl to avoid unnecessary Default
bound on D
."
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.
What's wrong is the way Rust works right now, IMO.
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 agree :) it's just that leaving a comment here won't change it!
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.
wasn't there an RFC about this, giving some more convenient way to opt out, at least?
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 prefer to tag the places that could/should be fixed later.
src/unify/mod.rs
Outdated
@@ -236,6 +236,8 @@ impl<K: UnifyKey> VarValue<K> { | |||
// Option<U>:LatticeValue. | |||
|
|||
impl<S: UnificationStore> UnificationTable<S> { | |||
// FIXME(eddyb) (not backwards-compat) this should | |||
// use a `Default` bound on `S` 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'd rather just have UnificationStore
require Default
. It's not a trait that others outside the crate are meant to implement.
@eddyb yeah, once we merge, I can push a new release to crates.io |
e2c335f
to
8dc607d
Compare
Oh @nikomatsakis didn't make |
This is needed for rust-lang/rust#52591. How will we update the dependency, do we need a release?