-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve dead code analysis for structs and traits defined locally #128637
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
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in tests/ui/sanitizer cc @rust-lang/project-exploit-mitigations, @rcvalle |
This comment has been minimized.
This comment has been minimized.
02e0843
to
edee22b
Compare
This comment has been minimized.
This comment has been minimized.
edee22b
to
dda1f0d
Compare
This comment has been minimized.
This comment has been minimized.
dda1f0d
to
8507664
Compare
Please separate this into separate commits each implementing an individual tweak to the dead code analysis, with the tests adjusted at each commit so I can see the fallout from each change specifically. It's very difficult to map the changes to the UI tests to each code change without that. --- I want to think very hard about each of these changes to determine if there are any false positives that are caused by each change, and that is harder to do with a single commit. Also, if you want, please open a separate PR that removes the dead code from the compiler/standard library that is now detected after these changes. That can be landed separately. |
This comment has been minimized.
This comment has been minimized.
865ba84
to
7759822
Compare
@compiler-errors I have separated this to separate commits. |
This comment was marked as resolved.
This comment was marked as resolved.
7759822
to
e400203
Compare
This comment has been minimized.
This comment has been minimized.
eab62e8
to
6f4b522
Compare
This comment was marked as resolved.
This comment was marked as resolved.
559d82b
to
ae42684
Compare
Could you submit 1317d54 as a separate PR? |
48cd073
to
994b713
Compare
This comment has been minimized.
This comment has been minimized.
I don't have time to do review any more. |
994b713
to
e482d0b
Compare
Busy with bootstrap things. |
r? estebank |
r? compiler |
I reviewed one of the predecessors to this PR and my experience can be summarized by this comment #122382 (comment)
because neither the code itself nor its explanations were clear enough to understand what's going on, so I'm not really enthusiastic about reviewing it again. @mu001999 |
Reminder, once the PR becomes ready for a review, use |
@petrochenkov ok, I'll turn these commits into separate PRs |
link to #141407, contains just test additions/modifications and refactorings |
…r, r=petrochenkov Refactor the two-phase check for impls and impl items Refactor the two-phase dead code check to make the logic clearer and simpler: 1. adding assoc fn and impl into `unsolved_items` directly during the initial construction of the worklist 2. converge the logic of checking whether assoc fn and impl are used to `item_should_be_checked`, and the item is considered used only when its corresponding trait and Self adt are used This PR only refactors as much as possible to avoid affecting the original functions. However, due to the adjustment of the order of checks, the test results are slightly different, but overall, there is no regression problem Extracted from rust-lang#128637. r? petrochenkov
…r, r=petrochenkov Refactor the two-phase check for impls and impl items Refactor the two-phase dead code check to make the logic clearer and simpler: 1. adding assoc fn and impl into `unsolved_items` directly during the initial construction of the worklist 2. converge the logic of checking whether assoc fn and impl are used to `item_should_be_checked`, and the item is considered used only when its corresponding trait and Self adt are used This PR only refactors as much as possible to avoid affecting the original functions. However, due to the adjustment of the order of checks, the test results are slightly different, but overall, there is no regression problem Extracted from rust-lang#128637. r? petrochenkov
Refactor the two-phase check for impls and impl items Refactor the two-phase dead code check to make the logic clearer and simpler: 1. adding assoc fn and impl into `unsolved_items` directly during the initial construction of the worklist 2. converge the logic of checking whether assoc fn and impl are used to `item_should_be_checked`, and the item is considered used only when its corresponding trait and Self adt are used This PR only refactors as much as possible to avoid affecting the original functions. However, due to the adjustment of the order of checks, the test results are slightly different, but overall, there is no regression problem Extracted from #128637. r? petrochenkov try-job: dist-aarch64-linux
Refactor the two-phase check for impls and impl items Refactor the two-phase dead code check to make the logic clearer and simpler: 1. adding assoc fn and impl into `unsolved_items` directly during the initial construction of the worklist 2. converge the logic of checking whether assoc fn and impl are used to `item_should_be_checked`, and the item is considered used only when its corresponding trait and Self adt are used This PR only refactors as much as possible to avoid affecting the original functions. However, due to the adjustment of the order of checks, the test results are slightly different, but overall, there is no regression problem Extracted from #128637. r? petrochenkov try-job: dist-aarch64-linux
…r, r=petrochenkov Refactor the two-phase check for impls and impl items Refactor the two-phase dead code check to make the logic clearer and simpler: 1. adding assoc fn and impl into `unsolved_items` directly during the initial construction of the worklist 2. converge the logic of checking whether assoc fn and impl are used to `item_should_be_checked`, and the item is considered used only when its corresponding trait and Self adt are used This PR only refactors as much as possible to avoid affecting the original functions. However, due to the adjustment of the order of checks, the test results are slightly different, but overall, there is no regression problem Fixes rust-lang#127911 Fixes rust-lang#128839 Extracted from rust-lang#128637. r? petrochenkov try-job: dist-aarch64-linux
This PR does some refactor and improvement on the dead code analysis, and doesn't lint pub structs.
Default
, without adding special logics forDefault
rustc_trivial_field_reads
onDefault
, and the logic inshould_ignore_item
&Foo
/[Foo]
thingsFixes #120770
Fixes #126729
Fixes #127911
Fixes #128839