Skip to content

Marks ADT live if it appears in pattern #142485

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

Merged
merged 1 commit into from
Jun 21, 2025

Conversation

mu001999
Copy link
Contributor

@mu001999 mu001999 commented Jun 14, 2025

Marks ADT live if it appears in pattern, it implies the construction of the ADT.

  1. Then we can detect unused private ADTs impl Default, without special logics for Default and other std traits.
  2. We can also remove rustc_trivial_field_reads on Default, and the logic in should_ignore_item (introduced by Detect unused structs which derived Default #126302).

Fixes #120770

Extracted from #128637.
r? @petrochenkov

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 14, 2025
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 20, 2025

📌 Commit 52167e0 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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2025
bors added a commit that referenced this pull request Jun 21, 2025
Rollup of 8 pull requests

Successful merges:

 - #142384 (Bringing `rustc_rayon_core` in tree as `rustc_thread_pool`)
 - #142476 (Insert parentheses around binary operation with attribute)
 - #142485 (Marks ADT live if it appears in pattern)
 - #142571 (Reason about borrowed classes in CopyProp.)
 - #142677 (Add CI check to ensure that rustdoc JSON `FORMAT_VERSION` is correctly updated)
 - #142716 (Adjust `with_generic_param_rib`.)
 - #142756 (Make `Clone` a `const_trait`)
 - #142765 (rustc_target: document public AbiMap-related fn and variants)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c93fac7 into rust-lang:master Jun 21, 2025
10 checks passed
@rustbot rustbot added this to the 1.89.0 milestone Jun 21, 2025
rust-timer added a commit that referenced this pull request Jun 21, 2025
Rollup merge of #142485 - mu001999-contrib:dead-code/adt-pattern, r=petrochenkov

Marks ADT live if it appears in pattern

Marks ADT live if it appears in pattern, it implies the construction of the ADT.
1. Then we can detect unused private ADTs impl `Default`, without special logics for `Default` and other std traits.
2. We can also remove `rustc_trivial_field_reads` on `Default`, and the logic in `should_ignore_item` (introduced by #126302).

Fixes #120770

Extracted from #128637.
r? `@petrochenkov`
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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dead_code false positive introduced in rustc 1.78.0-nightly (8ace7ea1f 2024-02-07)
5 participants