diff options
| author | bors <bors@rust-lang.org> | 2013-03-15 15:06:47 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-15 15:06:47 -0700 |
| commit | e75a843efa66fbcbe7db8473c3ee8f26fa2230ff (patch) | |
| tree | 5a8fabd2a9d064f4231b26e653fb9de9bdc3470b /src/libsyntax/parse | |
| parent | 2b059c6e5638de7b241ffddb38cef906813de245 (diff) | |
| parent | 4bd26481c4c91858c544981990efb2f48e5d3bbe (diff) | |
| download | rust-e75a843efa66fbcbe7db8473c3ee8f26fa2230ff.tar.gz rust-e75a843efa66fbcbe7db8473c3ee8f26fa2230ff.zip | |
auto merge of #5357 : jbclements/rust/add-nonempty-span-encoding, r=jbclements
r? @nikomatsakis
r? @erickt
Before this change, encoding an object containing a codemap::span
using the JSON encodeng produced invalid JSON, for instance:
[{"span":,"global":false,"idents":["abc"]}]
Since the decoder for codemap::span's ignores its argument, I
conjecture that this will not damage decoding, and should improve
it for many decoders.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 1cdf485d404..66a3ae7a2ae 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -297,10 +297,9 @@ mod test { use std; use core::io; use core::option::None; - use core::str; use util::testing::*; - #[test] fn to_json_str (val: @Encodable<std::json::Encoder>) -> ~str { + #[test] fn to_json_str<E : Encodable<std::json::Encoder>>(val: @E) -> ~str { do io::with_str_writer |writer| { val.encode(~std::json::Encoder(writer)); } @@ -312,18 +311,18 @@ mod test { @~"fn foo (x : int) { x; }", ~[], new_parse_sess(None)); - check_equal(to_json_str(@tts as @Encodable<std::json::Encoder>), - ~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\ - [\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\ - [\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\ - [\"tt_tok\",[,[\"IDENT\",[\"x\",false]]]],\ - [\"tt_tok\",[,[\"COLON\",[]]]],\ - [\"tt_tok\",[,[\"IDENT\",[\"int\",false]]]],\ - [\"tt_tok\",[,[\"RPAREN\",[]]]]]]],\ - [\"tt_delim\",[[[\"tt_tok\",[,[\"LBRACE\",[]]]],\ - [\"tt_tok\",[,[\"IDENT\",[\"x\",false]]]],\ - [\"tt_tok\",[,[\"SEMI\",[]]]],\ - [\"tt_tok\",[,[\"RBRACE\",[]]]]]]]]" + check_equal(to_json_str(@tts), + ~"[[\"tt_tok\",[null,[\"IDENT\",[\"fn\",false]]]],\ + [\"tt_tok\",[null,[\"IDENT\",[\"foo\",false]]]],\ + [\"tt_delim\",[[[\"tt_tok\",[null,[\"LPAREN\",[]]]],\ + [\"tt_tok\",[null,[\"IDENT\",[\"x\",false]]]],\ + [\"tt_tok\",[null,[\"COLON\",[]]]],\ + [\"tt_tok\",[null,[\"IDENT\",[\"int\",false]]]],\ + [\"tt_tok\",[null,[\"RPAREN\",[]]]]]]],\ + [\"tt_delim\",[[[\"tt_tok\",[null,[\"LBRACE\",[]]]],\ + [\"tt_tok\",[null,[\"IDENT\",[\"x\",false]]]],\ + [\"tt_tok\",[null,[\"SEMI\",[]]]],\ + [\"tt_tok\",[null,[\"RBRACE\",[]]]]]]]]" ); let ast1 = new_parser_from_tts(new_parse_sess(None),~[],tts) .parse_item(~[]); |
