diff options
| author | bors <bors@rust-lang.org> | 2016-01-21 19:01:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-01-21 19:01:24 +0000 |
| commit | 9ae76b363c1c109b1e2ab363f92ef9db80b18075 (patch) | |
| tree | 27d2b8ab9ec2068368663827c90a605a7c20f3f1 | |
| parent | c6ba7fee97e6834f3a72281f88621c10bd562669 (diff) | |
| parent | 1dc7eb8853f3ff5d8e4f7e4a717c55a7073f5533 (diff) | |
| download | rust-9ae76b363c1c109b1e2ab363f92ef9db80b18075.tar.gz rust-9ae76b363c1c109b1e2ab363f92ef9db80b18075.zip | |
Auto merge of #31028 - erickt:ast-json, r=michaelwoerister
The protocol for `serialize::{En,De}code` doesn't allow for two integers to be serialized next to each other.
Closes #31025.
cc @michaelwoerister
| -rw-r--r-- | src/libsyntax/codemap.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 19236f2cd98..8d6c0df981f 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -164,16 +164,31 @@ impl Eq for Span {} impl Encodable for Span { fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { - try!(s.emit_u32(self.lo.0)); - s.emit_u32(self.hi.0) + s.emit_struct("Span", 2, |s| { + try!(s.emit_struct_field("lo", 0, |s| { + self.lo.encode(s) + })); + + s.emit_struct_field("hi", 1, |s| { + self.hi.encode(s) + }) + }) } } impl Decodable for Span { fn decode<D: Decoder>(d: &mut D) -> Result<Span, D::Error> { - let lo = BytePos(try! { d.read_u32() }); - let hi = BytePos(try! { d.read_u32() }); - Ok(mk_sp(lo, hi)) + d.read_struct("Span", 2, |d| { + let lo = try!(d.read_struct_field("lo", 0, |d| { + BytePos::decode(d) + })); + + let hi = try!(d.read_struct_field("hi", 1, |d| { + BytePos::decode(d) + })); + + Ok(mk_sp(lo, hi)) + }) } } |
