From 2a7fb3584c974d6bf09182d454a457515aca228b Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 3 Nov 2014 10:53:49 -0500 Subject: [PATCH] syntax: Use UFCS in the expansion of `#[deriving(Clone)]` --- src/libsyntax/ext/deriving/clone.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 9748b531345..e653c8aebf4 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -52,11 +52,19 @@ fn cs_clone( name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P { - let clone_ident = substr.method_ident; let ctor_ident; let all_fields; - let subcall = |field: &FieldInfo| - cx.expr_method_call(field.span, field.self_.clone(), clone_ident, Vec::new()); + let fn_path = vec![ + cx.ident_of("std"), + cx.ident_of("clone"), + cx.ident_of("Clone"), + cx.ident_of("clone"), + ]; + let subcall = |field: &FieldInfo| { + let args = vec![cx.expr_addr_of(field.span, field.self_.clone())]; + + cx.expr_call_global(field.span, fn_path.clone(), args) + }; match *substr.fields { Struct(ref af) => {