diff options
| author | bors <bors@rust-lang.org> | 2014-01-27 20:26:35 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-27 20:26:35 -0800 |
| commit | d21b18306cd3679e94c58d9d5c1c4a3d291167fe (patch) | |
| tree | c0bc8549bbd8d6b5b2ef4718ed793f8693f01e4a /src/libsyntax | |
| parent | 8c6c229831a0859d7345b16b46473002073b646d (diff) | |
| parent | cb02a370428afaae76db59080befe88b8c97e14d (diff) | |
| download | rust-d21b18306cd3679e94c58d9d5c1c4a3d291167fe.tar.gz rust-d21b18306cd3679e94c58d9d5c1c4a3d291167fe.zip | |
auto merge of #11826 : huonw/rust/7621-deriving-errors, r=alexcrichton
cc #7621. See the commit message. I'm not sure if we should merge this now, or wait until we can write `Clone::clone(x)` which will directly solve the above issue with perfect error messages.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/ord.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 8 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index 8a2b11b798c..5a02d8eead8 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -78,14 +78,10 @@ fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructur _ => cx.span_bug(span, "Not exactly 2 arguments in `deriving(Ord)`") }; - let cmp = cx.expr_binary(span, op, - cx.expr_deref(span, self_f), - cx.expr_deref(span, other_f)); + let cmp = cx.expr_binary(span, op, self_f, other_f); let not_cmp = cx.expr_unary(span, ast::UnNot, - cx.expr_binary(span, op, - cx.expr_deref(span, other_f), - cx.expr_deref(span, self_f))); + cx.expr_binary(span, op, other_f, self_f)); let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr); cx.expr_binary(span, ast::BiOr, cmp, and) diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index e1fb80049e0..3c9401b109f 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -1013,7 +1013,8 @@ impl<'a> TraitDef<'a> { }; let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i))); paths.push(path.clone()); - ident_expr.push((sp, opt_id, cx.expr_path(path))); + let val = cx.expr(sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(path)))); + ident_expr.push((sp, opt_id, val)); } let subpats = self.create_subpatterns(paths, mutbl); @@ -1057,7 +1058,8 @@ impl<'a> TraitDef<'a> { let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i))); paths.push(path.clone()); - ident_expr.push((sp, None, cx.expr_path(path))); + let val = cx.expr(sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(path)))); + ident_expr.push((sp, None, val)); } let subpats = self.create_subpatterns(paths, mutbl); @@ -1132,7 +1134,7 @@ pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr, cx.expr_method_call(field.span, field.self_, substructure.method_ident, - field.other.clone()) + field.other.map(|e| cx.expr_addr_of(field.span, *e))) }); f(cx, trait_span, called) |
