Skip to content

Consider captures to be used by closures that unwind#152103

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
eggyal:caught-divergence-not-unused
Feb 16, 2026
Merged

Consider captures to be used by closures that unwind#152103
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
eggyal:caught-divergence-not-unused

Conversation

@eggyal
Copy link
Contributor

@eggyal eggyal commented Feb 4, 2026

Assignments to a captured variable within a diverging closure should not be considered unused if the divergence is caught.

This patch considers such assignments/captures to be used by diverging closures irrespective of whether the divergence is caught, but better a false negative unused lint than a false positive one (the latter having caused a stable-to-stable regression).

Fixes #152079
r? compiler

Assignments to a captured variable within a diverging closure should not
be considered unused if the divergence is caught.

This patch considers such assignments/captures to be used by diverging
closures irrespective of whether the divergence is caught, but better a
false negative unused lint than a false positive one (the latter having
caused a stable-to-stable regression).
@rustbot
Copy link
Collaborator

rustbot commented Feb 4, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Feb 4, 2026
@eggyal eggyal force-pushed the caught-divergence-not-unused branch from 58292e2 to be5d5f2 Compare February 14, 2026 10:45
@rustbot
Copy link
Collaborator

rustbot commented Feb 14, 2026

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

@eggyal eggyal force-pushed the caught-divergence-not-unused branch from be5d5f2 to 58292e2 Compare February 14, 2026 10:48
@eggyal
Copy link
Contributor Author

eggyal commented Feb 14, 2026

Sorry, was on the wrong branch!!

@cjgillot
Copy link
Contributor

InlineAsm can unwind too. Should we add it?

r=me either way

@eggyal
Copy link
Contributor Author

eggyal commented Feb 14, 2026

Can it? https://doc.rust-lang.org/nightly/reference/inline-assembly.html#r-asm.rules.unwind :

  • Behavior is undefined if execution unwinds out of the assembly code.
    • This also applies if the assembly code calls a function which then unwinds.

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 14, 2026

r? cjgillot

@rustbot rustbot assigned cjgillot and unassigned BoxyUwU Feb 14, 2026
@cjgillot
Copy link
Contributor

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

📌 Commit 58292e2 has been approved by cjgillot

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 Feb 15, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 16, 2026
…d, r=cjgillot

Consider captures to be used by closures that unwind

Assignments to a captured variable within a diverging closure should not be considered unused if the divergence is caught.

This patch considers such assignments/captures to be used by diverging closures irrespective of whether the divergence is caught, but better a false negative unused lint than a false positive one (the latter having caused a stable-to-stable regression).

Fixes rust-lang#152079
r? compiler
rust-bors bot pushed a commit that referenced this pull request Feb 16, 2026
Rollup of 4 pull requests

Successful merges:

 - #152103 (Consider captures to be used by closures that unwind)
 - #152474 (Implement opt-bisect-limit for MIR)
 - #152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`)
 - #152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`)
rust-bors bot pushed a commit that referenced this pull request Feb 16, 2026
Rollup of 4 pull requests

Successful merges:

 - #152103 (Consider captures to be used by closures that unwind)
 - #152474 (Implement opt-bisect-limit for MIR)
 - #152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`)
 - #152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`)
rust-bors bot pushed a commit that referenced this pull request Feb 16, 2026
Rollup of 6 pull requests

Successful merges:

 - #148206 (Deduplicated float tests and unified in floats/mod.rs)
 - #150601 (support c-variadic functions in `rustc_const_eval`)
 - #152103 (Consider captures to be used by closures that unwind)
 - #152296 (Port `rust_nonnull_optimization_guaranteed` and `rustc_do_not_const_check` to the new attribute parser)
 - #152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`)
 - #152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`)

Failed merges:

 - #152512 (core: Implement feature `float_exact_integer_constants`)
@rust-bors rust-bors bot merged commit c9a7f8a into rust-lang:main Feb 16, 2026
22 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 16, 2026
rust-timer added a commit that referenced this pull request Feb 16, 2026
Rollup merge of #152103 - eggyal:caught-divergence-not-unused, r=cjgillot

Consider captures to be used by closures that unwind

Assignments to a captured variable within a diverging closure should not be considered unused if the divergence is caught.

This patch considers such assignments/captures to be used by diverging closures irrespective of whether the divergence is caught, but better a false negative unused lint than a false positive one (the latter having caused a stable-to-stable regression).

Fixes #152079
r? compiler
@eggyal
Copy link
Contributor Author

eggyal commented Feb 16, 2026

Nominating for beta backport since this fixes a regression in 1.92.

@rustbot label beta-nominated

@rustbot rustbot added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Feb 16, 2026
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 17, 2026
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#148206 (Deduplicated float tests and unified in floats/mod.rs)
 - rust-lang/rust#150601 (support c-variadic functions in `rustc_const_eval`)
 - rust-lang/rust#152103 (Consider captures to be used by closures that unwind)
 - rust-lang/rust#152296 (Port `rust_nonnull_optimization_guaranteed` and `rustc_do_not_const_check` to the new attribute parser)
 - rust-lang/rust#152648 (Remove timing assertion from `oneshot::send_before_recv_timeout`)
 - rust-lang/rust#152686 (bootstrap: Inline the `is_tool` check for setting `-Zforce-unstable-if-unmarked`)

Failed merges:

 - rust-lang/rust#152512 (core: Implement feature `float_exact_integer_constants`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-nominated Nominated for backporting to the compiler in the beta channel. 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.

unused_assignments false positive on diverging path

4 participants