librustc: Remove ~EXPR, ~TYPE, and ~PAT from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
This commit is contained in:
@@ -50,19 +50,19 @@ pub trait MacroExpander {
|
||||
ecx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
token_tree: &[ast::TokenTree])
|
||||
-> ~MacResult;
|
||||
-> Box<MacResult>;
|
||||
}
|
||||
|
||||
pub type MacroExpanderFn =
|
||||
fn(ecx: &mut ExtCtxt, span: codemap::Span, token_tree: &[ast::TokenTree])
|
||||
-> ~MacResult;
|
||||
-> Box<MacResult>;
|
||||
|
||||
impl MacroExpander for BasicMacroExpander {
|
||||
fn expand(&self,
|
||||
ecx: &mut ExtCtxt,
|
||||
span: Span,
|
||||
token_tree: &[ast::TokenTree])
|
||||
-> ~MacResult {
|
||||
-> Box<MacResult> {
|
||||
(self.expander)(ecx, span, token_tree)
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ pub trait IdentMacroExpander {
|
||||
sp: Span,
|
||||
ident: ast::Ident,
|
||||
token_tree: Vec<ast::TokenTree> )
|
||||
-> ~MacResult;
|
||||
-> Box<MacResult>;
|
||||
}
|
||||
|
||||
impl IdentMacroExpander for BasicIdentMacroExpander {
|
||||
@@ -87,13 +87,13 @@ impl IdentMacroExpander for BasicIdentMacroExpander {
|
||||
sp: Span,
|
||||
ident: ast::Ident,
|
||||
token_tree: Vec<ast::TokenTree> )
|
||||
-> ~MacResult {
|
||||
-> Box<MacResult> {
|
||||
(self.expander)(cx, sp, ident, token_tree)
|
||||
}
|
||||
}
|
||||
|
||||
pub type IdentMacroExpanderFn =
|
||||
fn(&mut ExtCtxt, Span, ast::Ident, Vec<ast::TokenTree> ) -> ~MacResult;
|
||||
fn(&mut ExtCtxt, Span, ast::Ident, Vec<ast::TokenTree>) -> Box<MacResult>;
|
||||
|
||||
pub type MacroCrateRegistrationFun =
|
||||
fn(|ast::Name, SyntaxExtension|);
|
||||
@@ -130,8 +130,8 @@ pub struct MacExpr {
|
||||
e: @ast::Expr
|
||||
}
|
||||
impl MacExpr {
|
||||
pub fn new(e: @ast::Expr) -> ~MacResult {
|
||||
box MacExpr { e: e } as ~MacResult
|
||||
pub fn new(e: @ast::Expr) -> Box<MacResult> {
|
||||
box MacExpr { e: e } as Box<MacResult>
|
||||
}
|
||||
}
|
||||
impl MacResult for MacExpr {
|
||||
@@ -144,8 +144,8 @@ pub struct MacItem {
|
||||
i: @ast::Item
|
||||
}
|
||||
impl MacItem {
|
||||
pub fn new(i: @ast::Item) -> ~MacResult {
|
||||
box MacItem { i: i } as ~MacResult
|
||||
pub fn new(i: @ast::Item) -> Box<MacResult> {
|
||||
box MacItem { i: i } as Box<MacResult>
|
||||
}
|
||||
}
|
||||
impl MacResult for MacItem {
|
||||
@@ -173,8 +173,8 @@ impl DummyResult {
|
||||
///
|
||||
/// Use this as a return value after hitting any errors and
|
||||
/// calling `span_err`.
|
||||
pub fn any(sp: Span) -> ~MacResult {
|
||||
box DummyResult { expr_only: false, span: sp } as ~MacResult
|
||||
pub fn any(sp: Span) -> Box<MacResult> {
|
||||
box DummyResult { expr_only: false, span: sp } as Box<MacResult>
|
||||
}
|
||||
|
||||
/// Create a default MacResult that can only be an expression.
|
||||
@@ -182,8 +182,8 @@ impl DummyResult {
|
||||
/// Use this for macros that must expand to an expression, so even
|
||||
/// if an error is encountered internally, the user will recieve
|
||||
/// an error that they also used it in the wrong place.
|
||||
pub fn expr(sp: Span) -> ~MacResult {
|
||||
box DummyResult { expr_only: true, span: sp } as ~MacResult
|
||||
pub fn expr(sp: Span) -> Box<MacResult> {
|
||||
box DummyResult { expr_only: true, span: sp } as Box<MacResult>
|
||||
}
|
||||
|
||||
/// A plain dummy expression.
|
||||
@@ -229,13 +229,13 @@ pub enum SyntaxExtension {
|
||||
/// A normal, function-like syntax extension.
|
||||
///
|
||||
/// `bytes!` is a `NormalTT`.
|
||||
NormalTT(~MacroExpander:'static, Option<Span>),
|
||||
NormalTT(Box<MacroExpander:'static>, Option<Span>),
|
||||
|
||||
/// A function-like syntax extension that has an extra ident before
|
||||
/// the block.
|
||||
///
|
||||
/// `macro_rules!` is an `IdentTT`.
|
||||
IdentTT(~IdentMacroExpander:'static, Option<Span>),
|
||||
IdentTT(Box<IdentMacroExpander:'static>, Option<Span>),
|
||||
}
|
||||
|
||||
pub struct BlockInfo {
|
||||
|
||||
Reference in New Issue
Block a user