Skip to content

Enhance collapsible_match to cover if-elses#16560

Merged
llogiq merged 2 commits intorust-lang:masterfrom
profetia:issue16558
Feb 22, 2026
Merged

Enhance collapsible_match to cover if-elses#16560
llogiq merged 2 commits intorust-lang:masterfrom
profetia:issue16558

Conversation

@profetia
Copy link
Copy Markdown
Member

@profetia profetia commented Feb 13, 2026

Closes #16558

changelog: [collapsible_match] extend to cover if-elses

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 13, 2026

Some changes occurred in clippy_lints/src/doc

cc @notriddle

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Feb 13, 2026

r? @llogiq

rustbot has assigned @llogiq.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 13, 2026

Lintcheck changes for 5be3049

Lint Added Removed Changed
clippy::collapsible_match 15 0 1

This comment will be updated if you push new changes

@llogiq
Copy link
Copy Markdown
Contributor

llogiq commented Feb 22, 2026

Looks good to me. Thank you!

@llogiq llogiq added this pull request to the merge queue Feb 22, 2026
Merged via the queue into rust-lang:master with commit ad08bd6 Feb 22, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 22, 2026
meditationmind added a commit to meditationmind/serenity that referenced this pull request Feb 26, 2026
Revert code change and use `expect(clippy::collapsible_match)` instead to maintain consistent event handler structure in examples. New errors caused by: rust-lang/rust-clippy#16560
meditationmind added a commit to meditationmind/serenity that referenced this pull request Mar 1, 2026
Revert code change and use `expect(clippy::collapsible_match)` instead to maintain consistent event handler structure in examples. New errors caused by: rust-lang/rust-clippy#16560
@nbdd0121
Copy link
Copy Markdown
Member

nbdd0121 commented Mar 1, 2026

I think this warning should not trigger if clippy::collapsible_if is allowed.

meditationmind added a commit to meditationmind/serenity that referenced this pull request Mar 2, 2026
Revert code change and use `expect(clippy::collapsible_match)` instead to maintain consistent event handler structure in examples. New errors caused by: rust-lang/rust-clippy#16560
@mkj
Copy link
Copy Markdown

mkj commented Mar 6, 2026

Was this meant to change behaviour without else? I'm hitting it on code without any else, reverting 904a750 removes the warning. (Personally I prefer the code not collapsed in this case).

warning: this `if` can be collapsed into the outer `match`
   --> pldm-fw/src/fd.rs:719:17
    |
719 | /                 if dev.now() - self.update_timestamp_fd_t1 > Self::FD_T1_TIMEOUT
720 | |                 {
721 | |                     // TODO cancel any updates in Device?
722 | |                     self.set_state_idle_timeout();
723 | |                 }
    | |_________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
    = note: `#[warn(clippy::collapsible_match)]` on by default
help: collapse nested if block
    |
718 ~             State::Idle { .. }
719 |                 if dev.now() - self.update_timestamp_fd_t1 > Self::FD_T1_TIMEOUT
720 ~                 => {
721 |                     // TODO cancel any updates in Device?
722 |                     self.set_state_idle_timeout();
723 ~                 }
    |

code is
https://github.com/CodeConstruct/mctp-rs/blob/114dee1a7cfbae601ce11901b20516ebe217a4b2/pldm-fw/src/fd.rs#L714-L726

@samueltardieu
Copy link
Copy Markdown
Member

It looks like this is causing bugs in the latest release: #16875, #16864 (fixed in beta) , and #16860 (in less than 48 hours)
Ping @profetia @llogiq

@profetia
Copy link
Copy Markdown
Member Author

#16749 fixes a few of the bugs. I will also look into the new ones.

mkj added a commit to CodeConstruct/mctp-rs that referenced this pull request May 4, 2026
collapsible_match was extended to cover if statements.
The existing code intent is clearer than with collapsed statements, so
disable the check.

clippy changed in rust-lang/rust-clippy#16560

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend collapsible_match to cover if-elses

6 participants