diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2025-10-02 20:54:47 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2025-10-02 21:43:14 +0000 |
| commit | a5c9030271d48456ffefca83a416f0ee863ba965 (patch) | |
| tree | 13ba5575373fff78c597c33a61094742846e4515 /compiler/rustc_feature | |
| parent | 5c7ae0c7ed184c603e5224604a9f33ca0e8e0b36 (diff) | |
| download | rust-a5c9030271d48456ffefca83a416f0ee863ba965.tar.gz rust-a5c9030271d48456ffefca83a416f0ee863ba965.zip | |
Extract common logic for iterating over features
Two places doing the same thing is enough to motivate me to extract this to a method :)
Diffstat (limited to 'compiler/rustc_feature')
| -rw-r--r-- | compiler/rustc_feature/src/unstable.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index e63f29a9570..8397cd294e0 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -93,6 +93,16 @@ impl Features { &self.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.enabled_lang_features + .iter() + .map(|feat| (feat.gate_name, feat.attr_sp)) + .chain(self.enabled_lib_features.iter().map(|feat| (feat.gate_name, feat.attr_sp))) + } + /// Is the given feature enabled (via `#[feature(...)]`)? pub fn enabled(&self, feature: Symbol) -> bool { self.enabled_features.contains(&feature) |
