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

[tuple_array_conversions]: move from complexity to nursery #11146

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

MingweiSamuel
Copy link
Contributor

@MingweiSamuel MingweiSamuel commented Jul 12, 2023

The lint suggestion is arguably often less readable and more complex than the original code.

For example, which of the following is the most readable:

let _vertices = edges.flat_map(|(src, dst)| [src, dst]);
let _vertices = edges.flat_map(<_ as Into<[i32; 2]>>::into);
let _vertices = edges.flat_map(<[i32; 2]>::from);

The lint can be useful, but really only applies if the tuple is either long enough that naming the fields is silly (maybe at least 4 entries long), or if the author intends the fields to be homogenous, which is author intent and can't be determined by the lint. Therefore I think the lint should be marked as pedantic.

Currently, there are also a lot of false positives with the lint:

Should fix those issues before enabling it for everyone.


changelog: Move [tuple_array_conversions] to nursery (Now allow-by-default)

#11146

@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2023

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

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 12, 2023
@@ -31,7 +31,7 @@ declare_clippy_lint! {
/// ```
#[clippy::version = "1.72.0"]
pub TUPLE_ARRAY_CONVERSIONS,
complexity,
pedantic,
Copy link
Member

Choose a reason for hiding this comment

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

This should be nursery instead.

I'll try to fix most of these issues before the next sync (in 2 weeks).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, that makes sense too!

@MingweiSamuel MingweiSamuel changed the title [tuple_array_conversions]: move from complexity to pedantic [tuple_array_conversions]: move from complexity to nursery Jul 12, 2023
@Centri3
Copy link
Member

Centri3 commented Jul 13, 2023

Bit sad about this but it makes sense. Once it's been rewritten hopefully we can bump it up to pedantic, likely not complexity as the lost asymmetry is a big issue. Which is unfortunate since this lint was kinda meant as a learning tool.

@Centri3
Copy link
Member

Centri3 commented Jul 13, 2023

For example, which of the following is the most readable:

Will say though that IMO it's the third, it conveys the intent best (if it's not asymmetric) and even avoids an unnecessary closure which is pretty nice

@xFrednet xFrednet added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jul 13, 2023
@xFrednet
Copy link
Member

LGTM, thank you for the PR 👍 I believe this move makes sense for the time being.

The version says 1.72.0, we should be able to back port this move to beta.

r? @xFrednet

@bors r=Centri3,xFrednet

@bors
Copy link
Collaborator

bors commented Jul 13, 2023

📌 Commit 4102a30 has been approved by Centri3,xFrednet

It is now in the queue for this repository.

@rustbot rustbot assigned xFrednet and unassigned dswij Jul 13, 2023
@bors
Copy link
Collaborator

bors commented Jul 13, 2023

⌛ Testing commit 4102a30 with merge 631faa1...

@bors
Copy link
Collaborator

bors commented Jul 13, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Centri3,xFrednet
Pushing 631faa1 to master...

1 similar comment
@bors
Copy link
Collaborator

bors commented Jul 13, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Centri3,xFrednet
Pushing 631faa1 to master...

@bors bors merged commit 631faa1 into rust-lang:master Jul 13, 2023
5 checks passed
@Alexendoo Alexendoo removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jul 17, 2023
bors added a commit that referenced this pull request Jul 17, 2023
…Frednet

Move tuple_array_conversions to nursery

changelog: Move [`tuple_array_conversions`] to `nursery` (Now allow-by-default)
<!-- FIY: Ignore this change, if the commit gets backported and also #11146 -->
[#11172](#11172)

The nursery change got lost in #11146 and it ended up in pedantic, this puts it in nursery and gives something to backport

r? `@xFrednet`
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 17, 2023
…sery, r=xFrednet

Move tuple_array_conversions to nursery

changelog: Move [`tuple_array_conversions`] to `nursery` (Now allow-by-default)
<!-- FIY: Ignore this change, if the commit gets backported and also rust-lang/rust-clippy#11146 -->
[rust-lang#11172](rust-lang/rust-clippy#11172)

The nursery change got lost in rust-lang#11146 and it ended up in pedantic, this puts it in nursery and gives something to backport

r? `@xFrednet`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants