3 //! This module implements the gating necessary for preventing certain compiler
4 //! features from being used by default. This module will crawl a pre-expanded
5 //! AST to ensure that there are no features which are used that are not
8 //! Features are enabled in programs via the crate-level attributes of
9 //! `#![feature(...)]` with a comma-separated list of features.
11 //! For the purpose of future feature-tracking, once code for detection of feature
12 //! gate usage is added, *do not remove it again* even once the feature
20 use std::num::NonZeroU32;
21 use syntax_pos::{Span, edition::Edition, symbol::Symbol};
23 #[derive(Clone, Copy)]
26 Active { set: fn(&mut Features, Span) },
27 Removed { reason: Option<&'static str> },
28 Stabilized { reason: Option<&'static str> },
31 impl fmt::Debug for State {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 State::Accepted { .. } => write!(f, "accepted"),
35 State::Active { .. } => write!(f, "active"),
36 State::Removed { .. } => write!(f, "removed"),
37 State::Stabilized { .. } => write!(f, "stabilized"),
42 #[derive(Debug, Clone)]
46 pub since: &'static str,
47 issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
48 pub edition: Option<Edition>,
49 description: &'static str,
53 // FIXME(Centril): privatize again.
54 pub fn issue(&self) -> Option<NonZeroU32> {
55 self.issue.and_then(|i| NonZeroU32::new(i))
59 #[derive(Copy, Clone, Debug)]
62 // First argument is tracking issue link; second argument is an optional
63 // help message, which defaults to "remove this attribute".
64 Deprecated(&'static str, Option<&'static str>),
67 pub use accepted::ACCEPTED_FEATURES;
68 pub use active::{ACTIVE_FEATURES, Features, INCOMPLETE_FEATURES};
69 pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};