Introduce Enabled{Lang,Lib}Feature

Instead of passing around random n-tuples of e.g. `(gate_name, attr_sp,
since)`.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-10-24 23:53:08 +08:00
parent 5ae4d75eff
commit 3528149f73
7 changed files with 101 additions and 51 deletions

View file

@ -2287,13 +2287,15 @@ declare_lint_pass!(
impl EarlyLintPass for IncompleteInternalFeatures {
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
let features = cx.builder.features();
features
.enabled_lang_features()
.iter()
.map(|(name, span, _)| (name, span))
.chain(features.enabled_lib_features().iter().map(|(name, span)| (name, span)))
.filter(|(&name, _)| features.incomplete(name) || features.internal(name))
.for_each(|(&name, &span)| {
let lang_features =
features.enabled_lang_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
let lib_features =
features.enabled_lib_features().iter().map(|feat| (feat.gate_name, feat.attr_sp));
lang_features
.chain(lib_features)
.filter(|(name, _)| features.incomplete(*name) || features.internal(*name))
.for_each(|(name, span)| {
if features.incomplete(name) {
let note = rustc_feature::find_feature_issue(name, GateIssue::Language)
.map(|n| BuiltinFeatureIssueNote { n });