Skip to content

Don't suggest semicolon after if expression closing brace#157175

Open
Unique-Usman wants to merge 1 commit into
rust-lang:mainfrom
Unique-Usman:ua/syntatic
Open

Don't suggest semicolon after if expression closing brace#157175
Unique-Usman wants to merge 1 commit into
rust-lang:mainfrom
Unique-Usman:ua/syntatic

Conversation

@Unique-Usman
Copy link
Copy Markdown
Contributor

@Unique-Usman Unique-Usman commented May 30, 2026

When a type mismatch occurs inside an if expression, the compiler incorrectly suggests adding a semicolon after the closing brace. This doesn't fix the error. The fix excludes all if expressions from the suggest_semicolon_at_end suggestion in coercion.rs.

Fix: #156621

@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 May 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 30, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
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: compiler
  • compiler expanded to 73 candidates
  • Random selection from 17 candidates

@Unique-Usman
Copy link
Copy Markdown
Contributor Author

r? @estebank

@rustbot rustbot assigned estebank and unassigned davidtwco May 30, 2026
Comment thread compiler/rustc_hir_typeck/src/coercion.rs
Comment thread compiler/rustc_hir_typeck/src/coercion.rs
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 30, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

When a type mismatch occurs inside an if expression, the compiler
incorrectly suggests adding a semicolon after the closing brace.
This doesn't fix the error. The fix excludes all if expressions
from the suggest_semicolon_at_end suggestion in coercion.rs.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
|
= note: expected unit type `()`
found mutable reference `&mut V`
help: consider using a semicolon here
Copy link
Copy Markdown
Member

@Kivooeo Kivooeo May 31, 2026

Choose a reason for hiding this comment

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

(not related to this pr)

eh, what a wording of this help, why not something "at the end of the statement", i guess it should explain somehow why this requiers semicolon here

View changes since the review

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r=JonathanBrouwer,Kivooeo rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 31, 2026

📌 Commit fc7fa89 has been approved by JonathanBrouwer,Kivooeo

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 31, 2026
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.

Syntactically incorrect code suggestion for missing semicolon in if without else

6 participants