From 15ba0c310a2bfe2ab69670d0d87529a29d527973 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Mon, 27 Jan 2014 14:18:36 +0200 Subject: Demote self to an (almost) regular argument and remove the env param. Fixes #10667 and closes #10259. --- src/libsyntax/ext/build.rs | 9 +++++---- src/libsyntax/ext/deriving/generic.rs | 8 ++++++-- src/libsyntax/ext/deriving/ty.rs | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/ext') 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::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) 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))); -- cgit 1.4.1-3-g733a5