Skip to content

make ReturnsVisitor more accurate - #166013

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
folkertdev:return-visitor
Nov 24, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
folkertdev:return-visitor

Conversation

@folkertdev

@folkertdev folkertdev commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

I want to use this visitor for #147697, but it currently has some inaccuracies, so:

  • keep going when finding a return expression; there might be nested early returns.
  • just also look in the if condition and match scrutinee.
  • keep track of blocks/loops in tail position: a break to them is effectively a return

The diff is kind of a mess, it's probably easier to just look at the after version for the logic. The second commit does show the improvement in error messages nicely.

- keep doing when finding a return expression; there might be nested early returns.
- keep track of blocks/loops in tail position: a break to them is effectively a return
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 15, 2026
@folkertdev
folkertdev marked this pull request as ready for review November 16, 2026 09:46
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 16, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 16, 2026
@rustbot

rustbot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
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 79 candidates
  • Random selection from 19 candidates

@folkertdev

Copy link
Copy Markdown
Contributor Author

r? JonathanBrouwer

@rustbot rustbot assigned JonathanBrouwer and unassigned TaKO8Ki Nov 23, 2026

@JonathanBrouwer JonathanBrouwer 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.

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.

Could you add //@ run-rustfix to this test?

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.

Oh actually that won't work because we have both the impl suggestion and the Box<dyn> suggestion... nvm

@JonathanBrouwer

Copy link
Copy Markdown
Member

Nvm
@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 44568ec has been approved by JonathanBrouwer

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 Nov 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 24, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #166385 ([PERF] Inline some attribute parsing code)
 - #166013 (make `ReturnsVisitor` more accurate )
 - #166033 (Abby: move span out of leaf region constraint)
 - #166088 (Make rigid alias invalidation explicit when transitioning to PostAnalysis)
 - #166365 (Drop references to codebuild)
 - #166399 (Add safety section for intrinsic volatile operations)
 - #166439 (remove some incorrect docs from volatile intrinsics)
 - #166445 (fix test enum-repr-abi)
@rust-bors
rust-bors Bot merged commit 39d8288 into rust-lang:main Nov 24, 2026
14 checks passed
rust-bors Bot pushed a commit that referenced this pull request Nov 24, 2026
Rollup merge of #166013 - folkertdev:return-visitor, r=JonathanBrouwer

make `ReturnsVisitor` more accurate

I want to use this visitor for #147697, but it currently has some inaccuracies, so:

- keep going when finding a return expression; there might be nested early returns.
- just also look in the `if` condition and `match` scrutinee.
- keep track of blocks/loops in tail position: a break to them is effectively a return

The diff is kind of a mess, it's probably easier to just look at the after version for the logic. The second commit does show the improvement in error messages nicely.
@rustbot rustbot added this to the 1.102.0 milestone Nov 24, 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.

4 participants