Skip to content

Fix if branch in op.rs#155043

Open
malezjaa wants to merge 1 commit intorust-lang:mainfrom
malezjaa:refactor-typecheck-op
Open

Fix if branch in op.rs#155043
malezjaa wants to merge 1 commit intorust-lang:mainfrom
malezjaa:refactor-typecheck-op

Conversation

@malezjaa
Copy link
Copy Markdown
Contributor

@malezjaa malezjaa commented Apr 9, 2026

I removed the if guard without thinking in #154223. Really sorry about this.

r? @hkBst

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 9, 2026

Failed to set assignee to hkBst: 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.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 9, 2026
@hkBst
Copy link
Copy Markdown
Member

hkBst commented Apr 9, 2026

This restores the old behavior, but I'm also curious why the relevant code should not run for AssignOp's.

Comment on lines +297 to +298
if by_ref_binop {
if let ty::Ref(_, _, mutbl) = method.sig.inputs()[1].kind() {
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Apr 9, 2026

Choose a reason for hiding this comment

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

View changes since the review

Remark: this condition itself seems a bit fishy, what's even more fishy is that zero tests are failing with or without this condition 🤔

This was added in 3ce4438 from PR #42281

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

matches!(op, Op::AssignOp(_)) but not by_ref_binop 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@eddyb seems you wrote this originally in 2017 :D

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Apr 9, 2026

@rustbot reroll

@adwinwhite
Copy link
Copy Markdown
Contributor

Okay, this condition adds an autoref adjustment to the RHS type of comparison operators.

It doesn't get catched by test suites probably because ref impl and value impl usually have the same return type.
E.g. Add<&Self> vs Add<Self>

@malezjaa, could you add a test case for this?

r? @adwinwhite

@rustbot rustbot assigned adwinwhite and unassigned davidtwco Apr 9, 2026
@adwinwhite
Copy link
Copy Markdown
Contributor

It does seems fishy. Let's land the fix first and think about regression test (or the condition's validity) later without worrying about unexpected breakages. I have no time to look into it right now.

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 9, 2026

📌 Commit d024e57 has been approved by adwinwhite

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 9, 2026
…adwinwhite

Fix if branch in op.rs

I removed the if guard without thinking in rust-lang#154223. Really sorry about this.

r? @hkBst
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 9, 2026
…adwinwhite

Fix if branch in op.rs

I removed the if guard without thinking in rust-lang#154223. Really sorry about this.

r? @hkBst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants