From bb833ca0f0e878d381c3dc0c9afe958a810e4427 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 14 Feb 2013 21:17:26 -0800 Subject: librustc: Stop parsing `impl Type : Trait` and fix several declarations that slipped through. r=tjc --- src/libstd/flatpipes.rs | 38 +++++++------- src/libstd/json.rs | 8 +-- src/libstd/prettyprint.rs | 2 +- src/libstd/serialize.rs | 124 ++++++++++++++++++++++------------------------ src/libstd/workcache.rs | 4 +- 5 files changed, 83 insertions(+), 93 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index d33ed4fd7cb..cff30587607 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -258,7 +258,7 @@ pub trait ByteChan { const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; -pub impl,P:BytePort> FlatPort: GenericPort { +pub impl,P:BytePort> GenericPort for FlatPort { fn recv() -> T { match self.try_recv() { Some(val) => val, @@ -358,7 +358,7 @@ pub mod flatteners { bogus: () } - pub impl PodUnflattener: Unflattener { + pub impl Unflattener for PodUnflattener { fn unflatten(&self, buf: ~[u8]) -> T { assert size_of::() != 0; assert size_of::() == buf.len(); @@ -368,7 +368,7 @@ pub mod flatteners { } } - pub impl PodFlattener: Flattener { + pub impl Flattener for PodFlattener { fn flatten(&self, val: T) -> ~[u8] { assert size_of::() != 0; let val: *T = ptr::to_unsafe_ptr(&val); @@ -406,36 +406,32 @@ pub mod flatteners { serialize_value: SerializeValue } - pub impl> - DeserializingUnflattener: Unflattener { + pub impl> Unflattener + for DeserializingUnflattener { fn unflatten(&self, buf: ~[u8]) -> T { (self.deserialize_buffer)(buf) } } - pub impl> - SerializingFlattener: Flattener { + pub impl> Flattener + for SerializingFlattener { fn flatten(&self, val: T) -> ~[u8] { (self.serialize_value)(&val) } } - pub impl> - DeserializingUnflattener { - - static fn new(deserialize_buffer: DeserializeBuffer - ) -> DeserializingUnflattener { + pub impl> DeserializingUnflattener { + static fn new(deserialize_buffer: DeserializeBuffer) + -> DeserializingUnflattener { DeserializingUnflattener { deserialize_buffer: deserialize_buffer } } } - pub impl> - SerializingFlattener { - - static fn new(serialize_value: SerializeValue - ) -> SerializingFlattener { + pub impl> SerializingFlattener { + static fn new(serialize_value: SerializeValue) + -> SerializingFlattener { SerializingFlattener { serialize_value: serialize_value } @@ -523,7 +519,7 @@ pub mod bytepipes { writer: W } - pub impl ReaderBytePort: BytePort { + pub impl BytePort for ReaderBytePort { fn try_recv(&self, count: uint) -> Option<~[u8]> { let mut left = count; let mut bytes = ~[]; @@ -545,7 +541,7 @@ pub mod bytepipes { } } - pub impl WriterByteChan: ByteChan { + pub impl ByteChan for WriterByteChan { fn send(&self, val: ~[u8]) { self.writer.write(val); } @@ -576,7 +572,7 @@ pub mod bytepipes { chan: pipes::Chan<~[u8]> } - pub impl PipeBytePort: BytePort { + pub impl BytePort for PipeBytePort { fn try_recv(&self, count: uint) -> Option<~[u8]> { if self.buf.len() >= count { let mut bytes = ::core::util::replace(&mut self.buf, ~[]); @@ -608,7 +604,7 @@ pub mod bytepipes { } } - pub impl PipeByteChan: ByteChan { + pub impl ByteChan for PipeByteChan { fn send(&self, val: ~[u8]) { self.chan.send(val) } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 5aa05e9cf75..e8278bb1b35 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -82,7 +82,7 @@ pub fn Encoder(wr: io::Writer) -> Encoder { Encoder { wr: wr } } -pub impl Encoder: serialize::Encoder { +pub impl serialize::Encoder for Encoder { fn emit_nil(&self) { self.wr.write_str("null") } fn emit_uint(&self, v: uint) { self.emit_float(v as float); } @@ -217,7 +217,7 @@ pub fn PrettyEncoder(wr: io::Writer) -> PrettyEncoder { PrettyEncoder { wr: wr, indent: 0 } } -pub impl PrettyEncoder: serialize::Encoder { +pub impl serialize::Encoder for PrettyEncoder { fn emit_nil(&self) { self.wr.write_str("null") } fn emit_uint(&self, v: uint) { self.emit_float(v as float); } @@ -323,7 +323,7 @@ pub impl PrettyEncoder: serialize::Encoder { } } -pub impl Json: serialize::Encodable { +pub impl serialize::Encodable for Json { fn encode(&self, s: &S) { match *self { Number(v) => v.encode(s), @@ -768,7 +768,7 @@ priv impl Decoder { } } -pub impl Decoder: serialize::Decoder { +pub impl serialize::Decoder for Decoder { fn read_nil(&self) -> () { debug!("read_nil"); match *self.pop() { diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index dc2e3d3da2b..cb9090225bf 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -22,7 +22,7 @@ pub fn Serializer(wr: io::Writer) -> Serializer { Serializer { wr: wr } } -pub impl Serializer: serialize::Encoder { +pub impl serialize::Encoder for Serializer { fn emit_nil(&self) { self.wr.write_str(~"()") } diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index d4afdbf6f30..9b7cf8adce5 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -113,210 +113,210 @@ pub trait Decodable { static fn decode(&self, d: &D) -> Self; } -pub impl uint: Encodable { +pub impl Encodable for uint { fn encode(&self, s: &S) { s.emit_uint(*self) } } -pub impl uint: Decodable { +pub impl Decodable for uint { static fn decode(&self, d: &D) -> uint { d.read_uint() } } -pub impl u8: Encodable { +pub impl Encodable for u8 { fn encode(&self, s: &S) { s.emit_u8(*self) } } -pub impl u8: Decodable { +pub impl Decodable for u8 { static fn decode(&self, d: &D) -> u8 { d.read_u8() } } -pub impl u16: Encodable { +pub impl Encodable for u16 { fn encode(&self, s: &S) { s.emit_u16(*self) } } -pub impl u16: Decodable { +pub impl Decodable for u16 { static fn decode(&self, d: &D) -> u16 { d.read_u16() } } -pub impl u32: Encodable { +pub impl Encodable for u32 { fn encode(&self, s: &S) { s.emit_u32(*self) } } -pub impl u32: Decodable { +pub impl Decodable for u32 { static fn decode(&self, d: &D) -> u32 { d.read_u32() } } -pub impl u64: Encodable { +pub impl Encodable for u64 { fn encode(&self, s: &S) { s.emit_u64(*self) } } -pub impl u64: Decodable { +pub impl Decodable for u64 { static fn decode(&self, d: &D) -> u64 { d.read_u64() } } -pub impl int: Encodable { +pub impl Encodable for int { fn encode(&self, s: &S) { s.emit_int(*self) } } -pub impl int: Decodable { +pub impl Decodable for int { static fn decode(&self, d: &D) -> int { d.read_int() } } -pub impl i8: Encodable { +pub impl Encodable for i8 { fn encode(&self, s: &S) { s.emit_i8(*self) } } -pub impl i8: Decodable { +pub impl Decodable for i8 { static fn decode(&self, d: &D) -> i8 { d.read_i8() } } -pub impl i16: Encodable { +pub impl Encodable for i16 { fn encode(&self, s: &S) { s.emit_i16(*self) } } -pub impl i16: Decodable { +pub impl Decodable for i16 { static fn decode(&self, d: &D) -> i16 { d.read_i16() } } -pub impl i32: Encodable { +pub impl Encodable for i32 { fn encode(&self, s: &S) { s.emit_i32(*self) } } -pub impl i32: Decodable { +pub impl Decodable for i32 { static fn decode(&self, d: &D) -> i32 { d.read_i32() } } -pub impl i64: Encodable { +pub impl Encodable for i64 { fn encode(&self, s: &S) { s.emit_i64(*self) } } -pub impl i64: Decodable { +pub impl Decodable for i64 { static fn decode(&self, d: &D) -> i64 { d.read_i64() } } -pub impl &str: Encodable { +pub impl Encodable for &str { fn encode(&self, s: &S) { s.emit_borrowed_str(*self) } } -pub impl ~str: Encodable { +pub impl Encodable for ~str { fn encode(&self, s: &S) { s.emit_owned_str(*self) } } -pub impl ~str: Decodable { +pub impl Decodable for ~str { static fn decode(&self, d: &D) -> ~str { d.read_owned_str() } } -pub impl @str: Encodable { +pub impl Encodable for @str { fn encode(&self, s: &S) { s.emit_managed_str(*self) } } -pub impl @str: Decodable { +pub impl Decodable for @str { static fn decode(&self, d: &D) -> @str { d.read_managed_str() } } -pub impl float: Encodable { +pub impl Encodable for float { fn encode(&self, s: &S) { s.emit_float(*self) } } -pub impl float: Decodable { +pub impl Decodable for float { static fn decode(&self, d: &D) -> float { d.read_float() } } -pub impl f32: Encodable { +pub impl Encodable for f32 { fn encode(&self, s: &S) { s.emit_f32(*self) } } -pub impl f32: Decodable { +pub impl Decodable for f32 { static fn decode(&self, d: &D) -> f32 { d.read_f32() } } -pub impl f64: Encodable { +pub impl Encodable for f64 { fn encode(&self, s: &S) { s.emit_f64(*self) } } -pub impl f64: Decodable { +pub impl Decodable for f64 { static fn decode(&self, d: &D) -> f64 { d.read_f64() } } -pub impl bool: Encodable { +pub impl Encodable for bool { fn encode(&self, s: &S) { s.emit_bool(*self) } } -pub impl bool: Decodable { +pub impl Decodable for bool { static fn decode(&self, d: &D) -> bool { d.read_bool() } } -pub impl (): Encodable { +pub impl Encodable for () { fn encode(&self, s: &S) { s.emit_nil() } } -pub impl (): Decodable { +pub impl Decodable for () { static fn decode(&self, d: &D) -> () { d.read_nil() } } -pub impl> &T: Encodable { +pub impl> Encodable for &T { fn encode(&self, s: &S) { s.emit_borrowed(|| (**self).encode(s)) } } -pub impl> ~T: Encodable { +pub impl> Encodable for ~T { fn encode(&self, s: &S) { s.emit_owned(|| (**self).encode(s)) } } -pub impl> ~T: Decodable { +pub impl> Decodable for ~T { static fn decode(&self, d: &D) -> ~T { d.read_owned(|| ~Decodable::decode(d)) } } -pub impl> @T: Encodable { +pub impl> Encodable for @T { fn encode(&self, s: &S) { s.emit_managed(|| (**self).encode(s)) } } -pub impl> @T: Decodable { +pub impl> Decodable for @T { static fn decode(&self, d: &D) -> @T { d.read_managed(|| @Decodable::decode(d)) } } -pub impl> &[T]: Encodable { +pub impl> Encodable for &[T] { fn encode(&self, s: &S) { do s.emit_borrowed_vec(self.len()) { for self.eachi |i, e| { @@ -326,7 +326,7 @@ pub impl> &[T]: Encodable { } } -pub impl> ~[T]: Encodable { +pub impl> Encodable for ~[T] { fn encode(&self, s: &S) { do s.emit_owned_vec(self.len()) { for self.eachi |i, e| { @@ -336,7 +336,7 @@ pub impl> ~[T]: Encodable { } } -pub impl> ~[T]: Decodable { +pub impl> Decodable for ~[T] { static fn decode(&self, d: &D) -> ~[T] { do d.read_owned_vec |len| { do vec::from_fn(len) |i| { @@ -346,7 +346,7 @@ pub impl> ~[T]: Decodable { } } -pub impl> @[T]: Encodable { +pub impl> Encodable for @[T] { fn encode(&self, s: &S) { do s.emit_managed_vec(self.len()) { for self.eachi |i, e| { @@ -356,7 +356,7 @@ pub impl> @[T]: Encodable { } } -pub impl> @[T]: Decodable { +pub impl> Decodable for @[T] { static fn decode(&self, d: &D) -> @[T] { do d.read_managed_vec |len| { do at_vec::from_fn(len) |i| { @@ -366,7 +366,7 @@ pub impl> @[T]: Decodable { } } -pub impl> Option: Encodable { +pub impl> Encodable for Option { fn encode(&self, s: &S) { do s.emit_enum(~"option") { match *self { @@ -381,7 +381,7 @@ pub impl> Option: Encodable { } } -pub impl> Option: Decodable { +pub impl> Decodable for Option { static fn decode(&self, d: &D) -> Option { do d.read_enum(~"option") { do d.read_enum_variant |i| { @@ -396,11 +396,8 @@ pub impl> Option: Decodable { } } -pub impl< - S: Encoder, - T0: Encodable, - T1: Encodable -> (T0, T1): Encodable { +pub impl, T1: Encodable> Encodable + for (T0, T1) { fn encode(&self, s: &S) { match *self { (ref t0, ref t1) => { @@ -413,11 +410,8 @@ pub impl< } } -pub impl< - D: Decoder, - T0: Decodable, - T1: Decodable -> (T0, T1): Decodable { +pub impl, T1: Decodable> Decodable + for (T0, T1) { static fn decode(&self, d: &D) -> (T0, T1) { do d.read_tup(2) { ( @@ -433,7 +427,7 @@ pub impl< T0: Encodable, T1: Encodable, T2: Encodable -> (T0, T1, T2): Encodable { +> Encodable for (T0, T1, T2) { fn encode(&self, s: &S) { match *self { (ref t0, ref t1, ref t2) => { @@ -452,7 +446,7 @@ pub impl< T0: Decodable, T1: Decodable, T2: Decodable -> (T0, T1, T2): Decodable { +> Decodable for (T0, T1, T2) { static fn decode(&self, d: &D) -> (T0, T1, T2) { do d.read_tup(3) { ( @@ -470,7 +464,7 @@ pub impl< T1: Encodable, T2: Encodable, T3: Encodable -> (T0, T1, T2, T3): Encodable { +> Encodable for (T0, T1, T2, T3) { fn encode(&self, s: &S) { match *self { (ref t0, ref t1, ref t2, ref t3) => { @@ -491,7 +485,7 @@ pub impl< T1: Decodable, T2: Decodable, T3: Decodable -> (T0, T1, T2, T3): Decodable { +> Decodable for (T0, T1, T2, T3) { static fn decode(&self, d: &D) -> (T0, T1, T2, T3) { do d.read_tup(4) { ( @@ -511,7 +505,7 @@ pub impl< T2: Encodable, T3: Encodable, T4: Encodable -> (T0, T1, T2, T3, T4): Encodable { +> Encodable for (T0, T1, T2, T3, T4) { fn encode(&self, s: &S) { match *self { (ref t0, ref t1, ref t2, ref t3, ref t4) => { @@ -534,7 +528,7 @@ pub impl< T2: Decodable, T3: Decodable, T4: Decodable -> (T0, T1, T2, T3, T4): Decodable { +> Decodable for (T0, T1, T2, T3, T4) { static fn decode(&self, d: &D) -> (T0, T1, T2, T3, T4) { do d.read_tup(5) { @@ -558,7 +552,7 @@ pub trait EncoderHelpers { fn emit_from_vec(&self, v: &[T], f: fn(v: &T)); } -pub impl S: EncoderHelpers { +pub impl EncoderHelpers for S { fn emit_from_vec(&self, v: &[T], f: fn(v: &T)) { do self.emit_owned_vec(v.len()) { for v.eachi |i, e| { @@ -574,7 +568,7 @@ pub trait DecoderHelpers { fn read_to_vec(&self, f: fn() -> T) -> ~[T]; } -pub impl D: DecoderHelpers { +pub impl DecoderHelpers for D { fn read_to_vec(&self, f: fn() -> T) -> ~[T] { do self.read_owned_vec |len| { do vec::from_fn(len) |i| { diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index cb0f7d84b41..70c03c69d2d 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -138,7 +138,7 @@ impl WorkKey { type WorkMap = LinearMap; -pub impl WorkMap: Encodable { +pub impl Encodable for WorkMap { fn encode(&self, s: &S) { let mut d = ~[]; for self.each |&(k, v)| { @@ -149,7 +149,7 @@ pub impl WorkMap: Encodable { } } -pub impl WorkMap: Decodable { +pub impl Decodable for WorkMap { static fn decode(&self, d: &D) -> WorkMap { let v : ~[(WorkKey,~str)] = Decodable::decode(d); let mut w = LinearMap::new(); -- cgit 1.4.1-3-g733a5