diff options
| author | bors <bors@rust-lang.org> | 2024-10-12 21:03:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-12 21:03:01 +0000 |
| commit | ef4e8259b5016d85e261587b605028b2ff06c13d (patch) | |
| tree | 9625da8e08773e78c30a43523d12631b452673e0 /compiler/rustc_passes/src | |
| parent | 6b9676b45431a1e531b9c5f7bd289fc36a312749 (diff) | |
| parent | de729170508bda3ef71c7c8778c37b5343ef6dfe (diff) | |
| download | rust-ef4e8259b5016d85e261587b605028b2ff06c13d.tar.gz rust-ef4e8259b5016d85e261587b605028b2ff06c13d.zip | |
Auto merge of #131628 - matthiaskrgr:rollup-imbojxz, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #128784 (Check ABI target compatibility for function pointers) - #130965 (make `Step` doc-comments more clear) - #131239 (Don't assume traits used as type are trait objs in 2021 edition) - #131277 (Handle `clippy` cases of `rustc::potential_query_instability` lint) - #131503 (More clearly document Stdin::read_line) - #131567 (Emit an error for unstable attributes that reference already stable features) - #131599 (Shallowly match opaque key in storage) - #131617 (remove const_cow_is_borrowed feature gate) Failed merges: - #131616 (merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/stability.rs | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 4f00c90fa3b..f9186d3089a 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -1481,6 +1481,17 @@ pub(crate) struct CannotStabilizeDeprecated { } #[derive(Diagnostic)] +#[diag(passes_unstable_attr_for_already_stable_feature)] +pub(crate) struct UnstableAttrForAlreadyStableFeature { + #[primary_span] + #[label] + #[help] + pub span: Span, + #[label(passes_item)] + pub item_sp: Span, +} + +#[derive(Diagnostic)] #[diag(passes_missing_stability_attr)] pub(crate) struct MissingStabilityAttr<'a> { #[primary_span] diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 46b67e930d5..751c87a9fe5 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -10,6 +10,7 @@ use rustc_attr::{ }; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet}; +use rustc_feature::ACCEPTED_FEATURES; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalModDefId}; @@ -246,12 +247,27 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } + if let Stability { level: Unstable { .. }, feature } = stab { + if ACCEPTED_FEATURES.iter().find(|f| f.name == feature).is_some() { + self.tcx + .dcx() + .emit_err(errors::UnstableAttrForAlreadyStableFeature { span, item_sp }); + } + } if let Stability { level: Unstable { implied_by: Some(implied_by), .. }, feature } = stab { self.index.implications.insert(implied_by, feature); } + if let Some(ConstStability { level: Unstable { .. }, feature, .. }) = const_stab { + if ACCEPTED_FEATURES.iter().find(|f| f.name == feature).is_some() { + self.tcx.dcx().emit_err(errors::UnstableAttrForAlreadyStableFeature { + span: const_span.unwrap(), // If const_stab contains Some(..), same is true for const_span + item_sp, + }); + } + } if let Some(ConstStability { level: Unstable { implied_by: Some(implied_by), .. }, feature, |
