diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2015-03-06 12:56:28 -0800 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2015-03-06 14:12:28 -0800 |
| commit | 63ee3fe566762781d1e60f190014b416f99fed36 (patch) | |
| tree | 623d6437437d358aa45aac986d505e17c8913219 /src/libsyntax/ext | |
| parent | 4d716decb5d9944bc0d79cdc51b03e3af69bc59c (diff) | |
| download | rust-63ee3fe566762781d1e60f190014b416f99fed36.tar.gz rust-63ee3fe566762781d1e60f190014b416f99fed36.zip | |
Consolidate ExpansionConfig feature tests
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 60 |
1 files changed, 20 insertions, 40 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d48108f17ff..84b02999252 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1447,6 +1447,19 @@ pub struct ExpansionConfig<'feat> { pub recursion_limit: usize, } +macro_rules! feature_tests { + ($( fn $getter:ident = $field:ident, )*) => { + $( + pub fn $getter(&self) -> bool { + match self.features { + Some(&Features { $field: true, .. }) => true, + _ => false, + } + } + )* + } +} + impl<'feat> ExpansionConfig<'feat> { pub fn default(crate_name: String) -> ExpansionConfig<'static> { ExpansionConfig { @@ -1456,46 +1469,13 @@ impl<'feat> ExpansionConfig<'feat> { } } - pub fn enable_quotes(&self) -> bool { - match self.features { - Some(&Features { allow_quote: true, .. }) => true, - _ => false, - } - } - - pub fn enable_asm(&self) -> bool { - match self.features { - Some(&Features { allow_asm: true, .. }) => true, - _ => false, - } - } - - pub fn enable_log_syntax(&self) -> bool { - match self.features { - Some(&Features { allow_log_syntax: true, .. }) => true, - _ => false, - } - } - - pub fn enable_concat_idents(&self) -> bool { - match self.features { - Some(&Features { allow_concat_idents: true, .. }) => true, - _ => false, - } - } - - pub fn enable_trace_macros(&self) -> bool { - match self.features { - Some(&Features { allow_trace_macros: true, .. }) => true, - _ => false, - } - } - - pub fn enable_allow_internal_unstable(&self) -> bool { - match self.features { - Some(&Features { allow_internal_unstable: true, .. }) => true, - _ => false - } + feature_tests! { + fn enable_quotes = allow_quote, + fn enable_asm = allow_asm, + fn enable_log_syntax = allow_log_syntax, + fn enable_concat_idents = allow_concat_idents, + fn enable_trace_macros = allow_trace_macros, + fn enable_allow_internal_unstable = allow_internal_unstable, } } |
