-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Improve dead code analysis for structs and traits defined locally #128637
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. |
☔ The latest upstream changes (presumably #128761) made this pull request unmergeable. Please resolve the merge conflicts. |
7759822
to
e400203
Compare
This comment has been minimized.
This comment has been minimized.
eab62e8
to
6f4b522
Compare
☔ The latest upstream changes (presumably #129046) made this pull request unmergeable. Please resolve the merge conflicts. |
559d82b
to
ae42684
Compare
Could you submit 1317d54 as a separate PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR contains a fundamental change for this lint: it tries to reason on types, and not just on the names that appear in the code. It is probably necessary to make the lint handle associated types, I'd like an explanation why it is necessary and why we can't just rely on HIR and typeck-output resolutions.
This comment has been minimized.
This comment has been minimized.
e4a31fa
to
4f81926
Compare
Just detecting more dead codes? I think removing more unused items is helpful. And we have detected unused inherit assoc types, although the feature is unstable for now.
We can only get trait TwoWayStrategy {
type Output;
fn use_early_reject() -> bool;
fn rejecting(a: usize, b: usize) -> Self::Output;
fn matching(a: usize, b: usize) -> Self::Output;
} I asked such things before in zulip |
4f81926
to
c7aaac2
Compare
@rustbot ready |
…r=compiler-errors Removes dead code from the compiler Detected by rust-lang#128637
…r=compiler-errors Removes dead code from the compiler Detected by rust-lang#128637
Rollup merge of rust-lang#129544 - mu001999-contrib:dead-code/clean, r=compiler-errors Removes dead code from the compiler Detected by rust-lang#128637
☔ The latest upstream changes (presumably #129595) made this pull request unmergeable. Please resolve the merge conflicts. |
c7aaac2
to
91be66f
Compare
☔ The latest upstream changes (presumably #129941) made this pull request unmergeable. Please resolve the merge conflicts. |
91be66f
to
aa1fb28
Compare
@cjgillot friendly ping |
aa1fb28
to
06752de
Compare
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
cc @pnkfelix
r? @compiler-errors