Skip to content

Commit

Permalink
Unrolled build for rust-lang#127587
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#127587 - compiler-errors:all-features-at-once, r=Nilstrieb

Report usage of lib features in ast validation

No idea why it was split between ast validation for lang features and a later pass for lang features.

r? `@Nilstrieb`
  • Loading branch information
rust-timer authored Jul 14, 2024
2 parents 0968298 + 153a381 commit 9d4fe4d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 20 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
// does not check the same for lib features unless there's at least one
// declared lang feature
if !sess.opts.unstable_features.is_nightly_build() {
let lang_features = &features.declared_lang_features;
if lang_features.len() == 0 {
if features.declared_features.is_empty() {
return;
}
for attr in krate.attrs.iter().filter(|attr| attr.has_name(sym::feature)) {
Expand All @@ -624,7 +623,8 @@ fn maybe_stage_features(sess: &Session, features: &Features, krate: &ast::Crate)
attr.meta_item_list().into_iter().flatten().flat_map(|nested| nested.ident())
{
let name = ident.name;
let stable_since = lang_features
let stable_since = features
.declared_lang_features
.iter()
.flat_map(|&(feature, _, since)| if feature == name { since } else { None })
.next();
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ passes_export_name =
passes_extern_main =
the `main` function cannot be declared in an `extern` block
passes_feature_only_on_nightly =
`#![feature]` may not be used on the {$release_channel} release channel
passes_feature_previously_declared =
feature `{$feature}` is declared {$declared}, but was previously declared {$prev_declared}
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,14 +1492,6 @@ pub struct TraitImplConstStable {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(passes_feature_only_on_nightly, code = E0554)]
pub struct FeatureOnlyOnNightly {
#[primary_span]
pub span: Span,
pub release_channel: &'static str,
}

#[derive(Diagnostic)]
#[diag(passes_unknown_feature, code = E0635)]
pub struct UnknownFeature {
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,12 +936,6 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
let declared_lib_features = &tcx.features().declared_lib_features;
let mut remaining_lib_features = FxIndexMap::default();
for (feature, span) in declared_lib_features {
if !tcx.sess.opts.unstable_features.is_nightly_build() {
tcx.dcx().emit_err(errors::FeatureOnlyOnNightly {
span: *span,
release_channel: env!("CFG_RELEASE_CHANNEL"),
});
}
if remaining_lib_features.contains_key(&feature) {
// Warn if the user enables a lib feature multiple times.
tcx.dcx().emit_err(errors::DuplicateFeatureErr { span: *span, feature: *feature });
Expand Down

0 comments on commit 9d4fe4d

Please sign in to comment.