Skip to content

fix misleading diagnostics and improve diagnostics of return type mismatch - #162926

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Hamdan-Khan:return-type-mismatch-diagnostics
Oct 11, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
Hamdan-Khan:return-type-mismatch-diagnostics

Conversation

@Hamdan-Khan

@Hamdan-Khan Hamdan-Khan commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Fix misleading diagnostics and improve diagnostics of return type mismatch

  • Fixed misleading suggestions of adding a return and semicolon expression to an expression already in return position by adding a return position check.

  • Fixed duplicate emission of error 277 by de-duplicateing the suggestion suggest_missing_break_or_return_expr, where a failed normalization leads to E277

fixes: #162271

@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 Sep 17, 2026
@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
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 77 candidates
  • Random selection from 22 candidates

@mati865

mati865 commented Sep 17, 2026

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned tiif and unassigned mati865 Sep 17, 2026
@tiif

tiif commented Sep 27, 2026

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned TaKO8Ki and unassigned tiif Sep 27, 2026
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 28, 2026
…match

fixed misleading suggestions of adding a return and semicolon expression to an expression already in return position by adding a return position check.

fixed duplicate emission of error 277 by de-duplicateing the suggestion `suggest_missing_break_or_return_expr`, where a failed normalization leads to E277
@Hamdan-Khan
Hamdan-Khan force-pushed the return-type-mismatch-diagnostics branch from 706c0b2 to c608702 Compare September 30, 2026 17:29
@rustbot

rustbot commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Sep 30, 2026
@Hamdan-Khan

Copy link
Copy Markdown
Contributor Author

Hey @TaKO8Ki , sorry for the ping. Mind taking a look at this when you're free?

@mejrs

mejrs commented Oct 7, 2026

Copy link
Copy Markdown
Member

r? me

@rustbot rustbot assigned mejrs and unassigned TaKO8Ki Oct 7, 2026

@mejrs mejrs left a comment •

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.

@bors r+ rollup

Thanks for working on this and sorry about the reviewer hot potatoing 😅

View changes since this review

@rust-bors

rust-bors Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c608702 has been approved by mejrs

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 Oct 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 10, 2026
…iagnostics, r=mejrs

fix misleading diagnostics and improve diagnostics of return type mismatch

Fix misleading diagnostics and improve diagnostics of return type mismatch

- Fixed misleading suggestions of adding a return and semicolon expression to an expression already in return position by adding a return position check.

- Fixed duplicate emission of error 277 by de-duplicateing the suggestion `suggest_missing_break_or_return_expr`, where a failed normalization leads to E277

fixes:  rust-lang#162271
rust-bors Bot pushed a commit that referenced this pull request Oct 10, 2026
…uwer

Rollup of 3 pull requests

Successful merges:

 - #163999 ([tiny] Show trait span for associated item with similar name)
 - #162926 (fix misleading diagnostics and improve diagnostics of return type mismatch)
 - #164075 (set aliases in closure error bodies to rigid with next-solver)
rust-bors Bot pushed a commit that referenced this pull request Oct 11, 2026
Rollup of 8 pull requests

Successful merges:

 - #163402 (test-float-parse: Share one table of powers of two sized for f64)
 - #163999 ([tiny] Show trait span for associated item with similar name)
 - #164020 (deduced_param_attrs for unit type offers no benefit)
 - #162926 (fix misleading diagnostics and improve diagnostics of return type mismatch)
 - #164075 (set aliases in closure error bodies to rigid with next-solver)
 - #164100 (More `tests/rustdoc-html` cleanups)
 - #164110 (callconv: mips64: Clarify why padding floats with integer args is correct)
 - #164120 (tests: Update duplicated-path-in-error message on musl hosts)
@rust-bors
rust-bors Bot merged commit 65fb697 into rust-lang:main Oct 11, 2026
13 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 11, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 11, 2026
Rollup merge of #162926 - Hamdan-Khan:return-type-mismatch-diagnostics, r=mejrs

fix misleading diagnostics and improve diagnostics of return type mismatch

Fix misleading diagnostics and improve diagnostics of return type mismatch

- Fixed misleading suggestions of adding a return and semicolon expression to an expression already in return position by adding a return position check.

- Fixed duplicate emission of error 277 by de-duplicateing the suggestion `suggest_missing_break_or_return_expr`, where a failed normalization leads to E277

fixes:  #162271
@Hamdan-Khan

Copy link
Copy Markdown
Contributor Author

@bors r+ rollup

Thanks for working on this and sorry about the reviewer hot potatoing 😅

View changes since this review

Thanks! Glad I could help :)

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.

Poor errors from type-mismatched early return when the return type is impl Future

6 participants