Skip to content

Suggest implementing #[derive(PartialEq)] for types in vectors and arrays - #95371

Closed
TaKO8Ki wants to merge 1 commit into
rust-lang:masterfrom
TaKO8Ki:suggest-using-derive-partialeq-for-types-in-vector-and-array
Closed

Suggest implementing #[derive(PartialEq)] for types in vectors and arrays#95371
TaKO8Ki wants to merge 1 commit into
rust-lang:masterfrom
TaKO8Ki:suggest-using-derive-partialeq-for-types-in-vector-and-array

Conversation

@TaKO8Ki

Copy link
Copy Markdown
Member

closes#95285

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 27, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @cjgillot

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 27, 2022
}
}

if Some(trait_pred.trait_ref.def_id) == self.tcx.lang_items().eq_trait() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you leave a comment for what this function does? Also a comment explaining the special casing just for Eq. Alternatively, we could think of some way to generalize this?

@TaKO8KiTaKO8KiMar 29, 2022

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Hmm. In case of PartialOrd, rustc properly explains why xs can't be compared with [X, X, X].

fn main() {
struct X;
let xs = [X, X, X];
let eq = xs > [X, X, X];
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=7115dbcd188f44a242ba8640347bbfe3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to implement the PartialEq suggestion by re-using the code for PartialOrd?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yes. I'm going to do it.

@cjgillotcjgillot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2022
@bors

bors commented Apr 27, 2022

Copy link
Copy Markdown
Collaborator

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

@Dylan-DPC

Copy link
Copy Markdown
Member

@TaKO8Ki any updates on this?

@JohnCSimon

Copy link
Copy Markdown

@TaKO8Ki
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this.
Note: if you do please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github.
Thanks for your contribution.

@rustbot label: +S-inactive

@rustbotrustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Jan 29, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-inactiveStatus: Inactive and waiting on the author. This is often applied to closed PRs.S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhelpful error message when comparing an array of types that are not comparable

8 participants

@TaKO8Ki@rust-highfive@bors@Dylan-DPC@JohnCSimon@cjgillot@compiler-errors@rustbot