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

Collapse if and if let chains in Clippy itself #14228

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Feb 16, 2025

This adds a collapse_let_chains config option to the collapsible_if lint. This lint is then applies to Clippy itself. This reduces the level of indentation in Clippy source code in many locations.

The first two commits are from PR #14231, the third one from PR #14233. They must be merged first (or as part of this PR).

If reviewed on GitHub, the last two commits of this PR are best looked at side by side, with whitespace differences turned off.

changelog: none

@rustbot
Copy link
Collaborator

rustbot commented Feb 16, 2025

r? @Centri3

rustbot has assigned @Centri3.
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 Feb 16, 2025
@samueltardieu samueltardieu marked this pull request as draft February 16, 2025 12:44
@samueltardieu samueltardieu force-pushed the push-ptpxkoyowrpq branch 3 times, most recently from 4eab1e1 to b68a741 Compare February 16, 2025 14:26
@samueltardieu samueltardieu marked this pull request as ready for review February 16, 2025 14:27
@samueltardieu samueltardieu force-pushed the push-ptpxkoyowrpq branch 3 times, most recently from 99ccf9c to b78eba0 Compare February 16, 2025 15:32
@samueltardieu
Copy link
Contributor Author

samueltardieu commented Feb 16, 2025

Way too many hits from lintcheck, will double check.

Edit: lintcheck from the CI seems to use clippy.toml from the project, so it sets the collapse-let-chains option. I'll have to find a way to disable this during the lintcheck lint.
Edit: solved through #14233

@samueltardieu samueltardieu marked this pull request as draft February 16, 2025 15:46
By default, lintcheck will use the `clippy.toml` file found at the
toplevel of the repository (`CARGO_MANIFEST_DIR`). This file is meant
for configuration of Clippy applied to Clippy sources.

This creates a new `lintcheck/ci-config/clippy.toml` file which is used
by the CI when running lintcheck. By default this uses the default
Clippy configuration.
@samueltardieu samueltardieu marked this pull request as ready for review February 16, 2025 16:50
@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Feb 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 16, 2025

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust-clippy.git master
$ git push --force-with-lease

The following commits are merge commits:

@samueltardieu
Copy link
Contributor Author

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

Those will disappear after the PR it depends on are merged – I'll push with a linear history then, which will contain the same content.

@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2025

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust-clippy.git master
$ git push --force-with-lease

The following commits are merge commits (since this message was last posted):

@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2025

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust-clippy.git master
$ git push --force-with-lease

The following commits are merge commits (since this message was last posted):

@rustbot
Copy link
Collaborator

rustbot commented Feb 18, 2025

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust-clippy.git master
$ git push --force-with-lease

The following commits are merge commits (since this message was last posted):

Due to its use of `Sugg::ast()` to combine `if` conditions together,
`collapsible_if` cannot keep comments located inside the conditions
or between the conditions in its suggestions. However, it is still
possible to warn about those situations and let the user fix their
code by themselves.

A new configuration option `lint_commented_code`, which is `true` by
default, opts out from this behavior.
Since `collapsible_if` is an early lint, it is not possible to
automatically check whether the `let_chains` unstable rustc feature is
enabled or not, as features are not available in the `EarlyContext`
object.
Those are warned about but not autofixed as the comments inside the `if`
conditions would be lost.
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2025

There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

You can start a rebase with the following commands:

$ # rebase
$ git pull --rebase https://github.com/rust-lang/rust-clippy.git master
$ git push --force-with-lease

The following commits are merge commits (since this message was last posted):

@samueltardieu
Copy link
Contributor Author

I'll put this on hold until let chains are stabilized.
r? ghost
@rustbot author

@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2025

Failed to set assignee to ghost: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@samueltardieu samueltardieu marked this pull request as draft February 23, 2025 22:02
@samueltardieu samueltardieu removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants