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

arbitrary_source_item_ordering: Make alphabetic ordering in module item groups optional #13718

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

decryphe
Copy link
Contributor

From feedback to the arbitrary_source_item_ordering lint after its inclusion in clippy 1.82, making alphabetic ordering within module item groups has turned out to be the most requested improvement. With this improvement, it is possible to make the lint perform certain top-level structural checks on modules (e.g. use statements and module inclusions at the top), but still leaving everything else up to the developer.

Implements parts of the suggestions from #13675. A catch-all-group is still to be implemented.

changelog: [arbitrary_source_item_ordering]: Make alphabetic ordering in module item groups optional (off by default)

…ult: off)

From feedback to this lint after its inclusion in clippy 1.82, this has
turned out to be the most requested improvement. With this improvement,
it is possible to make the lint check certain top-level structural
checks on modules (e.g. use statements and module inclusions at the top),
but still leaving everything else up to the developer.
@rustbot
Copy link
Collaborator

rustbot commented Nov 22, 2024

r? @y21

rustbot has assigned @y21.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 22, 2024
Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

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

Sorry for the wait, this change looks good to me. I have one question but it's not a blocker (although it would be good to decide now so we wouldn't need to change the behavior of this configuration later and break users)

@@ -676,6 +676,16 @@ The named groupings of different source item kinds within modules.
* [`arbitrary_source_item_ordering`](https://rust-lang.github.io/rust-clippy/master/index.html#arbitrary_source_item_ordering)


## `module-items-ordered-within-groups`
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense for this configuration to accept an array of group names similar to how source-item-ordering lets you configure it for specific kinds of items and default to an empty array? Or do you think that's not needed and a simple boolean is enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was mostly thinking that the config is getting convoluted in either case, but I fully agree that it would make sense to go for higher granularity here. I would like to have an option for "all", but would need to investigate how to best express that in TOML.

Preferrably I'd have the options of:

module-items-ordered-within-groups = "none" (being the default)
module-items-ordered-within-groups = ["mod", "use", "my_custom_group", ...]
module-items-ordered-within-groups = "all"

I'll put some thought into this in the coming days.

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.

3 participants