-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
WIP: Lint unused features #152164
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: main
Are you sure you want to change the base?
WIP: Lint unused features #152164
Conversation
This comment has been minimized.
This comment has been minimized.
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 is neat! in the future, it would be easier to review if you split the rename into a separate commit from the change in behavior.
could you add some tests for this please?
cb9b84c to
cd83e12
Compare
|
Initial implementation completed. I plan to add more tests and check whether features in rustc are reported as unused correctly or not. |
This comment has been minimized.
This comment has been minimized.
cd83e12 to
2945856
Compare
This comment has been minimized.
This comment has been minimized.
2945856 to
36c0a20
Compare
This comment has been minimized.
This comment has been minimized.
36c0a20 to
2ddaf82
Compare
This comment has been minimized.
This comment has been minimized.
2ddaf82 to
fb08c95
Compare
This comment has been minimized.
This comment has been minimized.
fb08c95 to
38aefe4
Compare
This comment has been minimized.
This comment has been minimized.
38aefe4 to
0cda8d4
Compare
This comment has been minimized.
This comment has been minimized.
0cda8d4 to
2d2577f
Compare
This comment has been minimized.
This comment has been minimized.
2d2577f to
b67632e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a940d65 to
435090a
Compare
ec35e58 to
05cb32e
Compare
This comment has been minimized.
This comment has been minimized.
05cb32e to
b44e60c
Compare
This comment has been minimized.
This comment has been minimized.
b44e60c to
9909a6f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
402258f to
2e19ff0
Compare
This comment has been minimized.
This comment has been minimized.
2e19ff0 to
dbc424d
Compare
This comment has been minimized.
This comment has been minimized.
| // `restricted_std` is declared to mark std as unstable for certain targets, | ||
| // but it has no direct call sites to record usage, so it should never lint. | ||
| && f.as_str() != "restricted_std" |
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 is confusing to me — do you mean it's only checked downstream by a later invocation of the compiler? like, when std is no longer the local crate?
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 library feature is declared in
Lines 750 to 754 in f21b4c0
| // This is required to avoid an unstable error when `restricted-std` is not | |
| // enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std | |
| // is unconditional, so the unstable feature needs to be defined somewhere. | |
| #[unstable(feature = "restricted_std", issue = "none")] | |
| mod __restricted_std_workaround {} |
It is only on the private mod, so that it cannot be recorded as used in downstream crates, and will always be an unused feature.
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.
But I'm not sure it's the best way to solve this. Because we can define such features arbitrarily. And as we know they will be always unused, maybe users who use such features should allow unused_features manually or export a pub thing like pub mod workaround {} to make them used? 🤔
dbc424d to
b7f5529
Compare
This comment has been minimized.
This comment has been minimized.
b7f5529 to
5800ec9
Compare
This comment has been minimized.
This comment has been minimized.
5800ec9 to
ca05c07
Compare
|
Nice, CI has passes (finally :)), although I allowed |
Fixes #44232
Fixes #151752