Skip to content

Commit 2a7fb35

Browse files
author
Jorge Aparicio
committed
syntax: Use UFCS in the expansion of #[deriving(Clone)]
1 parent b11b706 commit 2a7fb35

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/libsyntax/ext/deriving/clone.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,19 @@ fn cs_clone(
5252
name: &str,
5353
cx: &mut ExtCtxt, trait_span: Span,
5454
substr: &Substructure) -> P<Expr> {
55-
let clone_ident = substr.method_ident;
5655
let ctor_ident;
5756
let all_fields;
58-
let subcall = |field: &FieldInfo|
59-
cx.expr_method_call(field.span, field.self_.clone(), clone_ident, Vec::new());
57+
let fn_path = vec![
58+
cx.ident_of("std"),
59+
cx.ident_of("clone"),
60+
cx.ident_of("Clone"),
61+
cx.ident_of("clone"),
62+
];
63+
let subcall = |field: &FieldInfo| {
64+
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
65+
66+
cx.expr_call_global(field.span, fn_path.clone(), args)
67+
};
6068

6169
match *substr.fields {
6270
Struct(ref af) => {

0 commit comments

Comments
 (0)