Repository navigation
Dead code refactor - #164913
Draft
tehforsch wants to merge 2 commits into
Draft
Dead code refactor#164913tehforsch wants to merge 2 commits into
tehforsch wants to merge 2 commits into
Conversation
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Member
I think this is a bugfix :) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While working on #164217, I noticed a lot of complex interactions between
allow(dead_code)/expect(dead_code),dead_code_pub_in_binaryand the newly introduced trivial usages. In particular, the logic for deciding when to explore an impl item based on the lint level and liveness of its trait and type became very complicated.This is an attempt to reduce the whole problem to a simpler structure in which the exact rules become a bit clearer.
This introduces is a
Livenesstype which defines whether we currently consider an item "live" because it is 1. used from a live seed, such asmain, 2. publically reachable 3. at allow/expect lint level:This introduces a strict hierarchy. When an item is used in
main, we don't care anymore if it is also public in the binary. If a type is public, we don't care if it is also annotated with#[allow(dead_code)](we do care forexpect, but we can defer handling that to the actual lint emission).The live symbols map then effectively becomes
LocalDefIdMap<Liveness>with "monotonically increasing" entries, i.e. we never change an entry fromLivetoPublic, for example.Doing so has a few implications:
WorkItemnow gets rid ofownandpropagatedComesFromAllowExpectstatus. Instead it carries only aLiveness.Liveness.scannedmap is removed entirely. We only insert new work items if the newLivenessis greater than the already known one for that item.get_impl_or_impl_item_liveness). The rules and edge cases are explicit and contained in a single function.This PR is purely refactoring. Allowing
#[rustc_trivial_field_reads]annotations can then be done in a separate PR, but is a lot simpler now since its mainly a matter of introducing aLivenesslevel belowAllowExpectand tracing the usage sites properly.There is a difference in behavior between
mainand this PR:On
main, only the unfulfilledexpectformethod()is reported, whereas this branch reports both. I wasn't sure whether this is a regression or a bugfix, so I haven't fixed this yet