auto merge of #5578 : erickt/rust/incoming, r=jbclements,erickt
Hey folks, This patch series does some work on the json decoder, specifically with auto decoding of enums. Previously, we would take this code: ``` enum A { B, C(~str, uint) } ``` and would encode a value of this enum to either `["B", []]` or `["C", ["D", 123]]`. I've changed this to `"B"` or `["C", "D", 123]`. This matches the style of the O'Caml json library [json-wheel](http://mjambon.com/json-wheel.html). I've added tests to make sure all this work. In order to make this change, I added passing a `&[&str]` vec to `Decode::emit_enum_variant` so the json decoder can convert the name of a variant into it's position. I also changed the impl of `Encodable` for `Option<T>` to have the right upper casing. I also did some work on the parser, which allows for `fn foo<T: ::cmp::Eq>() { ... }` statements (#5572), fixed the pretty printer properly expanding `debug!("...")` expressions, and removed `ast::expr_vstore_fixed`, which doesn't appear to be used anymore.
This commit is contained in:
commit
84ddff3909
24 changed files with 820 additions and 316 deletions
|
@ -28,7 +28,7 @@ use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac};
|
|||
use ast::{expr_method_call, expr_paren, expr_path, expr_repeat};
|
||||
use ast::{expr_ret, expr_swap, expr_struct, expr_tup, expr_unary};
|
||||
use ast::{expr_vec, expr_vstore, expr_vstore_mut_box, expr_inline_asm};
|
||||
use ast::{expr_vstore_fixed, expr_vstore_slice, expr_vstore_box};
|
||||
use ast::{expr_vstore_slice, expr_vstore_box};
|
||||
use ast::{expr_vstore_mut_slice, expr_while, extern_fn, field, fn_decl};
|
||||
use ast::{expr_vstore_uniq, TyClosure, TyBareFn, Onceness, Once, Many};
|
||||
use ast::{foreign_item, foreign_item_const, foreign_item_fn, foreign_mod};
|
||||
|
@ -1223,7 +1223,7 @@ pub impl Parser {
|
|||
let lvl = self.parse_expr();
|
||||
self.expect(&token::COMMA);
|
||||
let e = self.parse_expr();
|
||||
ex = expr_log(ast::log_other, lvl, e);
|
||||
ex = expr_log(lvl, e);
|
||||
hi = self.span.hi;
|
||||
self.expect(&token::RPAREN);
|
||||
} else if self.eat_keyword(&~"return") {
|
||||
|
@ -2721,8 +2721,9 @@ pub impl Parser {
|
|||
}
|
||||
self.bump();
|
||||
}
|
||||
token::IDENT(*) => {
|
||||
token::MOD_SEP | token::IDENT(*) => {
|
||||
let maybe_bound = match *self.token {
|
||||
token::MOD_SEP => None,
|
||||
token::IDENT(copy sid, _) => {
|
||||
match *self.id_to_str(sid) {
|
||||
~"send" |
|
||||
|
@ -2750,7 +2751,7 @@ pub impl Parser {
|
|||
result.push(bound);
|
||||
}
|
||||
None => {
|
||||
let ty = self.parse_ty(false);
|
||||
let ty = self.parse_ty(true);
|
||||
result.push(TraitTyParamBound(ty));
|
||||
}
|
||||
}
|
||||
|
@ -3099,14 +3100,6 @@ pub impl Parser {
|
|||
// impl<T> Foo { ... }
|
||||
// impl<T> ToStr for ~[T] { ... }
|
||||
fn parse_item_impl(&self, visibility: ast::visibility) -> item_info {
|
||||
fn wrap_path(p: &Parser, pt: @path) -> @Ty {
|
||||
@Ty {
|
||||
id: p.get_id(),
|
||||
node: ty_path(pt, p.get_id()),
|
||||
span: pt.span,
|
||||
}
|
||||
}
|
||||
|
||||
// First, parse type parameters if necessary.
|
||||
let generics = self.parse_generics();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue