Skip to content

Conversation

promptkp
Copy link

fixes #12483


changelog: new [stacked_if_match] lint against if if and match match

@rustbot
Copy link
Collaborator

rustbot commented Aug 25, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Alexendoo (or someone else) some time within the next two weeks.

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 Aug 25, 2024
@bors
Copy link
Contributor

bors commented Aug 28, 2024

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

@alex-semenyuk
Copy link
Member

In theory cases with match if and if match should work? I would be nice to have examples what happens in this cases

@promptkp
Copy link
Author

promptkp commented Sep 1, 2024

Hi @alex-semenyuk, thank you for the comment. To prevent overlinting, stacked_if_match only lints against if if and match match. I'll add additional test cases for match if and if match.

Note: this is my first contribution to Clippy, so if there's a faster/cleaner way to implement this, please let me know!

@bors
Copy link
Contributor

bors commented Sep 3, 2024

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

@bors
Copy link
Contributor

bors commented Sep 22, 2024

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

@Alexendoo
Copy link
Member

A few times I've looked at this again trying to figure out what the rustfmt rules are but they seem difficult to predict, e.g. here's an if in the middle of a condition that gets formatted in the undesired way

    if 1 == if xxxxxxxxxxxxxxxxxx {
        111111111111
    } else {
        222222222222222
    } && x == y
    {
        3
    } else {
        4
    };

Maybe instead of trying to recreate the behaviour we should check the actual format directly, something like calling SourceMap::lookup_char_pos to check if the inner if's hi is one above the outer if's lo

@Alexendoo Alexendoo added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Feb 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 31, 2025

☔ The latest upstream changes (possibly d28d234) made this pull request unmergeable. Please resolve the merge conflicts.

@Jarcho
Copy link
Contributor

Jarcho commented Sep 17, 2025

Ping @promptkp from triage. Do you plan to return to working on this?

@Jarcho
Copy link
Contributor

Jarcho commented Oct 1, 2025

Closing since there's been no response. @promptkp if you wish to return to working on this feel free to reopen or create a new PR.

@Jarcho Jarcho closed this Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Ban Stacked if's

6 participants