Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check whether the next_node is else-less if in get_return_block #124917

Merged
merged 3 commits into from
May 20, 2024

Conversation

cardigan1008
Copy link
Contributor

@cardigan1008 cardigan1008 commented May 9, 2024

Fix #124819

@rustbot
Copy link
Collaborator

rustbot commented May 9, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@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 9, 2024
@rust-log-analyzer

This comment has been minimized.

Fix rust-lang#124819, where a if-less block causes a wrong output. It is
caused by get_return_block in get_fn_decl. In get_return_block,
when a else-less if expression is the tail expression, the check
for next_node will keep iterating. So it is necessary to make a
early return in the check.
@cardigan1008 cardigan1008 marked this pull request as ready for review May 9, 2024 16:37
@cardigan1008 cardigan1008 changed the title fix: Add if to check whether the previous node is Block Check whether the next_node is else-less if in get_return_block May 9, 2024
@pnkfelix
Copy link
Member

can you add a unit test illustrating the change?

(If you need help with what steps to use to add a test, feel free to ask; I'd probably start by reading this https://rustc-dev-guide.rust-lang.org/tests/ui.html )

@pnkfelix
Copy link
Member

@rustbot author

@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 14, 2024
@cardigan1008
Copy link
Contributor Author

Hi @pnkfelix I have updated the unit test following the instruction. If there's any mistake, feel free to ask me to change. Thanks!

@cardigan1008
Copy link
Contributor Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 16, 2024
@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 20, 2024

📌 Commit c811acb has been approved by pnkfelix

It is now in the queue for this repository.

@bors bors 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 May 20, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#124682 (Suggest setting lifetime in borrowck error involving types with elided lifetimes)
 - rust-lang#124917 (Check whether the next_node is else-less if in get_return_block)
 - rust-lang#125106 (coverage: Memoize and simplify counter expressions)
 - rust-lang#125173 (Remove `Rvalue::CheckedBinaryOp`)
 - rust-lang#125305 (add some codegen tests for issue 120493)
 - rust-lang#125314 ( Add an experimental feature gate for global registration)
 - rust-lang#125318 (Migrate `run-make/rustdoc-scrape-examples-whitespace` to `rmake.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ba1bb80 into rust-lang:master May 20, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 20, 2024
Rollup merge of rust-lang#124917 - cardigan1008:issue-124819, r=pnkfelix

Check whether the next_node is else-less if in get_return_block

Fix rust-lang#124819
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.

Incorrect span label when non-() else-less if is tail expression in -> () function
5 participants