diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-11-03 10:53:49 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-11-03 18:29:24 -0500 |
| commit | 2a7fb3584c974d6bf09182d454a457515aca228b (patch) | |
| tree | 9b9532c2b10b360c3d25d22ea822d9520c04816f /src/libsyntax | |
| parent | b11b706545ec986b0416a14383170c60004644a5 (diff) | |
| download | rust-2a7fb3584c974d6bf09182d454a457515aca228b.tar.gz rust-2a7fb3584c974d6bf09182d454a457515aca228b.zip | |
syntax: Use UFCS in the expansion of `#[deriving(Clone)]`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/deriving/clone.rs | 14 |
1 files 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<Expr> { - 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) => { |
