diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-08-27 21:46:52 -0400 |
| commit | 1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (patch) | |
| tree | 552fabade603ab0d148a49ae3cf1abd3f399740a /src/libsyntax/ext/base.rs | |
| parent | 3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff) | |
| download | rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.tar.gz rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.zip | |
Implement generalized object and type parameter bounds (Fixes #16462)
Diffstat (limited to 'src/libsyntax/ext/base.rs')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 01d3920a254..b3b66a6a604 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -52,23 +52,23 @@ pub struct BasicMacroExpander { /// Represents a thing that maps token trees to Macro Results pub trait TTMacroExpander { - fn expand(&self, - ecx: &mut ExtCtxt, - span: Span, - token_tree: &[ast::TokenTree]) - -> Box<MacResult>; + fn expand<'cx>(&self, + ecx: &'cx mut ExtCtxt, + span: Span, + token_tree: &[ast::TokenTree]) + -> Box<MacResult+'cx>; } pub type MacroExpanderFn = - fn(ecx: &mut ExtCtxt, span: codemap::Span, token_tree: &[ast::TokenTree]) - -> Box<MacResult>; + fn<'cx>(ecx: &'cx mut ExtCtxt, span: codemap::Span, token_tree: &[ast::TokenTree]) + -> Box<MacResult+'cx>; impl TTMacroExpander for BasicMacroExpander { - fn expand(&self, - ecx: &mut ExtCtxt, - span: Span, - token_tree: &[ast::TokenTree]) - -> Box<MacResult> { + fn expand<'cx>(&self, + ecx: &'cx mut ExtCtxt, + span: Span, + token_tree: &[ast::TokenTree]) + -> Box<MacResult+'cx> { (self.expander)(ecx, span, token_tree) } } @@ -79,27 +79,27 @@ pub struct BasicIdentMacroExpander { } pub trait IdentMacroExpander { - fn expand(&self, - cx: &mut ExtCtxt, - sp: Span, - ident: ast::Ident, - token_tree: Vec<ast::TokenTree> ) - -> Box<MacResult>; + fn expand<'cx>(&self, + cx: &'cx mut ExtCtxt, + sp: Span, + ident: ast::Ident, + token_tree: Vec<ast::TokenTree> ) + -> Box<MacResult+'cx>; } impl IdentMacroExpander for BasicIdentMacroExpander { - fn expand(&self, - cx: &mut ExtCtxt, - sp: Span, - ident: ast::Ident, - token_tree: Vec<ast::TokenTree> ) - -> Box<MacResult> { + fn expand<'cx>(&self, + cx: &'cx mut ExtCtxt, + sp: Span, + ident: ast::Ident, + token_tree: Vec<ast::TokenTree> ) + -> Box<MacResult+'cx> { (self.expander)(cx, sp, ident, token_tree) } } pub type IdentMacroExpanderFn = - fn(&mut ExtCtxt, Span, ast::Ident, Vec<ast::TokenTree>) -> Box<MacResult>; + fn<'cx>(&'cx mut ExtCtxt, Span, ast::Ident, Vec<ast::TokenTree>) -> Box<MacResult+'cx>; /// The result of a macro expansion. The return values of the various /// methods are spliced into the AST at the callsite of the macro (or @@ -146,8 +146,8 @@ pub struct MacExpr { e: Gc<ast::Expr>, } impl MacExpr { - pub fn new(e: Gc<ast::Expr>) -> Box<MacResult> { - box MacExpr { e: e } as Box<MacResult> + pub fn new(e: Gc<ast::Expr>) -> Box<MacResult+'static> { + box MacExpr { e: e } as Box<MacResult+'static> } } impl MacResult for MacExpr { @@ -160,8 +160,8 @@ pub struct MacPat { p: Gc<ast::Pat>, } impl MacPat { - pub fn new(p: Gc<ast::Pat>) -> Box<MacResult> { - box MacPat { p: p } as Box<MacResult> + pub fn new(p: Gc<ast::Pat>) -> Box<MacResult+'static> { + box MacPat { p: p } as Box<MacResult+'static> } } impl MacResult for MacPat { @@ -174,8 +174,8 @@ pub struct MacItem { i: Gc<ast::Item> } impl MacItem { - pub fn new(i: Gc<ast::Item>) -> Box<MacResult> { - box MacItem { i: i } as Box<MacResult> + pub fn new(i: Gc<ast::Item>) -> Box<MacResult+'static> { + box MacItem { i: i } as Box<MacResult+'static> } } impl MacResult for MacItem { @@ -203,8 +203,8 @@ impl DummyResult { /// /// Use this as a return value after hitting any errors and /// calling `span_err`. - pub fn any(sp: Span) -> Box<MacResult> { - box DummyResult { expr_only: false, span: sp } as Box<MacResult> + pub fn any(sp: Span) -> Box<MacResult+'static> { + box DummyResult { expr_only: false, span: sp } as Box<MacResult+'static> } /// Create a default MacResult that can only be an expression. @@ -212,8 +212,8 @@ impl DummyResult { /// Use this for macros that must expand to an expression, so even /// if an error is encountered internally, the user will receive /// an error that they also used it in the wrong place. - pub fn expr(sp: Span) -> Box<MacResult> { - box DummyResult { expr_only: true, span: sp } as Box<MacResult> + pub fn expr(sp: Span) -> Box<MacResult+'static> { + box DummyResult { expr_only: true, span: sp } as Box<MacResult+'static> } /// A plain dummy expression. |
