diff options
| author | bors <bors@rust-lang.org> | 2015-01-05 14:51:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-05 14:51:03 +0000 |
| commit | 03268bbf35d3ff2350d987fe7b60375839abdf2e (patch) | |
| tree | 86ecae7591630a6ccf7a69a47570577a0caea8c6 /src/libsyntax/ptr.rs | |
| parent | 8e83af6e879535c33fd83d247d16619e39e0b951 (diff) | |
| parent | 0cb7a4062a3c69bb0c54f0c9136889a1006e4f62 (diff) | |
| download | rust-03268bbf35d3ff2350d987fe7b60375839abdf2e.tar.gz rust-03268bbf35d3ff2350d987fe7b60375839abdf2e.zip | |
auto merge of #20514 : alexcrichton/rust/serialize-associated-type, r=aturon
This commit moves the libserialize crate (and will force the hand of the rustc-serialize crate) to not require the `old_orphan_check` feature gate as well as using associated types wherever possible. Concretely, the following changes were made: * The error type of `Encoder` and `Decoder` is now an associated type, meaning that these traits have no type parameters. * The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable` traits have moved to the corresponding method of the trait. This movement alleviates the dependency on `old_orphan_check` but implies that implementations can no longer be specialized for the type of encoder/decoder being implemented. Due to the trait definitions changing, this is a: [breaking-change]
Diffstat (limited to 'src/libsyntax/ptr.rs')
| -rw-r--r-- | src/libsyntax/ptr.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 6eee1d903ea..13eda7bb88f 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -111,14 +111,30 @@ impl<S, T: Hash<S>> Hash<S> for P<T> { } } +#[cfg(stage0)] impl<E, D: Decoder<E>, T: 'static + Decodable<D, E>> Decodable<D, E> for P<T> { fn decode(d: &mut D) -> Result<P<T>, E> { Decodable::decode(d).map(P) } } +#[cfg(not(stage0))] +impl<T: 'static + Decodable> Decodable for P<T> { + fn decode<D: Decoder>(d: &mut D) -> Result<P<T>, D::Error> { + Decodable::decode(d).map(P) + } +} + +#[cfg(stage0)] impl<E, S: Encoder<E>, T: Encodable<S, E>> Encodable<S, E> for P<T> { fn encode(&self, s: &mut S) -> Result<(), E> { (**self).encode(s) } } + +#[cfg(not(stage0))] +impl<T: Encodable> Encodable for P<T> { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + (**self).encode(s) + } +} |
