diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2014-09-15 16:09:09 -0700 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2015-01-05 11:38:12 -0800 |
| commit | 5e5924b79915326d81db2aebfe73d2a20b8506f1 (patch) | |
| tree | 16d55df447ad54f7d8a0dff9a900d12e7b091dd1 /src/libsyntax/ext/tt | |
| parent | d1cf1b1e6bf0b33fe3bb9fa01d9d94f797c9f9fc (diff) | |
| download | rust-5e5924b79915326d81db2aebfe73d2a20b8506f1.tar.gz rust-5e5924b79915326d81db2aebfe73d2a20b8506f1.zip | |
Replace LetSyntaxTT with MacroRulesTT
The implementation of LetSyntaxTT was specialized to macro_rules! in various ways. This gets rid of the false generality and simplifies the code.
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 08014dc1338..15b75442ca2 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -129,15 +129,6 @@ impl TTMacroExpander for MacroRulesMacroExpander { } } -struct MacroRulesDefiner { - def: Option<MacroDef> -} -impl MacResult for MacroRulesDefiner { - fn make_def(&mut self) -> Option<MacroDef> { - Some(self.def.take().expect("empty MacroRulesDefiner")) - } -} - /// Given `lhses` and `rhses`, this is the new macro we create fn generic_extension<'cx>(cx: &'cx ExtCtxt, sp: Span, @@ -219,7 +210,7 @@ pub fn add_new_extension<'cx>(cx: &'cx mut ExtCtxt, sp: Span, name: Ident, arg: Vec<ast::TokenTree> ) - -> Box<MacResult+'cx> { + -> MacroDef { let lhs_nm = gensym_ident("lhs"); let rhs_nm = gensym_ident("rhs"); @@ -279,10 +270,8 @@ pub fn add_new_extension<'cx>(cx: &'cx mut ExtCtxt, rhses: rhses, }; - box MacroRulesDefiner { - def: Some(MacroDef { - name: token::get_ident(name).to_string(), - ext: NormalTT(exp, Some(sp)) - }) - } as Box<MacResult+'cx> + MacroDef { + name: token::get_ident(name).to_string(), + ext: NormalTT(exp, Some(sp)) + } } |
