Skip to content

lint: do not emit unreachable_code on become with diverging callee - #165539

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
epiglottis-cartilage:fix-become-unreachable-code
Nov 7, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
epiglottis-cartilage:fix-become-unreachable-code

Conversation

@epiglottis-cartilage

@epiglottis-cartilage epiglottis-cartilage commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #165536.

Exempts ExprKind::Become(..) from emitting unreachable_code when its inner call expression diverges, while preserving unreachable code warnings for any statements following become.

Changes

  • Add | ExprKind::Become(..) to the diverging child exemption list in compiler/rustc_hir_typeck/src/expr.rs.
  • Add tests/ui/explicit-tail-calls/become-diverging.rs.

@rustbot rustbot added F-explicit_tail_calls `#![feature(explicit_tail_calls)]` 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 Nov 6, 2026
@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @wesleywiser (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

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 20 candidates

}

fn caller() -> ! {
become callee();

@JonathanBrouwer JonathanBrouwer Nov 6, 2026 •

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.

while preserving unreachable code warnings for any statements following become

Could you also add a test for this in this file?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tests are added to check unreachable statements following become generate warnings.

@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 Nov 6, 2026
@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

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

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

@rust-bors

rust-bors Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit eea0d6f has been tentatively approved by JonathanBrouwer

It will be put into the queue for this repository once PR CI succeeds.

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

Rollup of 6 pull requests

Successful merges:

 - #165495 (rustdoc: Improve performance by skipping unneeded intermediate JSON serializations)
 - #165523 (remove stability attributes from intrinsics)
 - #165034 (allow configuring rustc_perf's path for out-of-tree uses of rustc_perf)
 - #165373 (use correct span for lifetimes with attributes)
 - #165539 (lint: do not emit unreachable_code on become with diverging callee)
 - #165556 (rustc_config: Replace `Option` with a custom enum for `--jobs` options)

> [!WARNING]
> This rollup conflicts with pending auto build #165548 and may need to be recreated if the pending build succeeds.
@rust-bors
rust-bors Bot merged commit 98574a6 into rust-lang:main Nov 7, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Nov 7, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup merge of #165539 - epiglottis-cartilage:fix-become-unreachable-code, r=JonathanBrouwer

lint: do not emit unreachable_code on become with diverging callee

<!--
Thank you for making the compiler better! What does this PR do?
-->

Fixes #165536.

Exempts `ExprKind::Become(..)` from emitting `unreachable_code` when its inner call expression diverges, while preserving unreachable code warnings for any statements following `become`.

### Changes

- Add `| ExprKind::Become(..)` to the diverging child exemption list in `compiler/rustc_hir_typeck/src/expr.rs`.
- Add `tests/ui/explicit-tail-calls/become-diverging.rs`.
@epiglottis-cartilage
epiglottis-cartilage deleted the fix-become-unreachable-code branch November 7, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-explicit_tail_calls `#![feature(explicit_tail_calls)]` 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.

[explicit_tail_calls] Spurious unreachable_code warning on 'become' with diverging function (-> !)

4 participants