diff options
| author | Pascal Hertleif <pascal@technocreatives.com> | 2019-08-24 17:50:21 +0200 |
|---|---|---|
| committer | Pascal Hertleif <pascal@technocreatives.com> | 2019-08-25 11:07:16 +0200 |
| commit | c9d9616e825fecd4301beaf7bcd9115d5d7d393f (patch) | |
| tree | b467b634be48058b9a492b5a9df202a15b7e6bd5 /src/libsyntax/feature_gate/active.rs | |
| parent | c9619a4202bd013f1be2776c328937ddd643e7b7 (diff) | |
Introduce and use `Feature` type for feature gates
This replaces the ad-hoc tuples used in the different feature gate files and unifies their content into a common type, leading to more readable matches and other good stuff that comes from having named fields. It also contains the description of each feature as extracted from the doc comment.
Diffstat (limited to 'src/libsyntax/feature_gate/active.rs')
| -rw-r--r-- | src/libsyntax/feature_gate/active.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs index 4008b79b141..c947b09fdcb 100644 --- a/src/libsyntax/feature_gate/active.rs +++ b/src/libsyntax/feature_gate/active.rs @@ -65,6 +65,16 @@ macro_rules! declare_features { }; } +impl Feature { + /// Set this feature in `Features`. Panics if called on a non-active feature. + pub fn set(&self, features: &mut Features, span: Span) { + match self.state { + State::Active { set } => set(features, span), + _ => panic!("Called `set` on feature `{}` which is not `active`", self.name) + } + } +} + // If you change this, please modify `src/doc/unstable-book` as well. // // Don't ever remove anything from this list; move them to `removed.rs`. |
