-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
rustc_feature: Separate "renamed" features from "removed" features
#155129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,6 +156,23 @@ pub(crate) struct FeatureRemoved<'a> { | |
| pub pull_note: String, | ||
| } | ||
|
|
||
| #[derive(Diagnostic)] | ||
| #[diag("feature was renamed", code = E0557)] | ||
| #[note("renamed in {$renamed_rustc_version}{$pull_note}")] | ||
| pub(crate) struct FeatureRenamed<'a> { | ||
| #[primary_span] | ||
| #[suggestion( | ||
| "update to the new name", | ||
| code = "{new_name}", | ||
| applicability = "machine-applicable" | ||
| )] | ||
| #[label("feature was renamed")] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this label duplicates a message from diag
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. old diagnostic had the same label and diagnostic message, so I just mirrored that: - error[E0557]: feature has been removed
+ error[E0557]: feature was renamed
--> $DIR/feature-gate-sanitize.rs:1:12
|
LL | #![feature(no_sanitize)]
- | ^^^^^^^^^^^ feature has been removed
+ | ^^^^^^^^^^^
+ | |
+ | feature was renamed
+ | help: update to the new name: `sanitize`
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, let's drop it from both in a follow up, or remvoe it from renamed now and from removed in a follow up, smth like this |
||
| pub span: Span, | ||
| pub new_name: &'a str, | ||
| pub renamed_rustc_version: &'a str, | ||
| pub pull_note: String, | ||
| } | ||
|
|
||
| #[derive(Subdiagnostic)] | ||
| #[note("{$reason}")] | ||
| pub(crate) struct FeatureRemovedReason<'a> { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| //! List of the renamed feature gates. | ||
|
|
||
| use std::num::NonZero; | ||
|
|
||
| use rustc_span::sym; | ||
|
|
||
| use super::{Feature, to_nonzero}; | ||
| use crate::opt_nonzero_u32; | ||
|
|
||
| pub struct RenamedFeature { | ||
| pub feature: Feature, | ||
| pub new_name: &'static str, | ||
| pub pull: Option<NonZero<u32>>, | ||
| } | ||
|
|
||
| macro_rules! declare_features { | ||
| ($( | ||
| $(#[doc = $doc:tt])* (renamed, $old_feature_name:ident => $new_feature_name:ident, $ver:expr, $issue:expr $(, $pull:expr)?), | ||
| )+) => { | ||
| /// Features that have been renamed. | ||
| pub static RENAMED_LANG_FEATURES: &[RenamedFeature] = &[ | ||
| $(RenamedFeature { | ||
| feature: Feature { | ||
| name: sym::$old_feature_name, | ||
| since: $ver, | ||
| issue: to_nonzero($issue), | ||
| }, | ||
| new_name: stringify!($new_feature_name), | ||
| pull: opt_nonzero_u32!($($pull)?), | ||
| }),+ | ||
| ]; | ||
| }; | ||
| } | ||
|
|
||
| #[rustfmt::skip] | ||
| declare_features! { | ||
| // ------------------------------------------------------------------------- | ||
| // feature-group-start: renamed features | ||
| // ------------------------------------------------------------------------- | ||
|
|
||
| // Note that the version indicates when it got *renamed*. | ||
| // | ||
| // When renaming a feature, set the version number to | ||
| // `CURRENT RUSTC VERSION` with ` ` replaced by `_`. | ||
|
|
||
| (renamed, abi_c_cmse_nonsecure_call => abi_cmse_nonsecure_call, "1.90.0", Some(81391), 142146), | ||
| /// Allows non-trivial generic constants which have to be manually propagated upwards. | ||
| (renamed, const_evaluatable_checked => generic_const_exprs, "1.56.0", Some(76560), 88369), | ||
| /// Allows `#[doc(spotlight)]`. | ||
| /// The attribute was renamed to `#[doc(notable_trait)]` | ||
| /// and the feature to `doc_notable_trait`. | ||
| (renamed, doc_spotlight => doc_notable_trait, "1.53.0", Some(45040), 80965), | ||
| /// Allows generators to be cloned. | ||
| (renamed, generator_clone => coroutine_clone, "1.75.0", Some(95360), 116958), | ||
| /// Allows defining generators. | ||
| (renamed, generators => coroutines, "1.75.0", Some(43122), 116958), | ||
| /// Allows `#[no_coverage]` on functions. | ||
| /// The feature was renamed to `coverage_attribute` and the attribute to `#[coverage(on|off)]` | ||
| (renamed, no_coverage => coverage_attribute, "1.74.0", Some(84605), 114656), | ||
| // Allows the use of `no_sanitize` attribute. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should it be a doc comment? |
||
| /// The feature was renamed to `sanitize` and the attribute to `#[sanitize(xyz = "on|off")]` | ||
| (renamed, no_sanitize => sanitize, "1.91.0", Some(39699), 142681), | ||
| /// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible (object safe). | ||
| /// Renamed to `dyn_compatible_for_dispatch`. | ||
| (renamed, object_safe_for_dispatch => dyn_compatible_for_dispatch, "1.83.0", Some(43561), 131511), | ||
| /// Allows features specific to OIBIT (now called auto traits). | ||
| /// Renamed to `auto_traits`. | ||
| (renamed, optin_builtin_traits => auto_traits, "1.50.0", Some(13231), 79336), | ||
|
|
||
| // ------------------------------------------------------------------------- | ||
| // feature-group-end: renamed features | ||
| // ------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| // ------------------------------------------------------------------------- | ||
| // feature-group-start: renamed library features | ||
| // ------------------------------------------------------------------------- | ||
| // | ||
| // FIXME(#141617): we should have a better way to track renamed library features, but we reuse | ||
| // the infrastructure here so users still get hints. The symbols used here can be remove from | ||
| // `symbol.rs` when that happens. | ||
|
|
||
| // ------------------------------------------------------------------------- | ||
| // feature-group-end: renamed library features | ||
| // ------------------------------------------------------------------------- | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.