Skip to content
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 PartialEq<[A]> for VecDeque<A>. #38661

Merged
merged 1 commit into from
Feb 2, 2017

Conversation

frewsxcv
Copy link
Member

Fixes #38625.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@frewsxcv frewsxcv added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Dec 28, 2016
@frewsxcv frewsxcv changed the title Implement PartialEq<&[A]> for VecDeque. Implement PartialEq<&[A]> for VecDeque<A>. Dec 28, 2016
@@ -2158,6 +2158,18 @@ impl<A: PartialEq> PartialEq for VecDeque<A> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Eq> Eq for VecDeque<A> {}

#[stable(feature = "vec-deque-partial-eq-slice", since = "")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder for future self that since should be filled in.

@frewsxcv
Copy link
Member Author

A crater run might be good for this (see this comment for more information).

@@ -2158,6 +2158,18 @@ impl<A: PartialEq> PartialEq for VecDeque<A> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Eq> Eq for VecDeque<A> {}

#[stable(feature = "vec-deque-partial-eq-slice", since = "")]
impl<'a, A: PartialEq> PartialEq<&'a [A]> for VecDeque<A> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct signature? Should it be PartialEq<[A]>?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PartialEq<[A]> should be the primary one. Does that change the utility of it? The type inference problems? (I guess it's the same.)

Copy link
Member Author

@frewsxcv frewsxcv Dec 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change it to impl<A: PartialEq> PartialEq<[A]> for VecDeque<A> and the non-test code compiles.

But if one does:

let mut d = VecDeque::new();
d.push_back('a');
d.push_back('b');
let v = vec!['a', 'b'];
assert!(d == &v);

...which looks perfectly valid to me, this compile error appears:

error[E0277]: the trait bound `collections::VecDeque<char>: std::cmp::PartialEq<&collections::vec::Vec<char>>` is not satisfied
   --> src/libcollections/../libcollectionstest/vec_deque.rs:623:13
    |
623 |     assert!(d == &v);
    |             ^^^^^^^ the trait `std::cmp::PartialEq<&collections::vec::Vec<char>>` is not implemented for `collections::VecDeque<char>`
    |
    = help: the following implementations were found:
    = help:   <collections::VecDeque<A> as std::cmp::PartialEq>
    = help:   <collections::VecDeque<A> as std::cmp::PartialEq<[A]>>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like one would have to write assert!(d == *&v[..]);, which seems less than ideal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v[..] must be enough. Still, less than ideal, but not surprising, since it's generic and thus &v can't coerce to anything anyway, it would need an explicit impl for &Vec<_>, would it not, to have d == &v compile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the latest commit.

@frewsxcv frewsxcv changed the title Implement PartialEq<&[A]> for VecDeque<A>. Implement PartialEq<[A]> for VecDeque<A>. Dec 29, 2016
@aturon
Copy link
Member

aturon commented Jan 4, 2017

cc @rust-lang/libs, this would be instantly stable.

@aturon
Copy link
Member

aturon commented Jan 4, 2017

@brson, can you do a crater run?

In general, I'm 👍 on this addition.

@sfackler
Copy link
Member

sfackler commented Jan 4, 2017

LGTM assuming the whole world doesn't break, which I don't imagine it will.

@alexcrichton
Copy link
Member

@aturon wanna fcp merge this? Otherwise lgtm

@aturon
Copy link
Member

aturon commented Jan 4, 2017

@rfcbot fcp merge

(We'll wait for crater before actually merging.)

@rfcbot
Copy link

rfcbot commented Jan 4, 2017

Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@bluss
Copy link
Member

bluss commented Jan 6, 2017

To double check, I thought PartialEq<[T]> would be the natural impl (And then further impls based upon that, possibly), but that doesn't seem to be how Vec does it at all. Vec<A> has PartialEq<X> with X = &[B], &mut [B], [B; 0], &[B; 0] where A: PartialEq<B> (and more array impls).

@frewsxcv frewsxcv force-pushed the vec-deque-partial-eq branch 4 times, most recently from 79566a1 to 5458a1f Compare January 7, 2017 22:09
@frewsxcv
Copy link
Member Author

frewsxcv commented Jan 7, 2017

Added more impls in the latest commit.

@bors
Copy link
Contributor

bors commented Jan 9, 2017

☔ The latest upstream changes (presumably #38581) made this pull request unmergeable. Please resolve the merge conflicts.

@frewsxcv
Copy link
Member Author

frewsxcv commented Jan 9, 2017

Rebased.

@brson
Copy link
Contributor

brson commented Jan 20, 2017

Yes I can crater.

@brson
Copy link
Contributor

brson commented Jan 20, 2017

$ target/debug/crater-cli.exe custom-build https://github.com/frewsxcv/rust 61313c1426d67db83cc333a4eef146e1df758006
created task for https://github.com/frewsxcv/rust
inspector link: https://tools.taskcluster.net/task-inspector/#y-UmEC_nRROj_6lqoJMPYg

$ target/debug/crater-cli.exe custom-build https://github.com/frewsxcv/rust 5c1472a720243314ac5e659f3d621242eb82f2de
created task for https://github.com/frewsxcv/rust
inspector link: https://tools.taskcluster.net/task-inspector/#KmxJ0FxVT1KPOnKE8Xj6EQ

@frewsxcv
Copy link
Member Author

I don't really understand the taskcluster interface. Did everything pass?

@rfcbot
Copy link

rfcbot commented Jan 23, 2017

🔔 This is now entering its final comment period, as per the review above. 🔔

psst @aturon, I wasn't able to add the final-comment-period label, please do so.

@bluss
Copy link
Member

bluss commented Jan 23, 2017

There's no discussion here, just me claiming different things about how I expected it to be and how Vec does it. What Vec does is obviously a mess (So many impls), do we really want to continue that?

With so many impls, it's very hard to remember when exactly a thing like VecDeque is comparable to something else.

@brson
Copy link
Contributor

brson commented Jan 23, 2017

Crater says one false positive.

@frewsxcv
Copy link
Member Author

Sooooo is this good to go? Should I fill in since?

@aturon
Copy link
Member

aturon commented Jan 27, 2017

@frewsxcv Let's do it!

@frewsxcv
Copy link
Member Author

This should be good to go!

@aturon
Copy link
Member

aturon commented Jan 31, 2017

@bors: r+

@bors
Copy link
Contributor

bors commented Jan 31, 2017

📌 Commit b081872 has been approved by aturon

@bors
Copy link
Contributor

bors commented Jan 31, 2017

⌛ Testing commit b081872 with merge cdf82c4...

bors added a commit that referenced this pull request Jan 31, 2017
Implement `PartialEq<[A]>` for `VecDeque<A>`.

Fixes #38625.
@bors
Copy link
Contributor

bors commented Feb 1, 2017

💔 Test failed - status-travis

@frewsxcv
Copy link
Member Author

frewsxcv commented Feb 1, 2017

@bors retry

@bors
Copy link
Contributor

bors commented Feb 1, 2017

⌛ Testing commit b081872 with merge 6f923bf...

@bors
Copy link
Contributor

bors commented Feb 1, 2017

💔 Test failed - status-appveyor

@frewsxcv
Copy link
Member Author

frewsxcv commented Feb 1, 2017

@bors retry couldn't fetch cargo

@bors
Copy link
Contributor

bors commented Feb 1, 2017

⌛ Testing commit b081872 with merge 4c357d0...

@bors
Copy link
Contributor

bors commented Feb 1, 2017

💔 Test failed - status-travis

@alexcrichton
Copy link
Member

alexcrichton commented Feb 1, 2017 via email

@bors
Copy link
Contributor

bors commented Feb 1, 2017

⌛ Testing commit b081872 with merge 123afbd...

@bors
Copy link
Contributor

bors commented Feb 2, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member

alexcrichton commented Feb 2, 2017 via email

@bors
Copy link
Contributor

bors commented Feb 2, 2017

⌛ Testing commit b081872 with merge 2a6f7e4...

bors added a commit that referenced this pull request Feb 2, 2017
Implement `PartialEq<[A]>` for `VecDeque<A>`.

Fixes #38625.
@bors
Copy link
Contributor

bors commented Feb 2, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: aturon
Pushing 2a6f7e4 to master...

@bors bors merged commit b081872 into rust-lang:master Feb 2, 2017
@frewsxcv frewsxcv deleted the vec-deque-partial-eq branch February 15, 2017 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants