diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2012-09-25 10:50:54 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-09-26 16:20:24 -0700 |
| commit | c0b9986c8f11c85c74ee0ba64dccf4495027a645 (patch) | |
| tree | a3bf26f36edf9c3ec25360fa076216e8a89fadc9 /src/libsyntax | |
| parent | cd93441705b84ab36a314d7f0b721c2fb6b01ecd (diff) | |
| download | rust-c0b9986c8f11c85c74ee0ba64dccf4495027a645.tar.gz rust-c0b9986c8f11c85c74ee0ba64dccf4495027a645.zip | |
libstd: change serialization2 to take &self argument methods
Unfortunately this trips over issue (#3585), where auto-ref isn't playing nicely with @T implementations. Most serializers don't care, but prettyprint2 won't properly display "@" until #3585 is fixed.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/auto_serialize2.rs | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/src/libsyntax/ext/auto_serialize2.rs b/src/libsyntax/ext/auto_serialize2.rs index e2e308f7e2c..264711584fc 100644 --- a/src/libsyntax/ext/auto_serialize2.rs +++ b/src/libsyntax/ext/auto_serialize2.rs @@ -232,9 +232,24 @@ fn mk_ser_method( bounds: @~[ast::bound_trait(ser_bound)], }]; + let ty_s = @{ + id: cx.next_id(), + node: ast::ty_rptr( + @{ + id: cx.next_id(), + node: ast::re_anon, + }, + { + ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), + mutbl: ast::m_imm + } + ), + span: span, + }; + let ser_inputs = ~[{ - mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), + mode: ast::infer(cx.next_id()), + ty: ty_s, ident: cx.ident_of(~"__s"), id: cx.next_id(), }]; @@ -255,7 +270,7 @@ fn mk_ser_method( ident: cx.ident_of(~"serialize"), attrs: ~[], tps: ser_tps, - self_ty: { node: ast::sty_by_ref, span: span }, + self_ty: { node: ast::sty_region(ast::m_imm), span: span }, purity: ast::impure_fn, decl: ser_decl, body: ser_body, @@ -288,9 +303,24 @@ fn mk_deser_method( bounds: @~[ast::bound_trait(deser_bound)], }]; + let ty_d = @{ + id: cx.next_id(), + node: ast::ty_rptr( + @{ + id: cx.next_id(), + node: ast::re_anon, + }, + { + ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), + mutbl: ast::m_imm + } + ), + span: span, + }; + let deser_inputs = ~[{ - mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), + mode: ast::infer(cx.next_id()), + ty: ty_d, ident: cx.ident_of(~"__d"), id: cx.next_id(), }]; @@ -608,11 +638,14 @@ fn mk_enum_ser_body( } }; - // ast for `match self { $(arms) }` + // ast for `match *self { $(arms) }` let match_expr = cx.expr( span, ast::expr_match( - cx.expr_var(span, ~"self"), + cx.expr( + span, + ast::expr_unary(ast::deref, cx.expr_var(span, ~"self")) + ), arms ) ); |
