Skip to content

Conversation

Urgau
Copy link
Member

@Urgau Urgau commented Jun 8, 2025

This PR alters dead code analysis to always consider const _: () = { ... }; to be live.

This doesn't address the _name pattern from #142075.

Fixes #142104

@rustbot

This comment was marked as resolved.

@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 Jun 8, 2025
@Urgau
Copy link
Member Author

Urgau commented Jun 8, 2025

r? compiler

@rustbot rustbot assigned petrochenkov and unassigned Noratrieb Jun 8, 2025
@Urgau Urgau force-pushed the dead_code-const_ branch from 1ff6452 to 44317e2 Compare June 8, 2025 19:57
@petrochenkov
Copy link
Contributor

r=me with #142208 (comment) addressed.
@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 Jun 9, 2025
@Urgau Urgau force-pushed the dead_code-const_ branch from 44317e2 to fe970ee Compare June 9, 2025 13:46
@Urgau Urgau force-pushed the dead_code-const_ branch from fe970ee to 33beaba Compare June 9, 2025 13:48
@Urgau
Copy link
Member Author

Urgau commented Jun 9, 2025

@bors r=petrochenkov

@bors
Copy link
Collaborator

bors commented Jun 9, 2025

📌 Commit 33beaba has been approved by petrochenkov

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 9, 2025
bors added a commit that referenced this pull request Jun 9, 2025
Rollup of 5 pull requests

Successful merges:

 - #140767 (Stabilize `sha512`, `sm3` and `sm4` for x86)
 - #141001 (Make NonZero<char> possible)
 - #141993 (Use the in-tree `compiler-builtins` for the sysroot)
 - #142208 (Always consider `const _` items as live for dead code analysis)
 - #142238 (stabilize nonnull_provenance)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit facc5da into rust-lang:master Jun 9, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 9, 2025
rust-timer added a commit that referenced this pull request Jun 9, 2025
Rollup merge of #142208 - Urgau:dead_code-const_, r=petrochenkov

Always consider `const _` items as live for dead code analysis

This PR alters dead code analysis to always consider `const _: () = { ... };` to be live.

This doesn't address the `_name` pattern from #142075.

Fixes #142104
tgross35 pushed a commit to tgross35/compiler-builtins that referenced this pull request Jun 9, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#140767 (Stabilize `sha512`, `sm3` and `sm4` for x86)
 - rust-lang/rust#141001 (Make NonZero<char> possible)
 - rust-lang/rust#141993 (Use the in-tree `compiler-builtins` for the sysroot)
 - rust-lang/rust#142208 (Always consider `const _` items as live for dead code analysis)
 - rust-lang/rust#142238 (stabilize nonnull_provenance)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 10, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#140767 (Stabilize `sha512`, `sm3` and `sm4` for x86)
 - rust-lang/rust#141001 (Make NonZero<char> possible)
 - rust-lang/rust#141993 (Use the in-tree `compiler-builtins` for the sysroot)
 - rust-lang/rust#142208 (Always consider `const _` items as live for dead code analysis)
 - rust-lang/rust#142238 (stabilize nonnull_provenance)

r? `@ghost`
`@rustbot` modify labels: rollup
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.

Function only used in const assert is treated as dead code
6 participants