serialize: use Result
All of Decoder and Encoder's methods now return a Result. Encodable.encode() and Decodable.decode() return a Result as well. fixes #12292
This commit is contained in:
parent
13dafa09f1
commit
f1739b14a1
27 changed files with 6558 additions and 1419 deletions
|
@ -110,6 +110,8 @@ impl Eq for Span {
|
|||
|
||||
impl TotalEq for Span {}
|
||||
|
||||
// FIXME: remove stage0 Encodables/Decodables after snapshot
|
||||
#[cfg(stage0)]
|
||||
impl<S:Encoder> Encodable<S> for Span {
|
||||
/* Note #1972 -- spans are encoded but not decoded */
|
||||
fn encode(&self, s: &mut S) {
|
||||
|
@ -117,12 +119,28 @@ impl<S:Encoder> Encodable<S> for Span {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
impl<D:Decoder> Decodable<D> for Span {
|
||||
fn decode(_d: &mut D) -> Span {
|
||||
DUMMY_SP
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl<S:Encoder<E>, E> Encodable<S, E> for Span {
|
||||
/* Note #1972 -- spans are encoded but not decoded */
|
||||
fn encode(&self, s: &mut S) -> Result<(), E> {
|
||||
s.emit_nil()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl<D:Decoder<E>, E> Decodable<D, E> for Span {
|
||||
fn decode(_d: &mut D) -> Result<Span, E> {
|
||||
Ok(DUMMY_SP)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn spanned<T>(lo: BytePos, hi: BytePos, t: T) -> Spanned<T> {
|
||||
respan(mk_sp(lo, hi), t)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue