Skip to content

Do not consider binary operators as commutative by default#16420

Merged
dswij merged 1 commit intorust-lang:masterfrom
samueltardieu:issues/16416
Jan 20, 2026
Merged

Do not consider binary operators as commutative by default#16420
dswij merged 1 commit intorust-lang:masterfrom
samueltardieu:issues/16416

Conversation

@samueltardieu
Copy link
Copy Markdown
Member

@samueltardieu samueltardieu commented Jan 16, 2026

Only == (and thus !=) are supposed to be commutative according to Rust's documentation. Do not make assumptions about other operators whose meaning may depend on the types on which they apply. However, special-case operators known to be commutative for primitive types such as addition or multiplication.

changelog: [if_same_then_else]: do not consider binary operators commutative by default

Fixes #16416

Only `==` (and thus `!=`) are supposed to be commutative according to
Rust's documentation. Do not make assumptions about other operators
whose meaning may depend on the types on which they apply. However,
special-case operators known to be commutative for primitive types
such as addition or multiplication.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 16, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 16, 2026

r? @dswij

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

@dswij dswij added this pull request to the merge queue Jan 20, 2026
Merged via the queue into rust-lang:master with commit 4b98bd3 Jan 20, 2026
11 of 13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 20, 2026
@samueltardieu samueltardieu deleted the issues/16416 branch January 20, 2026 07:36
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.

Cargo clippy misidentifies blocks as identical

3 participants