diff options
| author | bors <bors@rust-lang.org> | 2014-01-27 09:31:44 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-27 09:31:44 -0800 |
| commit | d6d7812da841ddedf6c765eebb655be9866956ce (patch) | |
| tree | 462e190485176d8089f3212a8acdfe783e447fbd /src/libsyntax/ext | |
| parent | be974bf499a977530703fd62b3794a9377b6cbc4 (diff) | |
| parent | 15ba0c310a2bfe2ab69670d0d87529a29d527973 (diff) | |
auto merge of #11595 : eddyb/rust/env-et-self-no-more, r=nikomatsakis
Non-exhaustive change list: * `self` is now present in argument lists (modulo type-checking code I don't trust myself to refactor) * methods have the same calling convention as bare functions (including the self argument) * the env param is gone from all bare functions (and methods), only used by closures and `proc`s * bare functions can only be coerced to closures and `proc`s if they are statically resolved, as they now require creating a wrapper specific to that function, to avoid indirect wrappers (equivalent to `impl<..Args, Ret> Fn<..Args, Ret> for fn(..Args) -> Ret`) that might not be optimizable by LLVM and don't work for `proc`s * refactored some `trans::closure` code, leading to the removal of `trans::glue::make_free_glue` and `ty_opaque_closure_ptr`
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 4 |
3 files changed, 13 insertions, 8 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 3b2cc4ca6ed..3b43c96a184 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -18,6 +18,7 @@ use ext::quote::rt::*; use fold::Folder; use opt_vec; use opt_vec::OptVec; +use parse::token::special_idents; pub struct Field { ident: ast::Ident, @@ -478,7 +479,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr_path(self.path_ident(span, id)) } fn expr_self(&self, span: Span) -> @ast::Expr { - self.expr(span, ast::ExprSelf) + self.expr_ident(span, special_idents::self_) } fn expr_binary(&self, sp: Span, op: ast::BinOp, @@ -523,9 +524,9 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn expr_method_call(&self, span: Span, expr: @ast::Expr, ident: ast::Ident, - args: ~[@ast::Expr]) -> @ast::Expr { - self.expr(span, - ast::ExprMethodCall(ast::DUMMY_NODE_ID, expr, ident, ~[], args, ast::NoSugar)) + mut args: ~[@ast::Expr]) -> @ast::Expr { + args.unshift(expr); + self.expr(span, ast::ExprMethodCall(ast::DUMMY_NODE_ID, ident, ~[], args, ast::NoSugar)) } fn expr_block(&self, b: P<ast::Block>) -> @ast::Expr { self.expr(b.span, ast::ExprBlock(b)) diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 1f778779fbd..e1fb80049e0 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -551,9 +551,14 @@ impl<'a> MethodDef<'a> { // create the generics that aren't for Self let fn_generics = self.generics.to_generics(trait_.cx, trait_.span, type_ident, generics); + let self_arg = match explicit_self.node { + ast::SelfStatic => None, + _ => Some(ast::Arg::new_self(trait_.span, ast::MutImmutable)) + }; let args = arg_types.move_iter().map(|(name, ty)| { trait_.cx.arg(trait_.span, name, ty) - }).collect(); + }); + let args = self_arg.move_iter().chain(args).collect(); let ret_type = self.get_ret_ty(trait_, generics, type_ident); @@ -578,7 +583,6 @@ impl<'a> MethodDef<'a> { body: body_block, id: ast::DUMMY_NODE_ID, span: trait_.span, - self_id: ast::DUMMY_NODE_ID, vis: ast::Inherited, } } diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index c2b32b45ce4..b22dcfe0da2 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -244,13 +244,13 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) let self_path = cx.expr_self(span); match *self_ptr { None => { - (self_path, respan(span, ast::SelfValue(ast::MutImmutable))) + (self_path, respan(span, ast::SelfValue)) } Some(ref ptr) => { let self_ty = respan( span, match *ptr { - Send => ast::SelfUniq(ast::MutImmutable), + Send => ast::SelfUniq, Managed => ast::SelfBox, Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s))); |
