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
21 use crate::{edition::Edition, symbol::Symbol};
23 use std::num::NonZeroU32;
26 #[derive(Clone, Copy)]
29 Active { set: fn(&mut Features, Span) },
30 Removed { reason: Option<&'static str> },
31 Stabilized { reason: Option<&'static str> },
34 impl fmt::Debug for State {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 State::Accepted { .. } => write!(f, "accepted"),
38 State::Active { .. } => write!(f, "active"),
39 State::Removed { .. } => write!(f, "removed"),
40 State::Stabilized { .. } => write!(f, "stabilized"),
45 #[derive(Debug, Clone)]
50 issue: Option<u32>, // FIXME: once #58732 is done make this an Option<NonZeroU32>
51 edition: Option<Edition>,
52 description: &'static str,
56 fn issue(&self) -> Option<NonZeroU32> {
57 self.issue.and_then(|i| NonZeroU32::new(i))
61 pub use active::{Features, INCOMPLETE_FEATURES};
62 pub use builtin_attrs::{
63 AttributeGate, AttributeType, GatedCfg,
64 BuiltinAttribute, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
65 deprecated_attributes, is_builtin_attr, is_builtin_attr_name,
68 check_crate, check_attribute, get_features, feature_err, emit_feature_err,
69 Stability, GateIssue, UnstableFeatures,
70 EXPLAIN_STMT_ATTR_SYNTAX, EXPLAIN_UNSIZED_TUPLE_COERCION,