Draft
Conversation
This comment has been minimized.
This comment has been minimized.
jyn514
reviewed
Feb 5, 2026
a3c0247 to
cb9b84c
Compare
cb9b84c to
cd83e12
Compare
Contributor
Author
|
Initial implementation completed. I plan to add more tests and check whether features in rustc are reported as unused correctly or not. |
jyn514
reviewed
Feb 5, 2026
Comment on lines
+44
to
+100
| pub fn unused_features(&self) -> Vec<(Symbol, Span)> { | ||
| let used_features = USED_FEATURES.lock().unwrap(); | ||
| self.enabled_features_iter_stable_order() | ||
| .filter(|(f, _)| !used_features.contains(f)) | ||
| .collect() | ||
| } | ||
|
|
||
| /// Is the given feature enabled (via `#[feature(...)]`)? | ||
| pub fn enabled(&self, feature: Symbol) -> bool { | ||
| USED_FEATURES.lock().unwrap().insert(feature); | ||
| self.features.enabled(feature) | ||
| } | ||
|
|
||
| /// Returns a list of [`EnabledLangFeature`] with info about: | ||
| /// | ||
| /// - Feature gate name. | ||
| /// - The span of the `#[feature]` attribute. | ||
| /// - For stable language features, version info for when it was stabilized. | ||
| pub fn enabled_lang_features(&self) -> &Vec<EnabledLangFeature> { | ||
| self.features.enabled_lang_features() | ||
| } | ||
|
|
||
| pub fn enabled_lib_features(&self) -> &Vec<EnabledLibFeature> { | ||
| self.features.enabled_lib_features() | ||
| } | ||
|
|
||
| pub fn enabled_features(&self) -> &FxHashSet<Symbol> { | ||
| &self.features.enabled_features() | ||
| } | ||
|
|
||
| /// Returns a iterator of enabled features in stable order. | ||
| pub fn enabled_features_iter_stable_order( | ||
| &self, | ||
| ) -> impl Iterator<Item = (Symbol, Span)> + Clone { | ||
| self.features.enabled_features_iter_stable_order() | ||
| } | ||
|
|
||
| pub fn dump_feature_usage_metrics( | ||
| &self, | ||
| metrics_path: PathBuf, | ||
| ) -> Result<(), Box<dyn std::error::Error>> { | ||
| self.features.dump_feature_usage_metrics(metrics_path) | ||
| } | ||
|
|
||
| /// Some features are known to be incomplete and using them is likely to have | ||
| /// unanticipated results, such as compiler crashes. We warn the user about these | ||
| /// to alert them. | ||
| pub fn incomplete(&self, feature: Symbol) -> bool { | ||
| self.features.incomplete(feature) | ||
| } | ||
|
|
||
| /// Some features are internal to the compiler and standard library and should not | ||
| /// be used in normal projects. We warn the user about these to alert them. | ||
| pub fn internal(&self, feature: Symbol) -> bool { | ||
| self.features.internal(feature) | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
i think for incremental soundness, none of these can be used outside the query system, right? maybe document that?
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
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.
Fixes #44232
Fixes #151752