Skip to content

Fix #[expect(dead_code)] liveness propagation#154377

Open
mu001999 wants to merge 1 commit intorust-lang:mainfrom
mu001999-contrib:fix/dead-code
Open

Fix #[expect(dead_code)] liveness propagation#154377
mu001999 wants to merge 1 commit intorust-lang:mainfrom
mu001999-contrib:fix/dead-code

Conversation

@mu001999
Copy link
Copy Markdown
Contributor

Fixes #154324
Fixes #152370 (cc @eggyal)

Previously, when traversing from a ComesFromAllowExpect::Yes item (i.e., with #[allow(dead_code)] or #[expect(dead_code)]), other ComesFromAllowExpect::Yes items reached during propagation would be updated to ComesFromAllowExpect::No and inserted into live_symbols. That caused dead_code lint couldn't be emitted correctly.

After this PR, ComesFromAllowExpect::Yes items no longer incorrectly update other ComesFromAllowExpect::Yes items during propagation or mark them live by mistake, then dead_code lint could behave as expected.

@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 Mar 25, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 25, 2026

r? @TaKO8Ki

rustbot has assigned @TaKO8Ki.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 69 candidates
  • Random selection from 12 candidates

@mu001999
Copy link
Copy Markdown
Contributor Author

@rustbot author

I realized that this would fail during secondary propagation. This still needs to be revised a bit.

@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 Mar 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 26, 2026

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

@mu001999
Copy link
Copy Markdown
Contributor Author

mu001999 commented Apr 7, 2026

oops, forgot to update the label

@rustbot ready

@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 Apr 7, 2026
No,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
Copy link
Copy Markdown
Contributor

@nikomatsakis nikomatsakis Apr 8, 2026

Choose a reason for hiding this comment

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

View changes since the review

Nit: I found this struct hard to understand, I think a doc comment that explains the role of these fields in terms of examples would be very helpful to future code readers :)

Copy link
Copy Markdown
Contributor Author

@mu001999 mu001999 Apr 9, 2026

Choose a reason for hiding this comment

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

Added, could you review this again? :)

@joshtriplett
Copy link
Copy Markdown
Member

See #152370 (comment) .

@joshtriplett
Copy link
Copy Markdown
Member

Test cases look good here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

5 participants