Skip to content

Commit 153a381

Browse files
Report usage of lib features in ast validation
1 parent c092b28 commit 153a381

File tree

4 files changed

+3
-20
lines changed

4 files changed

+3
-20
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
607607
// does not check the same for lib features unless there's at least one
608608
// declared lang feature
609609
if !sess.opts.unstable_features.is_nightly_build() {
610-
let lang_features = &features.declared_lang_features;
611-
if lang_features.len() == 0 {
610+
if features.declared_features.is_empty() {
612611
return;
613612
}
614613
for attr in krate.attrs.iter().filter(|attr| attr.has_name(sym::feature)) {
@@ -624,7 +623,8 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
624623
attr.meta_item_list().into_iter().flatten().flat_map(|nested| nested.ident())
625624
{
626625
let name = ident.name;
627-
let stable_since = lang_features
626+
let stable_since = features
627+
.declared_lang_features
628628
.iter()
629629
.flat_map(|&(feature, _, since)| if feature == name { since } else { None })
630630
.next();

compiler/rustc_passes/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ passes_export_name =
290290
passes_extern_main =
291291
the `main` function cannot be declared in an `extern` block
292292
293-
passes_feature_only_on_nightly =
294-
`#![feature]` may not be used on the {$release_channel} release channel
295-
296293
passes_feature_previously_declared =
297294
feature `{$feature}` is declared {$declared}, but was previously declared {$prev_declared}
298295

compiler/rustc_passes/src/errors.rs

-8
Original file line numberDiff line numberDiff line change
@@ -1492,14 +1492,6 @@ pub struct TraitImplConstStable {
14921492
pub span: Span,
14931493
}
14941494

1495-
#[derive(Diagnostic)]
1496-
#[diag(passes_feature_only_on_nightly, code = E0554)]
1497-
pub struct FeatureOnlyOnNightly {
1498-
#[primary_span]
1499-
pub span: Span,
1500-
pub release_channel: &'static str,
1501-
}
1502-
15031495
#[derive(Diagnostic)]
15041496
#[diag(passes_unknown_feature, code = E0635)]
15051497
pub struct UnknownFeature {

compiler/rustc_passes/src/stability.rs

-6
Original file line numberDiff line numberDiff line change
@@ -936,12 +936,6 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
936936
let declared_lib_features = &tcx.features().declared_lib_features;
937937
let mut remaining_lib_features = FxIndexMap::default();
938938
for (feature, span) in declared_lib_features {
939-
if !tcx.sess.opts.unstable_features.is_nightly_build() {
940-
tcx.dcx().emit_err(errors::FeatureOnlyOnNightly {
941-
span: *span,
942-
release_channel: env!("CFG_RELEASE_CHANNEL"),
943-
});
944-
}
945939
if remaining_lib_features.contains_key(&feature) {
946940
// Warn if the user enables a lib feature multiple times.
947941
tcx.dcx().emit_err(errors::DuplicateFeatureErr { span: *span, feature: *feature });

0 commit comments

Comments
 (0)