Skip to content

Commit a5e9d3e

Browse files
authored
Unrolled build for #147277
Rollup merge of #147277 - fee1-dead-contrib:featiter, r=Zalathar Extract common logic for iterating over features Two places doing the same thing is enough to motivate me to extract this to a method :)
2 parents 7950f24 + a5c9030 commit a5e9d3e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
622622
}
623623

624624
fn check_incompatible_features(sess: &Session, features: &Features) {
625-
let enabled_lang_features =
626-
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
627-
let enabled_lib_features =
628-
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
629-
let enabled_features = enabled_lang_features.chain(enabled_lib_features);
625+
let enabled_features = features.enabled_features_iter_stable_order();
630626

631627
for (f1, f2) in rustc_feature::INCOMPATIBLE_FEATURES
632628
.iter()

compiler/rustc_feature/src/unstable.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ impl Features {
9393
&self.enabled_features
9494
}
9595

96+
/// Returns a iterator of enabled features in stable order.
97+
pub fn enabled_features_iter_stable_order(
98+
&self,
99+
) -> impl Iterator<Item = (Symbol, Span)> + Clone {
100+
self.enabled_lang_features
101+
.iter()
102+
.map(|feat| (feat.gate_name, feat.attr_sp))
103+
.chain(self.enabled_lib_features.iter().map(|feat| (feat.gate_name, feat.attr_sp)))
104+
}
105+
96106
/// Is the given feature enabled (via `#[feature(...)]`)?
97107
pub fn enabled(&self, feature: Symbol) -> bool {
98108
self.enabled_features.contains(&feature)

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,13 +2331,9 @@ declare_lint_pass!(
23312331
impl EarlyLintPass for IncompleteInternalFeatures {
23322332
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
23332333
let features = cx.builder.features();
2334-
let lang_features =
2335-
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
2336-
let lib_features =
2337-
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
23382334

2339-
lang_features
2340-
.chain(lib_features)
2335+
features
2336+
.enabled_features_iter_stable_order()
23412337
.filter(|(name, _)| features.incomplete(*name) || features.internal(*name))
23422338
.for_each(|(name, span)| {
23432339
if features.incomplete(name) {

0 commit comments

Comments
 (0)