From 780b23af73540dad0ec78488949bbcd380efd71e Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 10 Sep 2012 18:27:39 -0700 Subject: libstd: add the new trait-based serialization This will need a snapshot before we can convert ebml and rustc to use the new-style serialization. --- src/libstd/std.rc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 422ff81b9fe..5979b98478f 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -35,7 +35,7 @@ export bitv, deque, fun_treemap, list, map; export smallintmap, sort, treemap; export rope, arena, par; export ebml, dbg, getopts, json, rand, sha1, term, time, prettyprint; -export test, tempfile, serialization; +export test, tempfile, serialization, serialization2; export cmp; export base64; export cell; @@ -144,6 +144,8 @@ mod unicode; mod test; #[legacy_exports] mod serialization; +#[legacy_exports] +mod serialization2; // Local Variables: // mode: rust; -- cgit 1.4.1-3-g733a5 From c0b9986c8f11c85c74ee0ba64dccf4495027a645 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 25 Sep 2012 10:50:54 -0700 Subject: libstd: change serialization2 to take &self argument methods Unfortunately this trips over issue (#3585), where auto-ref isn't playing nicely with @T implementations. Most serializers don't care, but prettyprint2 won't properly display "@" until #3585 is fixed. --- src/libstd/serialization2.rs | 366 +++++++++++++++++-------------- src/libstd/std.rc | 1 - src/libsyntax/ext/auto_serialize2.rs | 47 +++- src/test/run-pass/auto_serialize2-box.rs | 73 ++++++ src/test/run-pass/auto_serialize2.rs | 91 +++----- 5 files changed, 339 insertions(+), 239 deletions(-) create mode 100644 src/test/run-pass/auto_serialize2-box.rs (limited to 'src/libstd/std.rc') diff --git a/src/libstd/serialization2.rs b/src/libstd/serialization2.rs index 92461fed258..81941627ef6 100644 --- a/src/libstd/serialization2.rs +++ b/src/libstd/serialization2.rs @@ -4,179 +4,214 @@ Core serialization interfaces. */ -trait Serializer { +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; +#[forbid(non_camel_case_types)]; + +pub trait Serializer { // Primitive types: - fn emit_nil(); - fn emit_uint(v: uint); - fn emit_u64(v: u64); - fn emit_u32(v: u32); - fn emit_u16(v: u16); - fn emit_u8(v: u8); - fn emit_int(v: int); - fn emit_i64(v: i64); - fn emit_i32(v: i32); - fn emit_i16(v: i16); - fn emit_i8(v: i8); - fn emit_bool(v: bool); - fn emit_float(v: float); - fn emit_f64(v: f64); - fn emit_f32(v: f32); - fn emit_str(v: &str); + fn emit_nil(&self); + fn emit_uint(&self, v: uint); + fn emit_u64(&self, v: u64); + fn emit_u32(&self, v: u32); + fn emit_u16(&self, v: u16); + fn emit_u8(&self, v: u8); + fn emit_int(&self, v: int); + fn emit_i64(&self, v: i64); + fn emit_i32(&self, v: i32); + fn emit_i16(&self, v: i16); + fn emit_i8(&self, v: i8); + fn emit_bool(&self, v: bool); + fn emit_float(&self, v: float); + fn emit_f64(&self, v: f64); + fn emit_f32(&self, v: f32); + fn emit_str(&self, v: &str); // Compound types: - fn emit_enum(name: &str, f: fn()); - fn emit_enum_variant(v_name: &str, v_id: uint, sz: uint, f: fn()); - fn emit_enum_variant_arg(idx: uint, f: fn()); - fn emit_vec(len: uint, f: fn()); - fn emit_vec_elt(idx: uint, f: fn()); - fn emit_box(f: fn()); - fn emit_uniq(f: fn()); - fn emit_rec(f: fn()); - fn emit_rec_field(f_name: &str, f_idx: uint, f: fn()); - fn emit_tup(sz: uint, f: fn()); - fn emit_tup_elt(idx: uint, f: fn()); -} - -trait Deserializer { + fn emit_enum(&self, name: &str, f: fn()); + fn emit_enum_variant(&self, v_name: &str, v_id: uint, sz: uint, f: fn()); + fn emit_enum_variant_arg(&self, idx: uint, f: fn()); + fn emit_vec(&self, len: uint, f: fn()); + fn emit_vec_elt(&self, idx: uint, f: fn()); + fn emit_box(&self, f: fn()); + fn emit_uniq(&self, f: fn()); + fn emit_rec(&self, f: fn()); + fn emit_rec_field(&self, f_name: &str, f_idx: uint, f: fn()); + fn emit_tup(&self, sz: uint, f: fn()); + fn emit_tup_elt(&self, idx: uint, f: fn()); +} + +pub trait Deserializer { // Primitive types: - fn read_nil() -> (); - fn read_uint() -> uint; - fn read_u64() -> u64; - fn read_u32() -> u32; - fn read_u16() -> u16; - fn read_u8() -> u8; - fn read_int() -> int; - fn read_i64() -> i64; - fn read_i32() -> i32; - fn read_i16() -> i16; - fn read_i8() -> i8; - fn read_bool() -> bool; - fn read_f64() -> f64; - fn read_f32() -> f32; - fn read_float() -> float; - fn read_str() -> ~str; + fn read_nil(&self) -> (); + fn read_uint(&self) -> uint; + fn read_u64(&self) -> u64; + fn read_u32(&self) -> u32; + fn read_u16(&self) -> u16; + fn read_u8(&self) -> u8; + fn read_int(&self) -> int; + fn read_i64(&self) -> i64; + fn read_i32(&self) -> i32; + fn read_i16(&self) -> i16; + fn read_i8(&self) -> i8; + fn read_bool(&self) -> bool; + fn read_f64(&self) -> f64; + fn read_f32(&self) -> f32; + fn read_float(&self) -> float; + fn read_str(&self) -> ~str; // Compound types: - fn read_enum(name: ~str, f: fn() -> T) -> T; - fn read_enum_variant(f: fn(uint) -> T) -> T; - fn read_enum_variant_arg(idx: uint, f: fn() -> T) -> T; - fn read_vec(f: fn(uint) -> T) -> T; - fn read_vec_elt(idx: uint, f: fn() -> T) -> T; - fn read_box(f: fn() -> T) -> T; - fn read_uniq(f: fn() -> T) -> T; - fn read_rec(f: fn() -> T) -> T; - fn read_rec_field(f_name: ~str, f_idx: uint, f: fn() -> T) -> T; - fn read_tup(sz: uint, f: fn() -> T) -> T; - fn read_tup_elt(idx: uint, f: fn() -> T) -> T; -} - -trait Serializable { - fn serialize(s: S); - static fn deserialize(d: D) -> self; -} - -impl uint: Serializable { - fn serialize(s: S) { s.emit_uint(self) } - static fn deserialize(d: D) -> uint { d.read_uint() } + fn read_enum(&self, name: ~str, f: fn() -> T) -> T; + fn read_enum_variant(&self, f: fn(uint) -> T) -> T; + fn read_enum_variant_arg(&self, idx: uint, f: fn() -> T) -> T; + fn read_vec(&self, f: fn(uint) -> T) -> T; + fn read_vec_elt(&self, idx: uint, f: fn() -> T) -> T; + fn read_box(&self, f: fn() -> T) -> T; + fn read_uniq(&self, f: fn() -> T) -> T; + fn read_rec(&self, f: fn() -> T) -> T; + fn read_rec_field(&self, f_name: ~str, f_idx: uint, f: fn() -> T) -> T; + fn read_tup(&self, sz: uint, f: fn() -> T) -> T; + fn read_tup_elt(&self, idx: uint, f: fn() -> T) -> T; +} + +pub trait Serializable { + fn serialize(&self, s: &S); + static fn deserialize(&self, d: &D) -> self; +} + +pub impl uint: Serializable { + fn serialize(&self, s: &S) { s.emit_uint(*self) } + static fn deserialize(&self, d: &D) -> uint { + d.read_uint() + } } -impl u8: Serializable { - fn serialize(s: S) { s.emit_u8(self) } - static fn deserialize(d: D) -> u8 { d.read_u8() } +pub impl u8: Serializable { + fn serialize(&self, s: &S) { s.emit_u8(*self) } + static fn deserialize(&self, d: &D) -> u8 { + d.read_u8() + } } -impl u16: Serializable { - fn serialize(s: S) { s.emit_u16(self) } - static fn deserialize(d: D) -> u16 { d.read_u16() } +pub impl u16: Serializable { + fn serialize(&self, s: &S) { s.emit_u16(*self) } + static fn deserialize(&self, d: &D) -> u16 { + d.read_u16() + } } -impl u32: Serializable { - fn serialize(s: S) { s.emit_u32(self) } - static fn deserialize(d: D) -> u32 { d.read_u32() } +pub impl u32: Serializable { + fn serialize(&self, s: &S) { s.emit_u32(*self) } + static fn deserialize(&self, d: &D) -> u32 { + d.read_u32() + } } -impl u64: Serializable { - fn serialize(s: S) { s.emit_u64(self) } - static fn deserialize(d: D) -> u64 { d.read_u64() } +pub impl u64: Serializable { + fn serialize(&self, s: &S) { s.emit_u64(*self) } + static fn deserialize(&self, d: &D) -> u64 { + d.read_u64() + } } -impl int: Serializable { - fn serialize(s: S) { s.emit_int(self) } - static fn deserialize(d: D) -> int { d.read_int() } +pub impl int: Serializable { + fn serialize(&self, s: &S) { s.emit_int(*self) } + static fn deserialize(&self, d: &D) -> int { + d.read_int() + } } -impl i8: Serializable { - fn serialize(s: S) { s.emit_i8(self) } - static fn deserialize(d: D) -> i8 { d.read_i8() } +pub impl i8: Serializable { + fn serialize(&self, s: &S) { s.emit_i8(*self) } + static fn deserialize(&self, d: &D) -> i8 { + d.read_i8() + } } -impl i16: Serializable { - fn serialize(s: S) { s.emit_i16(self) } - static fn deserialize(d: D) -> i16 { d.read_i16() } +pub impl i16: Serializable { + fn serialize(&self, s: &S) { s.emit_i16(*self) } + static fn deserialize(&self, d: &D) -> i16 { + d.read_i16() + } } -impl i32: Serializable { - fn serialize(s: S) { s.emit_i32(self) } - static fn deserialize(d: D) -> i32 { d.read_i32() } +pub impl i32: Serializable { + fn serialize(&self, s: &S) { s.emit_i32(*self) } + static fn deserialize(&self, d: &D) -> i32 { + d.read_i32() + } } -impl i64: Serializable { - fn serialize(s: S) { s.emit_i64(self) } - static fn deserialize(d: D) -> i64 { d.read_i64() } +pub impl i64: Serializable { + fn serialize(&self, s: &S) { s.emit_i64(*self) } + static fn deserialize(&self, d: &D) -> i64 { + d.read_i64() + } } -impl ~str: Serializable { - fn serialize(s: S) { s.emit_str(self) } - static fn deserialize(d: D) -> ~str { d.read_str() } +pub impl ~str: Serializable { + fn serialize(&self, s: &S) { s.emit_str(*self) } + static fn deserialize(&self, d: &D) -> ~str { + d.read_str() + } } -impl float: Serializable { - fn serialize(s: S) { s.emit_float(self) } - static fn deserialize(d: D) -> float { d.read_float() } +pub impl float: Serializable { + fn serialize(&self, s: &S) { s.emit_float(*self) } + static fn deserialize(&self, d: &D) -> float { + d.read_float() + } } -impl f32: Serializable { - fn serialize(s: S) { s.emit_f32(self) } - static fn deserialize(d: D) -> f32 { d.read_f32() } +pub impl f32: Serializable { + fn serialize(&self, s: &S) { s.emit_f32(*self) } + static fn deserialize(&self, d: &D) -> f32 { + d.read_f32() } } -impl f64: Serializable { - fn serialize(s: S) { s.emit_f64(self) } - static fn deserialize(d: D) -> f64 { d.read_f64() } +pub impl f64: Serializable { + fn serialize(&self, s: &S) { s.emit_f64(*self) } + static fn deserialize(&self, d: &D) -> f64 { + d.read_f64() + } } -impl bool: Serializable { - fn serialize(s: S) { s.emit_bool(self) } - static fn deserialize(d: D) -> bool { d.read_bool() } +pub impl bool: Serializable { + fn serialize(&self, s: &S) { s.emit_bool(*self) } + static fn deserialize(&self, d: &D) -> bool { + d.read_bool() + } } -impl (): Serializable { - fn serialize(s: S) { s.emit_nil() } - static fn deserialize(d: D) -> () { d.read_nil() } +pub impl (): Serializable { + fn serialize(&self, s: &S) { s.emit_nil() } + static fn deserialize(&self, d: &D) -> () { + d.read_nil() + } } -impl @T: Serializable { - fn serialize(s: S) { +pub impl @T: Serializable { + fn serialize(&self, s: &S) { s.emit_box(|| (*self).serialize(s)) } - static fn deserialize(d: D) -> @T { + static fn deserialize(&self, d: &D) -> @T { d.read_box(|| @deserialize(d)) } } -impl ~T: Serializable { - fn serialize(s: S) { +pub impl ~T: Serializable { + fn serialize(&self, s: &S) { s.emit_uniq(|| (*self).serialize(s)) } - static fn deserialize(d: D) -> ~T { + static fn deserialize(&self, d: &D) -> ~T { d.read_uniq(|| ~deserialize(d)) } } -impl ~[T]: Serializable { - fn serialize(s: S) { +pub impl ~[T]: Serializable { + fn serialize(&self, s: &S) { do s.emit_vec(self.len()) { for self.eachi |i, e| { s.emit_vec_elt(i, || e.serialize(s)) @@ -184,7 +219,7 @@ impl ~[T]: Serializable { } } - static fn deserialize(d: D) -> ~[T] { + static fn deserialize(&self, d: &D) -> ~[T] { do d.read_vec |len| { do vec::from_fn(len) |i| { d.read_vec_elt(i, || deserialize(d)) @@ -193,10 +228,10 @@ impl ~[T]: Serializable { } } -impl Option: Serializable { - fn serialize(s: S) { +pub impl Option: Serializable { + fn serialize(&self, s: &S) { do s.emit_enum(~"option") { - match self { + match *self { None => do s.emit_enum_variant(~"none", 0u, 0u) { }, @@ -207,7 +242,7 @@ impl Option: Serializable { } } - static fn deserialize(d: D) -> Option { + static fn deserialize(&self, d: &D) -> Option { do d.read_enum(~"option") { do d.read_enum_variant |i| { match i { @@ -220,12 +255,12 @@ impl Option: Serializable { } } -impl< +pub impl< T0: Serializable, T1: Serializable > (T0, T1): Serializable { - fn serialize(s: S) { - match self { + fn serialize(&self, s: &S) { + match *self { (t0, t1) => { do s.emit_tup(2) { s.emit_tup_elt(0, || t0.serialize(s)); @@ -235,7 +270,7 @@ impl< } } - static fn deserialize(d: D) -> (T0, T1) { + static fn deserialize(&self, d: &D) -> (T0, T1) { do d.read_tup(2) { ( d.read_tup_elt(0, || deserialize(d)), @@ -245,13 +280,13 @@ impl< } } -impl< +pub impl< T0: Serializable, T1: Serializable, T2: Serializable > (T0, T1, T2): Serializable { - fn serialize(s: S) { - match self { + fn serialize(&self, s: &S) { + match *self { (t0, t1, t2) => { do s.emit_tup(3) { s.emit_tup_elt(0, || t0.serialize(s)); @@ -262,7 +297,7 @@ impl< } } - static fn deserialize(d: D) -> (T0, T1, T2) { + static fn deserialize(&self, d: &D) -> (T0, T1, T2) { do d.read_tup(3) { ( d.read_tup_elt(0, || deserialize(d)), @@ -273,14 +308,14 @@ impl< } } -impl< +pub impl< T0: Serializable, T1: Serializable, T2: Serializable, T3: Serializable > (T0, T1, T2, T3): Serializable { - fn serialize(s: S) { - match self { + fn serialize(&self, s: &S) { + match *self { (t0, t1, t2, t3) => { do s.emit_tup(4) { s.emit_tup_elt(0, || t0.serialize(s)); @@ -292,7 +327,7 @@ impl< } } - static fn deserialize(d: D) -> (T0, T1, T2, T3) { + static fn deserialize(&self, d: &D) -> (T0, T1, T2, T3) { do d.read_tup(4) { ( d.read_tup_elt(0, || deserialize(d)), @@ -304,15 +339,15 @@ impl< } } -impl< +pub impl< T0: Serializable, T1: Serializable, T2: Serializable, T3: Serializable, T4: Serializable > (T0, T1, T2, T3, T4): Serializable { - fn serialize(s: S) { - match self { + fn serialize(&self, s: &S) { + match *self { (t0, t1, t2, t3, t4) => { do s.emit_tup(5) { s.emit_tup_elt(0, || t0.serialize(s)); @@ -325,7 +360,8 @@ impl< } } - static fn deserialize(d: D) -> (T0, T1, T2, T3, T4) { + static fn deserialize(&self, d: &D) + -> (T0, T1, T2, T3, T4) { do d.read_tup(5) { ( d.read_tup_elt(0, || deserialize(d)), @@ -343,40 +379,32 @@ impl< // // In some cases, these should eventually be coded as traits. -fn emit_from_vec(s: S, v: ~[T], f: fn(T)) { - do s.emit_vec(v.len()) { - for v.eachi |i, e| { - do s.emit_vec_elt(i) { - f(*e) - } - } - } +pub trait SerializerHelpers { + fn emit_from_vec(&self, v: ~[T], f: fn(v: &T)); } -fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { - do d.read_vec |len| { - do vec::from_fn(len) |i| { - d.read_vec_elt(i, || f()) +pub impl S: SerializerHelpers { + fn emit_from_vec(&self, v: ~[T], f: fn(v: &T)) { + do self.emit_vec(v.len()) { + for v.eachi |i, e| { + do self.emit_vec_elt(i) { + f(e) + } + } } } } -trait SerializerHelpers { - fn emit_from_vec(v: ~[T], f: fn(T)); +pub trait DeserializerHelpers { + fn read_to_vec(&self, f: fn() -> T) -> ~[T]; } -impl S: SerializerHelpers { - fn emit_from_vec(v: ~[T], f: fn(T)) { - emit_from_vec(self, v, f) - } -} - -trait DeserializerHelpers { - fn read_to_vec(f: fn() -> T) -> ~[T]; -} - -impl D: DeserializerHelpers { - fn read_to_vec(f: fn() -> T) -> ~[T] { - read_to_vec(self, f) +pub impl D: DeserializerHelpers { + fn read_to_vec(&self, f: fn() -> T) -> ~[T] { + do self.read_vec |len| { + do vec::from_fn(len) |i| { + self.read_vec_elt(i, || f()) + } + } } } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 5979b98478f..548ec1c31b4 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -144,7 +144,6 @@ mod unicode; mod test; #[legacy_exports] mod serialization; -#[legacy_exports] mod serialization2; // Local Variables: diff --git a/src/libsyntax/ext/auto_serialize2.rs b/src/libsyntax/ext/auto_serialize2.rs index e2e308f7e2c..264711584fc 100644 --- a/src/libsyntax/ext/auto_serialize2.rs +++ b/src/libsyntax/ext/auto_serialize2.rs @@ -232,9 +232,24 @@ fn mk_ser_method( bounds: @~[ast::bound_trait(ser_bound)], }]; + let ty_s = @{ + id: cx.next_id(), + node: ast::ty_rptr( + @{ + id: cx.next_id(), + node: ast::re_anon, + }, + { + ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), + mutbl: ast::m_imm + } + ), + span: span, + }; + let ser_inputs = ~[{ - mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[cx.ident_of(~"__S")], ~[]), + mode: ast::infer(cx.next_id()), + ty: ty_s, ident: cx.ident_of(~"__s"), id: cx.next_id(), }]; @@ -255,7 +270,7 @@ fn mk_ser_method( ident: cx.ident_of(~"serialize"), attrs: ~[], tps: ser_tps, - self_ty: { node: ast::sty_by_ref, span: span }, + self_ty: { node: ast::sty_region(ast::m_imm), span: span }, purity: ast::impure_fn, decl: ser_decl, body: ser_body, @@ -288,9 +303,24 @@ fn mk_deser_method( bounds: @~[ast::bound_trait(deser_bound)], }]; + let ty_d = @{ + id: cx.next_id(), + node: ast::ty_rptr( + @{ + id: cx.next_id(), + node: ast::re_anon, + }, + { + ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), + mutbl: ast::m_imm + } + ), + span: span, + }; + let deser_inputs = ~[{ - mode: ast::expl(ast::by_ref), - ty: cx.ty_path(span, ~[cx.ident_of(~"__D")], ~[]), + mode: ast::infer(cx.next_id()), + ty: ty_d, ident: cx.ident_of(~"__d"), id: cx.next_id(), }]; @@ -608,11 +638,14 @@ fn mk_enum_ser_body( } }; - // ast for `match self { $(arms) }` + // ast for `match *self { $(arms) }` let match_expr = cx.expr( span, ast::expr_match( - cx.expr_var(span, ~"self"), + cx.expr( + span, + ast::expr_unary(ast::deref, cx.expr_var(span, ~"self")) + ), arms ) ); diff --git a/src/test/run-pass/auto_serialize2-box.rs b/src/test/run-pass/auto_serialize2-box.rs new file mode 100644 index 00000000000..e395b1bfe5d --- /dev/null +++ b/src/test/run-pass/auto_serialize2-box.rs @@ -0,0 +1,73 @@ +// xfail-test FIXME Blocked on (#3585) + +extern mod std; + +// These tests used to be separate files, but I wanted to refactor all +// the common code. + +use cmp::Eq; +use std::ebml2; +use io::Writer; +use std::serialization2::{Serializer, Serializable, deserialize}; +use std::prettyprint2; + +fn test_ser_and_deser( + a1: A, + expected: ~str +) { + // check the pretty printer: + let s = do io::with_str_writer |w| { + a1.serialize(&prettyprint2::Serializer(w)) + }; + debug!("s == %?", s); + assert s == expected; + + // check the EBML serializer: + let bytes = do io::with_bytes_writer |wr| { + let ebml_w = &ebml2::Serializer(wr); + a1.serialize(ebml_w) + }; + let d = ebml2::Doc(@bytes); + let a2: A = deserialize(&ebml2::Deserializer(d)); + assert a1 == a2; +} + +#[auto_serialize2] +enum Expr { + Val(uint), + Plus(@Expr, @Expr), + Minus(@Expr, @Expr) +} + +impl Expr : cmp::Eq { + pure fn eq(other: &Expr) -> bool { + match self { + Val(e0a) => { + match *other { + Val(e0b) => e0a == e0b, + _ => false + } + } + Plus(e0a, e1a) => { + match *other { + Plus(e0b, e1b) => e0a == e0b && e1a == e1b, + _ => false + } + } + Minus(e0a, e1a) => { + match *other { + Minus(e0b, e1b) => e0a == e0b && e1a == e1b, + _ => false + } + } + } + } + pure fn ne(other: &Expr) -> bool { !self.eq(other) } +} + +fn main() { + test_ser_and_deser(Plus(@Minus(@Val(3u), @Val(10u)), + @Plus(@Val(22u), @Val(5u))), + ~"Plus(@Minus(@Val(3u), @Val(10u)), \ + @Plus(@Val(22u), @Val(5u)))"); +} diff --git a/src/test/run-pass/auto_serialize2.rs b/src/test/run-pass/auto_serialize2.rs index da48de2ffab..ac526a8f0b6 100644 --- a/src/test/run-pass/auto_serialize2.rs +++ b/src/test/run-pass/auto_serialize2.rs @@ -15,98 +15,71 @@ fn test_ser_and_deser( ) { // check the pretty printer: - let s = io::with_str_writer(|w| a1.serialize(w)); + let s = do io::with_str_writer |w| { + a1.serialize(&prettyprint2::Serializer(w)) + }; debug!("s == %?", s); assert s == expected; // check the EBML serializer: let bytes = do io::with_bytes_writer |wr| { - let ebml_w = ebml2::Serializer(wr); + let ebml_w = &ebml2::Serializer(wr); a1.serialize(ebml_w) }; let d = ebml2::Doc(@bytes); - let a2: A = deserialize(ebml2::Deserializer(d)); + let a2: A = deserialize(&ebml2::Deserializer(d)); assert a1 == a2; } -#[auto_serialize2] -enum Expr { - Val(uint), - Plus(@Expr, @Expr), - Minus(@Expr, @Expr) -} - impl AnEnum : cmp::Eq { - pure fn eq(&&other: AnEnum) -> bool { + pure fn eq(other: &AnEnum) -> bool { self.v == other.v } - pure fn ne(&&other: AnEnum) -> bool { !self.eq(other) } + pure fn ne(other: &AnEnum) -> bool { !self.eq(other) } } impl Point : cmp::Eq { - pure fn eq(&&other: Point) -> bool { + pure fn eq(other: &Point) -> bool { self.x == other.x && self.y == other.y } - pure fn ne(&&other: Point) -> bool { !self.eq(other) } + pure fn ne(other: &Point) -> bool { !self.eq(other) } } impl Quark : cmp::Eq { - pure fn eq(&&other: Quark) -> bool { + pure fn eq(other: &Quark) -> bool { match self { - Top(ref q) => match other { - Top(ref r) => q == r, - Bottom(_) => false - }, - Bottom(ref q) => match other { - Top(_) => false, - Bottom(ref r) => q == r - } + Top(ref q) => { + match *other { + Top(ref r) => q == r, + Bottom(_) => false + } + }, + Bottom(ref q) => { + match *other { + Top(_) => false, + Bottom(ref r) => q == r + } + }, } } - pure fn ne(&&other: Quark) -> bool { !self.eq(other) } + pure fn ne(other: &Quark) -> bool { !self.eq(other) } } impl CLike : cmp::Eq { - pure fn eq(&&other: CLike) -> bool { - self as int == other as int - } - pure fn ne(&&other: CLike) -> bool { !self.eq(other) } -} - -impl Expr : cmp::Eq { - pure fn eq(&&other: Expr) -> bool { - match self { - Val(e0a) => { - match other { - Val(e0b) => e0a == e0b, - _ => false - } - } - Plus(e0a, e1a) => { - match other { - Plus(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - Minus(e0a, e1a) => { - match other { - Minus(e0b, e1b) => e0a == e0b && e1a == e1b, - _ => false - } - } - } + pure fn eq(other: &CLike) -> bool { + self as int == *other as int } - pure fn ne(&&other: Expr) -> bool { !self.eq(other) } + pure fn ne(other: &CLike) -> bool { !self.eq(other) } } #[auto_serialize2] type Spanned = {lo: uint, hi: uint, node: T}; impl Spanned : cmp::Eq { - pure fn eq(&&other: Spanned) -> bool { - self.lo == other.lo && self.hi == other.hi && self.node.eq(other.node) + pure fn eq(other: &Spanned) -> bool { + self.lo == other.lo && self.hi == other.hi && self.node == other.node } - pure fn ne(&&other: Spanned) -> bool { !self.eq(other) } + pure fn ne(other: &Spanned) -> bool { !self.eq(other) } } #[auto_serialize2] @@ -128,12 +101,6 @@ enum Quark { enum CLike { A, B, C } fn main() { - - test_ser_and_deser(Plus(@Minus(@Val(3u), @Val(10u)), - @Plus(@Val(22u), @Val(5u))), - ~"Plus(@Minus(@Val(3u), @Val(10u)), \ - @Plus(@Val(22u), @Val(5u)))"); - test_ser_and_deser({lo: 0u, hi: 5u, node: 22u}, ~"{lo: 0u, hi: 5u, node: 22u}"); -- cgit 1.4.1-3-g733a5 From a1ab7d3cba6c753cd1c838f99fabf029e4c1d035 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 18 Sep 2012 10:47:39 -0700 Subject: libstd: Add serialization2 versions of prettyprint and ebml --- src/libstd/ebml2.rs | 623 +++++++++++++++++++++++++++++++++++++++++++++ src/libstd/prettyprint2.rs | 142 +++++++++++ src/libstd/std.rc | 8 +- 3 files changed, 772 insertions(+), 1 deletion(-) create mode 100644 src/libstd/ebml2.rs create mode 100644 src/libstd/prettyprint2.rs (limited to 'src/libstd/std.rc') diff --git a/src/libstd/ebml2.rs b/src/libstd/ebml2.rs new file mode 100644 index 00000000000..8b37dea6210 --- /dev/null +++ b/src/libstd/ebml2.rs @@ -0,0 +1,623 @@ +use serialization2; + +// Simple Extensible Binary Markup Language (ebml) reader and writer on a +// cursor model. See the specification here: +// http://www.matroska.org/technical/specs/rfc/index.html +export Doc; +export doc_at; +export maybe_get_doc; +export get_doc; +export docs; +export tagged_docs; +export doc_data; +export doc_as_str; +export doc_as_u8; +export doc_as_u16; +export doc_as_u32; +export doc_as_u64; +export doc_as_i8; +export doc_as_i16; +export doc_as_i32; +export doc_as_i64; +export Serializer; +export Deserializer; +export with_doc_data; +export get_doc; +export extensions; + +struct EbmlTag { + id: uint, + size: uint, +} + +struct EbmlState { + ebml_tag: EbmlTag, + tag_pos: uint, + data_pos: uint, +} + +// FIXME (#2739): When we have module renaming, make "reader" and "writer" +// separate modules within this file. + +// ebml reading +struct Doc { + data: @~[u8], + start: uint, + end: uint, +} + +struct TaggedDoc { + tag: uint, + doc: Doc, +} + +impl Doc: ops::Index { + pure fn index(+tag: uint) -> Doc { + unsafe { + get_doc(self, tag) + } + } +} + +fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { + let a = data[start]; + if a & 0x80u8 != 0u8 { + return {val: (a & 0x7fu8) as uint, next: start + 1u}; + } + if a & 0x40u8 != 0u8 { + return {val: ((a & 0x3fu8) as uint) << 8u | + (data[start + 1u] as uint), + next: start + 2u}; + } else if a & 0x20u8 != 0u8 { + return {val: ((a & 0x1fu8) as uint) << 16u | + (data[start + 1u] as uint) << 8u | + (data[start + 2u] as uint), + next: start + 3u}; + } else if a & 0x10u8 != 0u8 { + return {val: ((a & 0x0fu8) as uint) << 24u | + (data[start + 1u] as uint) << 16u | + (data[start + 2u] as uint) << 8u | + (data[start + 3u] as uint), + next: start + 4u}; + } else { error!("vint too big"); fail; } +} + +fn Doc(data: @~[u8]) -> Doc { + Doc { data: data, start: 0u, end: vec::len::(*data) } +} + +fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { + let elt_tag = vuint_at(*data, start); + let elt_size = vuint_at(*data, elt_tag.next); + let end = elt_size.next + elt_size.val; + TaggedDoc { + tag: elt_tag.val, + doc: Doc { data: data, start: elt_size.next, end: end } + } +} + +fn maybe_get_doc(d: Doc, tg: uint) -> Option { + let mut pos = d.start; + while pos < d.end { + let elt_tag = vuint_at(*d.data, pos); + let elt_size = vuint_at(*d.data, elt_tag.next); + pos = elt_size.next + elt_size.val; + if elt_tag.val == tg { + return Some(Doc { data: d.data, start: elt_size.next, end: pos }); + } + } + None +} + +fn get_doc(d: Doc, tg: uint) -> Doc { + match maybe_get_doc(d, tg) { + Some(d) => d, + None => { + error!("failed to find block with tag %u", tg); + fail; + } + } +} + +fn docs(d: Doc, it: fn(uint, Doc) -> bool) { + let mut pos = d.start; + while pos < d.end { + let elt_tag = vuint_at(*d.data, pos); + let elt_size = vuint_at(*d.data, elt_tag.next); + pos = elt_size.next + elt_size.val; + let doc = Doc { data: d.data, start: elt_size.next, end: pos }; + if !it(elt_tag.val, doc) { + break; + } + } +} + +fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { + let mut pos = d.start; + while pos < d.end { + let elt_tag = vuint_at(*d.data, pos); + let elt_size = vuint_at(*d.data, elt_tag.next); + pos = elt_size.next + elt_size.val; + if elt_tag.val == tg { + let doc = Doc { data: d.data, start: elt_size.next, end: pos }; + if !it(doc) { + break; + } + } + } +} + +fn doc_data(d: Doc) -> ~[u8] { vec::slice::(*d.data, d.start, d.end) } + +fn with_doc_data(d: Doc, f: fn(x: &[u8]) -> T) -> T { + f(vec::view(*d.data, d.start, d.end)) +} + +fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) } + +fn doc_as_u8(d: Doc) -> u8 { + assert d.end == d.start + 1u; + (*d.data)[d.start] +} + +fn doc_as_u16(d: Doc) -> u16 { + assert d.end == d.start + 2u; + io::u64_from_be_bytes(*d.data, d.start, 2u) as u16 +} + +fn doc_as_u32(d: Doc) -> u32 { + assert d.end == d.start + 4u; + io::u64_from_be_bytes(*d.data, d.start, 4u) as u32 +} + +fn doc_as_u64(d: Doc) -> u64 { + assert d.end == d.start + 8u; + io::u64_from_be_bytes(*d.data, d.start, 8u) +} + +fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 } +fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 } +fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } +fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } + +// ebml writing +struct Serializer { + writer: io::Writer, + priv mut size_positions: ~[uint], +} + +fn write_sized_vuint(w: io::Writer, n: uint, size: uint) { + match size { + 1u => w.write(&[0x80u8 | (n as u8)]), + 2u => w.write(&[0x40u8 | ((n >> 8_u) as u8), n as u8]), + 3u => w.write(&[0x20u8 | ((n >> 16_u) as u8), (n >> 8_u) as u8, + n as u8]), + 4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8, + (n >> 8_u) as u8, n as u8]), + _ => fail fmt!("vint to write too big: %?", n) + }; +} + +fn write_vuint(w: io::Writer, n: uint) { + if n < 0x7f_u { write_sized_vuint(w, n, 1u); return; } + if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } + if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } + if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } + fail fmt!("vint to write too big: %?", n); +} + +fn Serializer(w: io::Writer) -> Serializer { + let size_positions: ~[uint] = ~[]; + Serializer { writer: w, mut size_positions: size_positions } +} + +// FIXME (#2741): Provide a function to write the standard ebml header. +impl Serializer { + fn start_tag(tag_id: uint) { + debug!("Start tag %u", tag_id); + + // Write the enum ID: + write_vuint(self.writer, tag_id); + + // Write a placeholder four-byte size. + vec::push(self.size_positions, self.writer.tell()); + let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8]; + self.writer.write(zeroes); + } + + fn end_tag() { + let last_size_pos = vec::pop::(self.size_positions); + let cur_pos = self.writer.tell(); + self.writer.seek(last_size_pos as int, io::SeekSet); + let size = (cur_pos - last_size_pos - 4u); + write_sized_vuint(self.writer, size, 4u); + self.writer.seek(cur_pos as int, io::SeekSet); + + debug!("End tag (size = %u)", size); + } + + fn wr_tag(tag_id: uint, blk: fn()) { + self.start_tag(tag_id); + blk(); + self.end_tag(); + } + + fn wr_tagged_bytes(tag_id: uint, b: &[u8]) { + write_vuint(self.writer, tag_id); + write_vuint(self.writer, vec::len(b)); + self.writer.write(b); + } + + fn wr_tagged_u64(tag_id: uint, v: u64) { + do io::u64_to_be_bytes(v, 8u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u32(tag_id: uint, v: u32) { + do io::u64_to_be_bytes(v as u64, 4u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u16(tag_id: uint, v: u16) { + do io::u64_to_be_bytes(v as u64, 2u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_u8(tag_id: uint, v: u8) { + self.wr_tagged_bytes(tag_id, &[v]); + } + + fn wr_tagged_i64(tag_id: uint, v: i64) { + do io::u64_to_be_bytes(v as u64, 8u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i32(tag_id: uint, v: i32) { + do io::u64_to_be_bytes(v as u64, 4u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i16(tag_id: uint, v: i16) { + do io::u64_to_be_bytes(v as u64, 2u) |v| { + self.wr_tagged_bytes(tag_id, v); + } + } + + fn wr_tagged_i8(tag_id: uint, v: i8) { + self.wr_tagged_bytes(tag_id, &[v as u8]); + } + + fn wr_tagged_str(tag_id: uint, v: &str) { + str::byte_slice(v, |b| self.wr_tagged_bytes(tag_id, b)); + } + + fn wr_bytes(b: &[u8]) { + debug!("Write %u bytes", vec::len(b)); + self.writer.write(b); + } + + fn wr_str(s: ~str) { + debug!("Write str: %?", s); + self.writer.write(str::to_bytes(s)); + } +} + +// FIXME (#2743): optionally perform "relaxations" on end_tag to more +// efficiently encode sizes; this is a fixed point iteration + +// Set to true to generate more debugging in EBML serialization. +// Totally lame approach. +const debug: bool = false; + +enum EbmlSerializerTag { + EsUint, EsU64, EsU32, EsU16, EsU8, + EsInt, EsI64, EsI32, EsI16, EsI8, + EsBool, + EsStr, + EsF64, EsF32, EsFloat, + EsEnum, EsEnumVid, EsEnumBody, + EsVec, EsVecLen, EsVecElt, + + EsOpaque, + + EsLabel // Used only when debugging +} + +priv impl Serializer { + // used internally to emit things like the vector length and so on + fn _emit_tagged_uint(t: EbmlSerializerTag, v: uint) { + assert v <= 0xFFFF_FFFF_u; + self.wr_tagged_u32(t as uint, v as u32); + } + + fn _emit_label(label: &str) { + // There are various strings that we have access to, such as + // the name of a record field, which do not actually appear in + // the serialized EBML (normally). This is just for + // efficiency. When debugging, though, we can emit such + // labels and then they will be checked by deserializer to + // try and check failures more quickly. + if debug { self.wr_tagged_str(EsLabel as uint, label) } + } +} + +impl Serializer { + fn emit_opaque(&self, f: fn()) { + do self.wr_tag(EsOpaque as uint) { + f() + } + } +} + +impl Serializer: serialization2::Serializer { + fn emit_nil(&self) {} + + fn emit_uint(&self, v: uint) { + self.wr_tagged_u64(EsUint as uint, v as u64); + } + fn emit_u64(&self, v: u64) { self.wr_tagged_u64(EsU64 as uint, v); } + fn emit_u32(&self, v: u32) { self.wr_tagged_u32(EsU32 as uint, v); } + fn emit_u16(&self, v: u16) { self.wr_tagged_u16(EsU16 as uint, v); } + fn emit_u8(&self, v: u8) { self.wr_tagged_u8 (EsU8 as uint, v); } + + fn emit_int(&self, v: int) { + self.wr_tagged_i64(EsInt as uint, v as i64); + } + fn emit_i64(&self, v: i64) { self.wr_tagged_i64(EsI64 as uint, v); } + fn emit_i32(&self, v: i32) { self.wr_tagged_i32(EsI32 as uint, v); } + fn emit_i16(&self, v: i16) { self.wr_tagged_i16(EsI16 as uint, v); } + fn emit_i8(&self, v: i8) { self.wr_tagged_i8 (EsI8 as uint, v); } + + fn emit_bool(&self, v: bool) { + self.wr_tagged_u8(EsBool as uint, v as u8) + } + + // FIXME (#2742): implement these + fn emit_f64(&self, _v: f64) { fail ~"Unimplemented: serializing an f64"; } + fn emit_f32(&self, _v: f32) { fail ~"Unimplemented: serializing an f32"; } + fn emit_float(&self, _v: float) { + fail ~"Unimplemented: serializing a float"; + } + + fn emit_str(&self, v: &str) { self.wr_tagged_str(EsStr as uint, v) } + + fn emit_enum(&self, name: &str, f: fn()) { + self._emit_label(name); + self.wr_tag(EsEnum as uint, f) + } + fn emit_enum_variant(&self, _v_name: &str, v_id: uint, _cnt: uint, + f: fn()) { + self._emit_tagged_uint(EsEnumVid, v_id); + self.wr_tag(EsEnumBody as uint, f) + } + fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) { f() } + + fn emit_vec(&self, len: uint, f: fn()) { + do self.wr_tag(EsVec as uint) { + self._emit_tagged_uint(EsVecLen, len); + f() + } + } + + fn emit_vec_elt(&self, _idx: uint, f: fn()) { + self.wr_tag(EsVecElt as uint, f) + } + + fn emit_box(&self, f: fn()) { f() } + fn emit_uniq(&self, f: fn()) { f() } + fn emit_rec(&self, f: fn()) { f() } + fn emit_rec_field(&self, f_name: &str, _f_idx: uint, f: fn()) { + self._emit_label(f_name); + f() + } + fn emit_tup(&self, _sz: uint, f: fn()) { f() } + fn emit_tup_elt(&self, _idx: uint, f: fn()) { f() } +} + +struct Deserializer { + priv mut parent: Doc, + priv mut pos: uint, +} + +fn Deserializer(d: Doc) -> Deserializer { + Deserializer { mut parent: d, mut pos: d.start } +} + +priv impl Deserializer { + fn _check_label(lbl: ~str) { + if self.pos < self.parent.end { + let TaggedDoc { tag: r_tag, doc: r_doc } = + doc_at(self.parent.data, self.pos); + + if r_tag == (EsLabel as uint) { + self.pos = r_doc.end; + let str = doc_as_str(r_doc); + if lbl != str { + fail fmt!("Expected label %s but found %s", lbl, str); + } + } + } + } + + fn next_doc(exp_tag: EbmlSerializerTag) -> Doc { + debug!(". next_doc(exp_tag=%?)", exp_tag); + if self.pos >= self.parent.end { + fail ~"no more documents in current node!"; + } + let TaggedDoc { tag: r_tag, doc: r_doc } = + doc_at(self.parent.data, self.pos); + debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?", + copy self.parent.start, copy self.parent.end, + copy self.pos, r_tag, r_doc.start, r_doc.end); + if r_tag != (exp_tag as uint) { + fail fmt!("expected EMBL doc with tag %? but found tag %?", + exp_tag, r_tag); + } + if r_doc.end > self.parent.end { + fail fmt!("invalid EBML, child extends to 0x%x, parent to 0x%x", + r_doc.end, self.parent.end); + } + self.pos = r_doc.end; + r_doc + } + + fn push_doc(d: Doc, f: fn() -> T) -> T{ + let old_parent = self.parent; + let old_pos = self.pos; + self.parent = d; + self.pos = d.start; + let r = f(); + self.parent = old_parent; + self.pos = old_pos; + move r + } + + fn _next_uint(exp_tag: EbmlSerializerTag) -> uint { + let r = doc_as_u32(self.next_doc(exp_tag)); + debug!("_next_uint exp_tag=%? result=%?", exp_tag, r); + r as uint + } +} + +impl Deserializer { + fn read_opaque(&self, op: fn(Doc) -> R) -> R { + do self.push_doc(self.next_doc(EsOpaque)) { + op(copy self.parent) + } + } +} + +impl Deserializer: serialization2::Deserializer { + fn read_nil(&self) -> () { () } + + fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) } + fn read_u32(&self) -> u32 { doc_as_u32(self.next_doc(EsU32)) } + fn read_u16(&self) -> u16 { doc_as_u16(self.next_doc(EsU16)) } + fn read_u8 (&self) -> u8 { doc_as_u8 (self.next_doc(EsU8 )) } + fn read_uint(&self) -> uint { + let v = doc_as_u64(self.next_doc(EsUint)); + if v > (core::uint::max_value as u64) { + fail fmt!("uint %? too large for this architecture", v); + } + v as uint + } + + fn read_i64(&self) -> i64 { doc_as_u64(self.next_doc(EsI64)) as i64 } + fn read_i32(&self) -> i32 { doc_as_u32(self.next_doc(EsI32)) as i32 } + fn read_i16(&self) -> i16 { doc_as_u16(self.next_doc(EsI16)) as i16 } + fn read_i8 (&self) -> i8 { doc_as_u8 (self.next_doc(EsI8 )) as i8 } + fn read_int(&self) -> int { + let v = doc_as_u64(self.next_doc(EsInt)) as i64; + if v > (int::max_value as i64) || v < (int::min_value as i64) { + fail fmt!("int %? out of range for this architecture", v); + } + v as int + } + + fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool)) as bool } + + fn read_f64(&self) -> f64 { fail ~"read_f64()"; } + fn read_f32(&self) -> f32 { fail ~"read_f32()"; } + fn read_float(&self) -> float { fail ~"read_float()"; } + + fn read_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) } + + // Compound types: + fn read_enum(&self, name: ~str, f: fn() -> T) -> T { + debug!("read_enum(%s)", name); + self._check_label(name); + self.push_doc(self.next_doc(EsEnum), f) + } + + fn read_enum_variant(&self, f: fn(uint) -> T) -> T { + debug!("read_enum_variant()"); + let idx = self._next_uint(EsEnumVid); + debug!(" idx=%u", idx); + do self.push_doc(self.next_doc(EsEnumBody)) { + f(idx) + } + } + + fn read_enum_variant_arg(&self, idx: uint, f: fn() -> T) -> T { + debug!("read_enum_variant_arg(idx=%u)", idx); + f() + } + + fn read_vec(&self, f: fn(uint) -> T) -> T { + debug!("read_vec()"); + do self.push_doc(self.next_doc(EsVec)) { + let len = self._next_uint(EsVecLen); + debug!(" len=%u", len); + f(len) + } + } + + fn read_vec_elt(&self, idx: uint, f: fn() -> T) -> T { + debug!("read_vec_elt(idx=%u)", idx); + self.push_doc(self.next_doc(EsVecElt), f) + } + + fn read_box(&self, f: fn() -> T) -> T { + debug!("read_box()"); + f() + } + + fn read_uniq(&self, f: fn() -> T) -> T { + debug!("read_uniq()"); + f() + } + + fn read_rec(&self, f: fn() -> T) -> T { + debug!("read_rec()"); + f() + } + + fn read_rec_field(&self, f_name: ~str, f_idx: uint, + f: fn() -> T) -> T { + debug!("read_rec_field(%s, idx=%u)", f_name, f_idx); + self._check_label(f_name); + f() + } + + fn read_tup(&self, sz: uint, f: fn() -> T) -> T { + debug!("read_tup(sz=%u)", sz); + f() + } + + fn read_tup_elt(&self, idx: uint, f: fn() -> T) -> T { + debug!("read_tup_elt(idx=%u)", idx); + f() + } +} + + +// ___________________________________________________________________________ +// Testing + +#[cfg(test)] +mod tests { + #[test] + fn test_option_int() { + fn test_v(v: Option) { + debug!("v == %?", v); + let bytes = do io::with_bytes_writer |wr| { + let ebml_w = Serializer(wr); + v.serialize(&ebml_w) + }; + let ebml_doc = Doc(@bytes); + let deser = Deserializer(ebml_doc); + let v1 = serialization2::deserialize(&deser); + debug!("v1 == %?", v1); + assert v == v1; + } + + test_v(Some(22)); + test_v(None); + test_v(Some(3)); + } +} diff --git a/src/libstd/prettyprint2.rs b/src/libstd/prettyprint2.rs new file mode 100644 index 00000000000..c0e76662bcb --- /dev/null +++ b/src/libstd/prettyprint2.rs @@ -0,0 +1,142 @@ +#[forbid(deprecated_mode)]; +#[forbid(deprecated_pattern)]; + +use io::Writer; +use io::WriterUtil; +use serialization2; + +struct Serializer { + wr: io::Writer, +} + +fn Serializer(wr: io::Writer) -> Serializer { + Serializer { wr: wr } +} + +impl Serializer: serialization2::Serializer { + fn emit_nil(&self) { + self.wr.write_str(~"()") + } + + fn emit_uint(&self, v: uint) { + self.wr.write_str(fmt!("%?u", v)); + } + + fn emit_u64(&self, v: u64) { + self.wr.write_str(fmt!("%?_u64", v)); + } + + fn emit_u32(&self, v: u32) { + self.wr.write_str(fmt!("%?_u32", v)); + } + + fn emit_u16(&self, v: u16) { + self.wr.write_str(fmt!("%?_u16", v)); + } + + fn emit_u8(&self, v: u8) { + self.wr.write_str(fmt!("%?_u8", v)); + } + + fn emit_int(&self, v: int) { + self.wr.write_str(fmt!("%?", v)); + } + + fn emit_i64(&self, v: i64) { + self.wr.write_str(fmt!("%?_i64", v)); + } + + fn emit_i32(&self, v: i32) { + self.wr.write_str(fmt!("%?_i32", v)); + } + + fn emit_i16(&self, v: i16) { + self.wr.write_str(fmt!("%?_i16", v)); + } + + fn emit_i8(&self, v: i8) { + self.wr.write_str(fmt!("%?_i8", v)); + } + + fn emit_bool(&self, v: bool) { + self.wr.write_str(fmt!("%b", v)); + } + + fn emit_float(&self, v: float) { + self.wr.write_str(fmt!("%?_f", v)); + } + + fn emit_f64(&self, v: f64) { + self.wr.write_str(fmt!("%?_f64", v)); + } + + fn emit_f32(&self, v: f32) { + self.wr.write_str(fmt!("%?_f32", v)); + } + + fn emit_str(&self, v: &str) { + self.wr.write_str(fmt!("%?", v)); + } + + fn emit_enum(&self, _name: &str, f: fn()) { + f(); + } + + fn emit_enum_variant(&self, v_name: &str, _v_id: uint, sz: uint, + f: fn()) { + self.wr.write_str(v_name); + if sz > 0u { self.wr.write_str(~"("); } + f(); + if sz > 0u { self.wr.write_str(~")"); } + } + + fn emit_enum_variant_arg(&self, idx: uint, f: fn()) { + if idx > 0u { self.wr.write_str(~", "); } + f(); + } + + fn emit_vec(&self, _len: uint, f: fn()) { + self.wr.write_str(~"["); + f(); + self.wr.write_str(~"]"); + } + + fn emit_vec_elt(&self, idx: uint, f: fn()) { + if idx > 0u { self.wr.write_str(~", "); } + f(); + } + + fn emit_box(&self, f: fn()) { + self.wr.write_str(~"@"); + f(); + } + + fn emit_uniq(&self, f: fn()) { + self.wr.write_str(~"~"); + f(); + } + + fn emit_rec(&self, f: fn()) { + self.wr.write_str(~"{"); + f(); + self.wr.write_str(~"}"); + } + + fn emit_rec_field(&self, f_name: &str, f_idx: uint, f: fn()) { + if f_idx > 0u { self.wr.write_str(~", "); } + self.wr.write_str(f_name); + self.wr.write_str(~": "); + f(); + } + + fn emit_tup(&self, _sz: uint, f: fn()) { + self.wr.write_str(~"("); + f(); + self.wr.write_str(~")"); + } + + fn emit_tup_elt(&self, idx: uint, f: fn()) { + if idx > 0u { self.wr.write_str(~", "); } + f(); + } +} diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 548ec1c31b4..c3b7c1793ec 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -34,7 +34,9 @@ export sync, arc, comm; export bitv, deque, fun_treemap, list, map; export smallintmap, sort, treemap; export rope, arena, par; -export ebml, dbg, getopts, json, rand, sha1, term, time, prettyprint; +export ebml, ebml2; +export dbg, getopts, json, rand, sha1, term, time; +export prettyprint, prettyprint2; export test, tempfile, serialization, serialization2; export cmp; export base64; @@ -107,6 +109,8 @@ mod treemap; #[legacy_exports] mod ebml; #[legacy_exports] +mod ebml2; +#[legacy_exports] mod dbg; #[legacy_exports] mod getopts; @@ -125,6 +129,8 @@ mod time; #[legacy_exports] mod prettyprint; #[legacy_exports] +mod prettyprint2; +#[legacy_exports] mod arena; #[legacy_exports] mod par; -- cgit 1.4.1-3-g733a5 From 1845cf23aa61448a1996b1dca5a11a27dfdd28b0 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 27 Sep 2012 16:43:15 -0700 Subject: De-export std::{base64,cmp,par}. Part of #3583. --- src/libstd/base64.rs | 4 ++-- src/libstd/cmp.rs | 2 +- src/libstd/par.rs | 11 +++++------ src/libstd/std.rc | 3 --- 4 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index e5eacd5c440..995910e635d 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -2,7 +2,7 @@ #[forbid(deprecated_pattern)]; use io::Reader; -trait ToBase64 { +pub trait ToBase64 { fn to_base64() -> ~str; } @@ -63,7 +63,7 @@ impl &str: ToBase64 { } } -trait FromBase64 { +pub trait FromBase64 { fn from_base64() -> ~[u8]; } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 9b094f9215c..52c50a39f25 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -4,7 +4,7 @@ const fuzzy_epsilon: float = 1.0e-6; -trait FuzzyEq { +pub trait FuzzyEq { pure fn fuzzy_eq(other: &self) -> bool; } diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 2f98c4bad34..a0c9a1b92fe 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -1,6 +1,5 @@ use future_spawn = future::spawn; -export map, mapi, alli, any, mapi_factory; /** * The maximum number of tasks this module will spawn for a single @@ -73,7 +72,7 @@ fn map_slices( } /// A parallel version of map. -fn map(xs: ~[A], f: fn~(A) -> B) -> ~[B] { +pub fn map(xs: ~[A], f: fn~(A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { fn~(_base: uint, slice : &[A], copy f) -> ~[B] { vec::map(slice, |x| f(*x)) @@ -82,7 +81,7 @@ fn map(xs: ~[A], f: fn~(A) -> B) -> ~[B] { } /// A parallel version of mapi. -fn mapi(xs: ~[A], +pub fn mapi(xs: ~[A], f: fn~(uint, A) -> B) -> ~[B] { let slices = map_slices(xs, || { fn~(base: uint, slice : &[A], copy f) -> ~[B] { @@ -103,7 +102,7 @@ fn mapi(xs: ~[A], * In this case, f is a function that creates functions to run over the * inner elements. This is to skirt the need for copy constructors. */ -fn mapi_factory( +pub fn mapi_factory( xs: &[A], f: fn() -> fn~(uint, A) -> B) -> ~[B] { let slices = map_slices(xs, || { let f = f(); @@ -120,7 +119,7 @@ fn mapi_factory( } /// Returns true if the function holds for all elements in the vector. -fn alli(xs: ~[A], f: fn~(uint, A) -> bool) -> bool { +pub fn alli(xs: ~[A], f: fn~(uint, A) -> bool) -> bool { do vec::all(map_slices(xs, || { fn~(base: uint, slice : &[A], copy f) -> bool { vec::alli(slice, |i, x| { @@ -131,7 +130,7 @@ fn alli(xs: ~[A], f: fn~(uint, A) -> bool) -> bool { } /// Returns true if the function holds for any elements in the vector. -fn any(xs: ~[A], f: fn~(A) -> bool) -> bool { +pub fn any(xs: ~[A], f: fn~(A) -> bool) -> bool { do vec::any(map_slices(xs, || { fn~(_base : uint, slice: &[A], copy f) -> bool { vec::any(slice, |x| f(x)) diff --git a/src/libstd/std.rc b/src/libstd/std.rc index c3b7c1793ec..2f75ae07c84 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -132,11 +132,8 @@ mod prettyprint; mod prettyprint2; #[legacy_exports] mod arena; -#[legacy_exports] mod par; -#[legacy_exports] mod cmp; -#[legacy_exports] mod base64; #[cfg(unicode)] -- cgit 1.4.1-3-g733a5 From 86041c421dc5782bf48cdac4a4bc49dc1e50b360 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 27 Sep 2012 18:03:00 -0700 Subject: De-export std::{dbg,sha1,md4,tempfile,term}. Part of #3583. --- src/libstd/dbg.rs | 21 +++++++-------------- src/libstd/md4.rs | 6 +++--- src/libstd/sha1.rs | 3 +-- src/libstd/std.rc | 5 ----- src/libstd/tempfile.rs | 2 +- src/libstd/term.rs | 48 ++++++++++++++++++++++++------------------------ 6 files changed, 36 insertions(+), 49 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index 2b9df33b2d4..ac343053bed 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -4,13 +4,6 @@ use cast::reinterpret_cast; -export debug_tydesc; -export debug_opaque; -export debug_box; -export debug_tag; -export debug_fn; -export ptr_cast; -export breakpoint; #[abi = "cdecl"] extern mod rustrt { @@ -24,34 +17,34 @@ extern mod rustrt { fn rust_dbg_breakpoint(); } -fn debug_tydesc() { +pub fn debug_tydesc() { rustrt::debug_tydesc(sys::get_type_desc::()); } -fn debug_opaque(+x: T) { +pub fn debug_opaque(+x: T) { rustrt::debug_opaque(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_box(x: @T) { +pub fn debug_box(x: @T) { rustrt::debug_box(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_tag(+x: T) { +pub fn debug_tag(+x: T) { rustrt::debug_tag(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -fn debug_fn(+x: T) { +pub fn debug_fn(+x: T) { rustrt::debug_fn(sys::get_type_desc::(), ptr::addr_of(x) as *()); } -unsafe fn ptr_cast(x: @T) -> @U { +pub unsafe fn ptr_cast(x: @T) -> @U { reinterpret_cast( &rustrt::debug_ptrcast(sys::get_type_desc::(), reinterpret_cast(&x))) } /// Triggers a debugger breakpoint -fn breakpoint() { +pub fn breakpoint() { rustrt::rust_dbg_breakpoint(); } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 0bf4f6f8610..6de6ea8b16c 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -1,7 +1,7 @@ #[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; -fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { +pub fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { // subtle: if orig_len is merely uint, then the code below // which performs shifts by 32 bits or more has undefined // results. @@ -85,7 +85,7 @@ fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { return {a: a, b: b, c: c, d: d}; } -fn md4_str(msg: &[u8]) -> ~str { +pub fn md4_str(msg: &[u8]) -> ~str { let {a, b, c, d} = md4(msg); fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { f(a); f(b); f(c); f(d); @@ -103,7 +103,7 @@ fn md4_str(msg: &[u8]) -> ~str { result } -fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } +pub fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } #[test] fn test_md4() { diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index a40db2c1f1f..178bf2be7fe 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -20,7 +20,6 @@ * implementation, which is written for clarity, not speed. At some * point this will want to be rewritten. */ -export sha1; /// The SHA-1 interface trait Sha1 { @@ -53,7 +52,7 @@ const k3: u32 = 0xCA62C1D6u32; /// Construct a `sha` object -fn sha1() -> Sha1 { +pub fn sha1() -> Sha1 { type Sha1State = {h: ~[mut u32], mut len_low: u32, diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 2f75ae07c84..fba3f85ae5d 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -110,19 +110,14 @@ mod treemap; mod ebml; #[legacy_exports] mod ebml2; -#[legacy_exports] mod dbg; #[legacy_exports] mod getopts; #[legacy_exports] mod json; -#[legacy_exports] mod sha1; -#[legacy_exports] mod md4; -#[legacy_exports] mod tempfile; -#[legacy_exports] mod term; #[legacy_exports] mod time; diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 8b6b306d6b6..5c59bc02cb7 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -6,7 +6,7 @@ use core::option; use option::{None, Some}; -fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { +pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option { let r = rand::Rng(); let mut i = 0u; while (i < 1000u) { diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 6a264161bc7..af7fde5a174 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -6,35 +6,35 @@ use core::Option; // FIXME (#2807): Windows support. -const color_black: u8 = 0u8; -const color_red: u8 = 1u8; -const color_green: u8 = 2u8; -const color_yellow: u8 = 3u8; -const color_blue: u8 = 4u8; -const color_magenta: u8 = 5u8; -const color_cyan: u8 = 6u8; -const color_light_gray: u8 = 7u8; -const color_light_grey: u8 = 7u8; -const color_dark_gray: u8 = 8u8; -const color_dark_grey: u8 = 8u8; -const color_bright_red: u8 = 9u8; -const color_bright_green: u8 = 10u8; -const color_bright_yellow: u8 = 11u8; -const color_bright_blue: u8 = 12u8; -const color_bright_magenta: u8 = 13u8; -const color_bright_cyan: u8 = 14u8; -const color_bright_white: u8 = 15u8; +pub const color_black: u8 = 0u8; +pub const color_red: u8 = 1u8; +pub const color_green: u8 = 2u8; +pub const color_yellow: u8 = 3u8; +pub const color_blue: u8 = 4u8; +pub const color_magenta: u8 = 5u8; +pub const color_cyan: u8 = 6u8; +pub const color_light_gray: u8 = 7u8; +pub const color_light_grey: u8 = 7u8; +pub const color_dark_gray: u8 = 8u8; +pub const color_dark_grey: u8 = 8u8; +pub const color_bright_red: u8 = 9u8; +pub const color_bright_green: u8 = 10u8; +pub const color_bright_yellow: u8 = 11u8; +pub const color_bright_blue: u8 = 12u8; +pub const color_bright_magenta: u8 = 13u8; +pub const color_bright_cyan: u8 = 14u8; +pub const color_bright_white: u8 = 15u8; -fn esc(writer: io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } +pub fn esc(writer: io::Writer) { writer.write(~[0x1bu8, '[' as u8]); } /// Reset the foreground and background colors to default -fn reset(writer: io::Writer) { +pub fn reset(writer: io::Writer) { esc(writer); writer.write(~['0' as u8, 'm' as u8]); } /// Returns true if the terminal supports color -fn color_supported() -> bool { +pub fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; return match os::getenv(~"TERM") { @@ -48,7 +48,7 @@ fn color_supported() -> bool { }; } -fn set_color(writer: io::Writer, first_char: u8, color: u8) { +pub fn set_color(writer: io::Writer, first_char: u8, color: u8) { assert (color < 16u8); esc(writer); let mut color = color; @@ -57,12 +57,12 @@ fn set_color(writer: io::Writer, first_char: u8, color: u8) { } /// Set the foreground color -fn fg(writer: io::Writer, color: u8) { +pub fn fg(writer: io::Writer, color: u8) { return set_color(writer, '3' as u8, color); } /// Set the background color -fn bg(writer: io::Writer, color: u8) { +pub fn bg(writer: io::Writer, color: u8) { return set_color(writer, '4' as u8, color); } -- cgit 1.4.1-3-g733a5 From fe62ff465cb572e58b23bf1ddb0ce51e11c21e49 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 27 Sep 2012 18:21:32 -0700 Subject: De-mode std::{treemap,sort}. Part of #3583. --- src/libstd/sort.rs | 18 ++++++------------ src/libstd/std.rc | 3 --- src/libstd/treemap.rs | 15 +++++---------- 3 files changed, 11 insertions(+), 25 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index f1abe5be5a5..20a18b88320 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -5,12 +5,6 @@ use vec::{len, push}; use core::cmp::{Eq, Ord}; -export le; -export merge_sort; -export quick_sort; -export quick_sort3; -export Sort; - type Le = pure fn(v1: &T, v2: &T) -> bool; /** @@ -19,7 +13,7 @@ type Le = pure fn(v1: &T, v2: &T) -> bool; * Has worst case O(n log n) performance, best case O(n), but * is not space efficient. This is a stable sort. */ -fn merge_sort(le: Le, v: &[const T]) -> ~[T] { +pub fn merge_sort(le: Le, v: &[const T]) -> ~[T] { type Slice = (uint, uint); return merge_sort_(le, v, (0u, len(v))); @@ -93,7 +87,7 @@ fn qsort(compare_func: Le, arr: &[mut T], left: uint, * Has worst case O(n^2) performance, average case O(n log n). * This is an unstable sort. */ -fn quick_sort(compare_func: Le, arr: &[mut T]) { +pub fn quick_sort(compare_func: Le, arr: &[mut T]) { if len::(arr) == 0u { return; } qsort::(compare_func, arr, 0u, len::(arr) - 1u); } @@ -155,12 +149,12 @@ fn qsort3(arr: &[mut T], left: int, right: int) { * * This is an unstable sort. */ -fn quick_sort3(arr: &[mut T]) { +pub fn quick_sort3(arr: &[mut T]) { if arr.len() <= 1 { return; } qsort3(arr, 0, (arr.len() - 1) as int); } -trait Sort { +pub trait Sort { fn qsort(self); } @@ -274,7 +268,7 @@ mod tests { fn check_sort(v1: &[int], v2: &[int]) { let len = vec::len::(v1); - pure fn le(a: &int, b: &int) -> bool { *a <= *b } + pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } let f = le; let v3 = merge_sort::(f, v1); let mut i = 0u; @@ -304,7 +298,7 @@ mod tests { #[test] fn test_merge_sort_mutable() { - pure fn le(a: &int, b: &int) -> bool { *a <= *b } + pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } let v1 = ~[mut 3, 2, 1]; let v2 = merge_sort(le, v1); assert v2 == ~[1, 2, 3]; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index fba3f85ae5d..96d7b8c20fc 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -98,11 +98,8 @@ mod map; mod rope; #[legacy_exports] mod smallintmap; -#[legacy_exports] mod sort; -#[legacy_exports] mod treemap; -#[legacy_exports] // And ... other stuff diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 7fe8b145ed7..3419f1cb90c 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -12,12 +12,7 @@ use core::cmp::{Eq, Ord}; use core::option::{Some, None}; use Option = core::Option; -export TreeMap; -export insert; -export find; -export traverse; - -type TreeMap = @mut TreeEdge; +pub type TreeMap = @mut TreeEdge; type TreeEdge = Option<@TreeNode>; @@ -29,10 +24,10 @@ enum TreeNode = { }; /// Create a treemap -fn TreeMap() -> TreeMap { @mut None } +pub fn TreeMap() -> TreeMap { @mut None } /// Insert a value into the map -fn insert(m: &mut TreeEdge, +k: K, +v: V) { +pub fn insert(m: &mut TreeEdge, +k: K, +v: V) { match copy *m { None => { *m = Some(@TreeNode({key: k, @@ -54,7 +49,7 @@ fn insert(m: &mut TreeEdge, +k: K, +v: V) { } /// Find a value based on the key -fn find(m: &const TreeEdge, +k: K) +pub fn find(m: &const TreeEdge, +k: K) -> Option { match copy *m { None => None, @@ -73,7 +68,7 @@ fn find(m: &const TreeEdge, +k: K) } /// Visit all pairs in the map in order. -fn traverse(m: &const TreeEdge, f: fn((&K), (&V))) { +pub fn traverse(m: &const TreeEdge, f: fn((&K), (&V))) { match copy *m { None => (), Some(node) => { -- cgit 1.4.1-3-g733a5 From bc9efaad9c978f71bd7ac2c91efbc957e25d43fb Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 28 Sep 2012 00:22:18 -0700 Subject: std: Eliminate deprecated patterns --- src/libstd/arc.rs | 1 - src/libstd/arena.rs | 1 - src/libstd/base64.rs | 1 - src/libstd/bitv.rs | 61 ++++++++++++++++++++++---------------------- src/libstd/cell.rs | 1 - src/libstd/cmp.rs | 1 - src/libstd/comm.rs | 1 - src/libstd/dbg.rs | 1 - src/libstd/deque.rs | 3 +-- src/libstd/fun_treemap.rs | 15 +++++------ src/libstd/getopts.rs | 29 ++++++++++----------- src/libstd/json.rs | 23 ++++++++--------- src/libstd/list.rs | 13 +++++----- src/libstd/map.rs | 3 +-- src/libstd/md4.rs | 1 - src/libstd/net_ip.rs | 17 ++++++------ src/libstd/net_tcp.rs | 34 ++++++++++++------------ src/libstd/net_url.rs | 3 +-- src/libstd/prettyprint.rs | 1 - src/libstd/prettyprint2.rs | 1 - src/libstd/rope.rs | 17 ++++++------ src/libstd/serialization.rs | 4 +-- src/libstd/serialization2.rs | 11 ++++---- src/libstd/sha1.rs | 1 - src/libstd/smallintmap.rs | 5 ++-- src/libstd/sort.rs | 1 - src/libstd/std.rc | 1 + src/libstd/sync.rs | 1 - src/libstd/tempfile.rs | 1 - src/libstd/term.rs | 5 ++-- src/libstd/test.rs | 27 ++++++++++---------- src/libstd/time.rs | 3 +-- src/libstd/timer.rs | 1 - src/libstd/treemap.rs | 1 - src/libstd/unicode.rs | 1 - src/libstd/uv_global_loop.rs | 1 - src/libstd/uv_iotask.rs | 3 +-- 37 files changed, 130 insertions(+), 165 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 1f26822ed9f..a4d19b110d7 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -1,6 +1,5 @@ // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /** * Concurrency-enabled mechanisms for sharing mutable and/or immutable state * between tasks. diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index fbe9a2ddae6..de3c5774bfe 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -23,7 +23,6 @@ // to waste time running the destructors of POD. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; export Arena, arena_with_size; diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 995910e635d..9bad4d39750 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::Reader; pub trait ToBase64 { diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 0ff0c0b6457..33065fffd03 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use vec::{to_mut, from_elem}; @@ -241,22 +240,22 @@ priv impl Bitv { self.die(); } match self.rep { - Small(s) => match other.rep { - Small(s1) => match op { - Union => s.union(s1, self.nbits), - Intersect => s.intersect(s1, self.nbits), - Assign => s.become(s1, self.nbits), - Difference => s.difference(s1, self.nbits) + Small(ref s) => match other.rep { + Small(ref s1) => match op { + Union => s.union(*s1, self.nbits), + Intersect => s.intersect(*s1, self.nbits), + Assign => s.become(*s1, self.nbits), + Difference => s.difference(*s1, self.nbits) }, Big(_) => self.die() }, - Big(s) => match other.rep { + Big(ref s) => match other.rep { Small(_) => self.die(), - Big(s1) => match op { - Union => s.union(s1, self.nbits), - Intersect => s.intersect(s1, self.nbits), - Assign => s.become(s1, self.nbits), - Difference => s.difference(s1, self.nbits) + Big(ref s1) => match op { + Union => s.union(*s1, self.nbits), + Intersect => s.intersect(*s1, self.nbits), + Assign => s.become(*s1, self.nbits), + Difference => s.difference(*s1, self.nbits) } } } @@ -297,10 +296,10 @@ impl Bitv { #[inline(always)] fn clone() -> ~Bitv { ~match self.rep { - Small(b) => { + Small(ref b) => { Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})} } - Big(b) => { + Big(ref b) => { let st = to_mut(from_elem(self.nbits / uint_bits + 1, 0)); let len = st.len(); for uint::range(0, len) |i| { st[i] = b.storage[i]; }; @@ -314,8 +313,8 @@ impl Bitv { pure fn get(i: uint) -> bool { assert (i < self.nbits); match self.rep { - Big(b) => b.get(i), - Small(s) => s.get(i) + Big(ref b) => b.get(i), + Small(ref s) => s.get(i) } } @@ -328,8 +327,8 @@ impl Bitv { fn set(i: uint, x: bool) { assert (i < self.nbits); match self.rep { - Big(b) => b.set(i, x), - Small(s) => s.set(i, x) + Big(ref b) => b.set(i, x), + Small(ref s) => s.set(i, x) } } @@ -343,12 +342,12 @@ impl Bitv { fn equal(v1: Bitv) -> bool { if self.nbits != v1.nbits { return false; } match self.rep { - Small(b) => match v1.rep { - Small(b1) => b.equals(b1, self.nbits), + Small(ref b) => match v1.rep { + Small(ref b1) => b.equals(*b1, self.nbits), _ => false }, - Big(s) => match v1.rep { - Big(s1) => s.equals(s1, self.nbits), + Big(ref s) => match v1.rep { + Big(ref s1) => s.equals(*s1, self.nbits), Small(_) => return false } } @@ -358,8 +357,8 @@ impl Bitv { #[inline(always)] fn clear() { match self.rep { - Small(b) => b.clear(), - Big(s) => for s.each_storage() |w| { w = 0u } + Small(ref b) => b.clear(), + Big(ref s) => for s.each_storage() |w| { w = 0u } } } @@ -367,16 +366,16 @@ impl Bitv { #[inline(always)] fn set_all() { match self.rep { - Small(b) => b.set_all(), - Big(s) => for s.each_storage() |w| { w = !0u } } + Small(ref b) => b.set_all(), + Big(ref s) => for s.each_storage() |w| { w = !0u } } } /// Invert all bits #[inline(always)] fn invert() { match self.rep { - Small(b) => b.invert(), - Big(s) => for s.each_storage() |w| { w = !w } } + Small(ref b) => b.invert(), + Big(ref s) => for s.each_storage() |w| { w = !w } } } /** @@ -395,7 +394,7 @@ impl Bitv { #[inline(always)] fn is_true() -> bool { match self.rep { - Small(b) => b.is_true(self.nbits), + Small(ref b) => b.is_true(self.nbits), _ => { for self.each() |i| { if !i { return false; } } true @@ -415,7 +414,7 @@ impl Bitv { /// Returns true if all bits are 0 fn is_false() -> bool { match self.rep { - Small(b) => b.is_false(self.nbits), + Small(ref b) => b.is_false(self.nbits), Big(_) => { for self.each() |i| { if i { return false; } } true diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index bc16aa2e03e..4ef695f4198 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /// A dynamic, mutable location. /// /// Similar to a mutable option type, but friendlier. diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index 52c50a39f25..2ec0bf41675 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /// Additional general-purpose comparison functionality. const fuzzy_epsilon: float = 1.0e-6; diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index e2d4646d670..58958d6115e 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -6,7 +6,6 @@ Higher level communication abstractions. // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use pipes::{Channel, Recv, Chan, Port, Selectable}; diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index ac343053bed..26b2a02ec9c 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; //! Unsafe debugging functions for inspecting values. use cast::reinterpret_cast; diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 8506bd5f6fc..515f033b1f1 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -1,6 +1,5 @@ //! A deque. Untested as of yet. Likely buggy #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[forbid(non_camel_case_types)]; use option::{Some, None}; @@ -46,7 +45,7 @@ fn create() -> Deque { move rv } fn get(elts: &DVec>, i: uint) -> T { - match (*elts).get_elt(i) { Some(t) => t, _ => fail } + match (*elts).get_elt(i) { Some(move t) => t, _ => fail } } type Repr = {mut nelts: uint, diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 778a62eebbe..6388e8983d2 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -1,5 +1,4 @@ #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /*! * A functional key,value store that works on anything. @@ -37,7 +36,7 @@ fn insert(m: Treemap, +k: K, +v: V) -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), - @Node(@kk, vv, left, right) => { + @Node(@copy kk, vv, left, right) => { if k < kk { Node(@kk, vv, insert(left, k, v), right) } else if k == kk { @@ -51,10 +50,10 @@ fn insert(m: Treemap, +k: K, +v: V) fn find(m: Treemap, +k: K) -> Option { match *m { Empty => None, - Node(@kk, @v, left, right) => { - if k == kk { + Node(@ref kk, @copy v, left, right) => { + if k == *kk { Some(v) - } else if k < kk { find(left, move k) } else { find(right, move k) } + } else if k < *kk { find(left, move k) } else { find(right, move k) } } } } @@ -68,11 +67,9 @@ fn traverse(m: Treemap, f: fn((&K), (&V))) { matches to me, so I changed it. but that may be a de-optimization -- tjc */ - Node(@k, @v, left, right) => { - // copy v to make aliases work out - let v1 = v; + Node(@ref k, @ref v, left, right) => { traverse(left, f); - f(&k, &v1); + f(k, v); traverse(right, f); } } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 7a47db8a7f0..3106ed953b1 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -63,7 +63,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use core::result::{Err, Ok}; @@ -110,9 +109,9 @@ fn mkname(nm: &str) -> Name { impl Name : Eq { pure fn eq(other: &Name) -> bool { match self { - Long(e0a) => { + Long(ref e0a) => { match (*other) { - Long(e0b) => e0a == e0b, + Long(ref e0b) => e0a == e0b, _ => false } } @@ -177,7 +176,7 @@ fn is_arg(arg: &str) -> bool { fn name_str(nm: &Name) -> ~str { return match *nm { Short(ch) => str::from_char(ch), - Long(s) => s + Long(copy s) => s }; } @@ -200,12 +199,12 @@ enum Fail_ { /// Convert a `fail_` enum into an error string fn fail_str(+f: Fail_) -> ~str { return match f { - ArgumentMissing(nm) => ~"Argument to option '" + nm + ~"' missing.", - UnrecognizedOption(nm) => ~"Unrecognized option: '" + nm + ~"'.", - OptionMissing(nm) => ~"Required option '" + nm + ~"' missing.", - OptionDuplicated(nm) => ~"Option '" + nm + ~"' given more than once.", - UnexpectedArgument(nm) => { - ~"Option " + nm + ~" does not take an argument." + ArgumentMissing(ref nm) => ~"Argument to option '" + *nm + ~"' missing.", + UnrecognizedOption(ref nm) => ~"Unrecognized option: '" + *nm + ~"'.", + OptionMissing(ref nm) => ~"Required option '" + *nm + ~"' missing.", + OptionDuplicated(ref nm) => ~"Option '" + *nm + ~"' given more than once.", + UnexpectedArgument(ref nm) => { + ~"Option " + *nm + ~" does not take an argument." } }; } @@ -382,7 +381,7 @@ fn opts_present(+mm: Matches, names: &[~str]) -> bool { * argument */ fn opt_str(+mm: Matches, nm: &str) -> ~str { - return match opt_val(mm, nm) { Val(s) => s, _ => fail }; + return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; } /** @@ -394,7 +393,7 @@ fn opt_str(+mm: Matches, nm: &str) -> ~str { fn opts_str(+mm: Matches, names: &[~str]) -> ~str { for vec::each(names) |nm| { match opt_val(mm, *nm) { - Val(s) => return s, + Val(copy s) => return s, _ => () } } @@ -411,7 +410,7 @@ fn opts_str(+mm: Matches, names: &[~str]) -> ~str { fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(mm, nm)) |v| { - match *v { Val(s) => acc.push(s), _ => () } + match *v { Val(copy s) => acc.push(s), _ => () } } return acc; } @@ -420,7 +419,7 @@ fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } - return match vals[0] { Val(s) => Some::<~str>(s), _ => None::<~str> }; + return match vals[0] { Val(copy s) => Some::<~str>(s), _ => None::<~str> }; } @@ -434,7 +433,7 @@ fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } - return match vals[0] { Val(s) => Some::<~str>(s), + return match vals[0] { Val(copy s) => Some::<~str>(s), _ => Some::<~str>(str::from_slice(def)) } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 29535c62b5e..9e53febb85f 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1,7 +1,6 @@ // Rust JSON serialization library // Copyright (c) 2011 Google Inc. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[forbid(non_camel_case_types)]; //! json serialization @@ -252,7 +251,7 @@ pub impl PrettySerializer: serialization2::Serializer { pub fn to_serializer(ser: &S, json: &Json) { match *json { Number(f) => ser.emit_float(f), - String(s) => ser.emit_str(s), + String(ref s) => ser.emit_str(*s), Boolean(b) => ser.emit_bool(b), List(v) => { do ser.emit_vec(v.len()) || { @@ -261,7 +260,7 @@ pub fn to_serializer(ser: &S, json: &Json) { } } } - Object(o) => { + Object(ref o) => { do ser.emit_rec || { let mut idx = 0; for o.each |key, value| { @@ -866,8 +865,8 @@ impl Json : Eq { match self { Number(f0) => match *other { Number(f1) => f0 == f1, _ => false }, - String(s0) => - match *other { String(s1) => s0 == s1, _ => false }, + String(ref s0) => + match *other { String(ref s1) => s0 == s1, _ => false }, Boolean(b0) => match *other { Boolean(b1) => b0 == b1, _ => false }, Null => @@ -910,10 +909,10 @@ impl Json : Ord { } } - String(s0) => { + String(ref s0) => { match *other { Number(_) => false, - String(s1) => s0 < s1, + String(ref s1) => s0 < s1, Boolean(_) | List(_) | Object(_) | Null => true } } @@ -934,10 +933,10 @@ impl Json : Ord { } } - Object(d0) => { + Object(ref d0) => { match *other { Number(_) | String(_) | Boolean(_) | List(_) => false, - Object(d1) => { + Object(ref d1) => { unsafe { let mut d0_flat = ~[]; let mut d1_flat = ~[]; @@ -1065,7 +1064,7 @@ impl @~str: ToJson { impl (A, B): ToJson { fn to_json() -> Json { match self { - (a, b) => { + (ref a, ref b) => { List(~[a.to_json(), b.to_json()]) } } @@ -1075,7 +1074,7 @@ impl (A, B): ToJson { impl (A, B, C): ToJson { fn to_json() -> Json { match self { - (a, b, c) => { + (ref a, ref b, ref c) => { List(~[a.to_json(), b.to_json(), c.to_json()]) } } @@ -1112,7 +1111,7 @@ impl Option: ToJson { fn to_json() -> Json { match self { None => Null, - Some(value) => value.to_json() + Some(ref value) => value.to_json() } } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index d8f7edada6a..1568c6c099f 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -1,6 +1,5 @@ //! A standard linked list #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use core::option; @@ -47,8 +46,8 @@ fn find(ls: @List, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { - Cons(hd, tl) => { - if f(&hd) { return Some(hd); } + Cons(ref hd, tl) => { + if f(hd) { return Some(*hd); } tl } Nil => return None @@ -95,7 +94,7 @@ pure fn tail(ls: @List) -> @List { /// Returns the first element of a list pure fn head(ls: @List) -> T { match *ls { - Cons(hd, _) => hd, + Cons(copy hd, _) => hd, // makes me sad _ => fail ~"head invoked on empty list" } @@ -105,7 +104,7 @@ pure fn head(ls: @List) -> T { pure fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, - Cons(x, xs) => { + Cons(copy x, xs) => { let rest = append(xs, m); return @Cons(x, rest); } @@ -151,9 +150,9 @@ fn each(l: @List, f: fn((&T)) -> bool) { impl List : Eq { pure fn eq(other: &List) -> bool { match self { - Cons(e0a, e1a) => { + Cons(ref e0a, e1a) => { match (*other) { - Cons(e0b, e1b) => e0a == e0b && e1a == e1b, + Cons(ref e0b, e1b) => e0a == e0b && e1a == e1b, _ => false } } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 06df5a9e8ae..fce75cbda75 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -1,7 +1,6 @@ //! A map type #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::WriterUtil; use to_str::ToStr; @@ -404,7 +403,7 @@ fn hash_from_vec( let map = HashMap(); for vec::each(items) |item| { match *item { - (key, value) => { + (copy key, copy value) => { map.insert(key, value); } } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 6de6ea8b16c..581beb78bdc 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; pub fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} { // subtle: if orig_len is merely uint, then the code below diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 347f2b271a1..ad4eb9a0fa6 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -1,6 +1,5 @@ //! Types/fns concerning Internet Protocol (IP), versions 4 & 6 #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use iotask = uv::iotask::IoTask; use interact = uv::iotask::interact; @@ -48,15 +47,15 @@ type ParseAddrErr = { */ fn format_addr(ip: &IpAddr) -> ~str { match *ip { - Ipv4(addr) => unsafe { - let result = uv_ip4_name(&addr); + Ipv4(ref addr) => unsafe { + let result = uv_ip4_name(addr); if result == ~"" { fail ~"failed to convert inner sockaddr_in address to str" } result }, - Ipv6(addr) => unsafe { - let result = uv_ip6_name(&addr); + Ipv6(ref addr) => unsafe { + let result = uv_ip6_name(addr); if result == ~"" { fail ~"failed to convert inner sockaddr_in address to str" } @@ -136,8 +135,8 @@ mod v4 { */ fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { - result::Ok(addr) => copy(addr), - result::Err(err_data) => fail err_data.err_msg + result::Ok(copy addr) => addr, + result::Err(ref err_data) => fail err_data.err_msg } } // the simple, old style numberic representation of @@ -223,8 +222,8 @@ mod v6 { */ fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { - result::Ok(addr) => copy(addr), - result::Err(err_data) => fail err_data.err_msg + result::Ok(copy addr) => addr, + result::Err(copy err_data) => fail err_data.err_msg } } fn try_parse_addr(ip: &str) -> result::Result { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index a0ba8aae3f1..011c7e6a0c7 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -168,7 +168,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint, ptr::addr_of((*socket_data_ptr).connect_req); let addr_str = ip::format_addr(&input_ip); let connect_result = match input_ip { - ip::Ipv4(addr) => { + ip::Ipv4(ref addr) => { // have to "recreate" the sockaddr_in/6 // since the ip_addr discards the port // info.. should probably add an additional @@ -233,7 +233,7 @@ fn connect(+input_ip: ip::IpAddr, port: uint, log(debug, ~"tcp::connect - received success on result_po"); result::Ok(TcpSocket(socket_data)) } - ConnFailure(err_data) => { + ConnFailure(ref err_data) => { core::comm::recv(closed_signal_po); log(debug, ~"tcp::connect - received failure on result_po"); // still have to free the malloc'd stream handle.. @@ -535,7 +535,7 @@ fn accept(new_conn: TcpNewConnection) } // UNSAFE LIBUV INTERACTION END match core::comm::recv(result_po) { - Some(err_data) => result::Err(err_data), + Some(copy err_data) => result::Err(err_data), None => result::Ok(TcpSocket(client_socket_data)) } } @@ -623,13 +623,13 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, server_data_ptr); let addr_str = ip::format_addr(&loc_ip); let bind_result = match loc_ip { - ip::Ipv4(addr) => { + ip::Ipv4(ref addr) => { log(debug, fmt!("addr: %?", addr)); let in_addr = uv::ll::ip4_addr(addr_str, port as int); uv::ll::tcp_bind(server_stream_ptr, ptr::addr_of(in_addr)) } - ip::Ipv6(addr) => { + ip::Ipv6(ref addr) => { log(debug, fmt!("addr: %?", addr)); let in_addr = uv::ll::ip6_addr(addr_str, port as int); uv::ll::tcp_bind6(server_stream_ptr, @@ -666,7 +666,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, setup_ch.recv() }; match setup_result { - Some(err_data) => { + Some(ref err_data) => { do iotask::interact(iotask) |loop_ptr| unsafe { log(debug, fmt!("tcp::listen post-kill recv hl interact %?", loop_ptr)); @@ -703,7 +703,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, stream_closed_po.recv(); match kill_result { // some failure post bind/listen - Some(err_data) => result::Err(GenericListenErr(err_data.err_name, + Some(ref err_data) => result::Err(GenericListenErr(err_data.err_name, err_data.err_msg)), // clean exit None => result::Ok(()) @@ -884,7 +884,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint) Some(core::comm::recv(result::get(&rs_result))) }; log(debug, ~"tcp::read after recv_timeout"); - match read_result { + match move read_result { None => { log(debug, ~"tcp::read: timed out.."); let err_data = { @@ -894,7 +894,7 @@ fn read_common_impl(socket_data: *TcpSocketData, timeout_msecs: uint) read_stop_common_impl(socket_data); result::Err(err_data) } - Some(data_result) => { + Some(move data_result) => { log(debug, ~"tcp::read got data"); read_stop_common_impl(socket_data); data_result @@ -924,7 +924,7 @@ fn read_stop_common_impl(socket_data: *TcpSocketData) -> } }; match core::comm::recv(stop_po) { - Some(err_data) => result::Err(err_data.to_tcp_err()), + Some(ref err_data) => result::Err(err_data.to_tcp_err()), None => result::Ok(()) } } @@ -954,7 +954,7 @@ fn read_start_common_impl(socket_data: *TcpSocketData) } }; match core::comm::recv(start_po) { - Some(err_data) => result::Err(err_data.to_tcp_err()), + Some(ref err_data) => result::Err(err_data.to_tcp_err()), None => result::Ok((*socket_data).reader_po) } } @@ -1001,7 +1001,7 @@ fn write_common_impl(socket_data_ptr: *TcpSocketData, // aftermath, so we don't have to sit here blocking. match core::comm::recv(result_po) { TcpWriteSuccess => result::Ok(()), - TcpWriteError(err_data) => result::Err(err_data.to_tcp_err()) + TcpWriteError(ref err_data) => result::Err(err_data.to_tcp_err()) } } @@ -1530,8 +1530,8 @@ mod test { log(debug, ~"SERVER: successfully accepted"+ ~"connection!"); let received_req_bytes = read(&sock, 0u); - match received_req_bytes { - result::Ok(data) => { + match move received_req_bytes { + result::Ok(move data) => { log(debug, ~"SERVER: got REQ str::from_bytes.."); log(debug, fmt!("SERVER: REQ data len: %?", vec::len(data))); @@ -1542,7 +1542,7 @@ mod test { log(debug, ~"SERVER: after write.. die"); core::comm::send(kill_ch, None); } - result::Err(err_data) => { + result::Err(move err_data) => { log(debug, fmt!("SERVER: error recvd: %s %s", err_data.err_name, err_data.err_msg)); core::comm::send(kill_ch, Some(err_data)); @@ -1560,9 +1560,9 @@ mod test { // err check on listen_result if result::is_err(&listen_result) { match result::get_err(&listen_result) { - GenericListenErr(name, msg) => { + GenericListenErr(ref name, ref msg) => { fail fmt!("SERVER: exited abnormally name %s msg %s", - name, msg); + *name, *msg); } AccessDenied => { fail ~"SERVER: exited abnormally, got access denied.."; diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 33e657c390b..00226c4e81e 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -1,6 +1,5 @@ //! Types/fns concerning URLs (see RFC 3986) #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use map::HashMap; @@ -661,7 +660,7 @@ fn from_str(rawurl: &str) -> result::Result { impl Url : FromStr { static fn from_str(s: &str) -> Option { match from_str(s) { - Ok(url) => Some(url), + Ok(move url) => Some(url), Err(_) => None } } diff --git a/src/libstd/prettyprint.rs b/src/libstd/prettyprint.rs index fa4c41dfa13..bc528800666 100644 --- a/src/libstd/prettyprint.rs +++ b/src/libstd/prettyprint.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::Writer; use io::WriterUtil; diff --git a/src/libstd/prettyprint2.rs b/src/libstd/prettyprint2.rs index c0e76662bcb..325d240eb57 100644 --- a/src/libstd/prettyprint2.rs +++ b/src/libstd/prettyprint2.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use io::Writer; use io::WriterUtil; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 4680448e275..1d88b89277d 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -24,7 +24,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /// The type of ropes. type Rope = node::Root; @@ -738,14 +737,14 @@ mod node { //FIXME (#2744): Could we do this without the pattern-matching? match (*node) { Leaf(y) => return y.byte_len, - Concat(y) => return y.byte_len + Concat(ref y) => return y.byte_len } } pure fn char_len(node: @Node) -> uint { match (*node) { Leaf(y) => return y.char_len, - Concat(y) => return y.char_len + Concat(ref y) => return y.char_len } } @@ -835,7 +834,7 @@ mod node { fn flatten(node: @Node) -> @Node unsafe { match (*node) { Leaf(_) => return node, - Concat(x) => { + Concat(ref x) => { return @Leaf({ byte_offset: 0u, byte_len: x.byte_len, @@ -913,7 +912,7 @@ mod node { char_len: char_len, content: x.content}); } - node::Concat(x) => { + node::Concat(ref x) => { let left_len: uint = node::byte_len(x.left); if byte_offset <= left_len { if byte_offset + byte_len <= left_len { @@ -976,7 +975,7 @@ mod node { char_len: char_len, content: x.content}); } - node::Concat(x) => { + node::Concat(ref x) => { if char_offset == 0u && char_len == x.char_len {return node;} let left_len : uint = node::char_len(x.left); if char_offset <= left_len { @@ -1015,7 +1014,7 @@ mod node { fn height(node: @Node) -> uint { match (*node) { Leaf(_) => return 0u, - Concat(x) => return x.height + Concat(ref x) => return x.height } } @@ -1067,7 +1066,7 @@ mod node { loop { match (*current) { Leaf(x) => return it(x), - Concat(x) => if loop_leaves(x.left, it) { //non tail call + Concat(ref x) => if loop_leaves(x.left, it) { //non tail call current = x.right; //tail call } else { return false; @@ -1134,7 +1133,7 @@ mod node { let current = it.stack[it.stackpos]; it.stackpos -= 1; match (*current) { - Concat(x) => { + Concat(ref x) => { it.stackpos += 1; it.stack[it.stackpos] = x.right; it.stackpos += 1; diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index af581ba4958..a385924e846 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -245,9 +245,9 @@ fn serialize_Option(s: S, v: Option, st: fn(T)) { None => do s.emit_enum_variant(~"none", 0u, 0u) { }, - Some(v) => do s.emit_enum_variant(~"some", 1u, 1u) { + Some(ref v) => do s.emit_enum_variant(~"some", 1u, 1u) { do s.emit_enum_variant_arg(0u) { - st(v) + st(*v) } } } diff --git a/src/libstd/serialization2.rs b/src/libstd/serialization2.rs index 81941627ef6..09954affc21 100644 --- a/src/libstd/serialization2.rs +++ b/src/libstd/serialization2.rs @@ -5,7 +5,6 @@ Core serialization interfaces. */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; #[forbid(non_camel_case_types)]; pub trait Serializer { @@ -235,7 +234,7 @@ pub impl Option: Serializable { None => do s.emit_enum_variant(~"none", 0u, 0u) { }, - Some(v) => do s.emit_enum_variant(~"some", 1u, 1u) { + Some(ref v) => do s.emit_enum_variant(~"some", 1u, 1u) { s.emit_enum_variant_arg(0u, || v.serialize(s)) } } @@ -261,7 +260,7 @@ pub impl< > (T0, T1): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1) => { + (ref t0, ref t1) => { do s.emit_tup(2) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); @@ -287,7 +286,7 @@ pub impl< > (T0, T1, T2): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1, t2) => { + (ref t0, ref t1, ref t2) => { do s.emit_tup(3) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); @@ -316,7 +315,7 @@ pub impl< > (T0, T1, T2, T3): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1, t2, t3) => { + (ref t0, ref t1, ref t2, ref t3) => { do s.emit_tup(4) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); @@ -348,7 +347,7 @@ pub impl< > (T0, T1, T2, T3, T4): Serializable { fn serialize(&self, s: &S) { match *self { - (t0, t1, t2, t3, t4) => { + (ref t0, ref t1, ref t2, ref t3, ref t4) => { do s.emit_tup(5) { s.emit_tup_elt(0, || t0.serialize(s)); s.emit_tup_elt(1, || t1.serialize(s)); diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 178bf2be7fe..05890035273 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -13,7 +13,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /* * A SHA-1 implementation derived from Paul E. Jones's reference diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 5fc8ead59fd..e3927ef188c 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -3,7 +3,6 @@ * are O(highest integer key). */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::option; use core::option::{Some, None}; @@ -56,7 +55,7 @@ pure fn get(self: SmallIntMap, key: uint) -> T { error!("smallintmap::get(): key not present"); fail; } - Some(v) => return v + Some(move v) => return v } } @@ -117,7 +116,7 @@ impl SmallIntMap: map::Map { let mut idx = 0u, l = self.v.len(); while idx < l { match self.v.get_elt(idx) { - Some(elt) => if !it(&idx, &elt) { break }, + Some(ref elt) => if !it(&idx, elt) { break }, None => () } idx += 1u; diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 20a18b88320..f783addcf50 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1,6 +1,5 @@ //! Sorting methods #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use vec::{len, push}; use core::cmp::{Eq, Ord}; diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 96d7b8c20fc..5370f20cfa1 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -23,6 +23,7 @@ not required in or otherwise suitable for the core library. #[allow(vecs_implicitly_copyable)]; #[deny(non_camel_case_types)]; +#[forbid(deprecated_pattern)]; extern mod core(vers = "0.4"); use core::*; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 7638b43ad86..c94a1ab46bf 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -1,6 +1,5 @@ // NB: transitionary, de-mode-ing. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; /** * The concurrency primitives you know and love. * diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index 5c59bc02cb7..84c04aa1bd7 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -1,7 +1,6 @@ //! Temporary files and directories #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::option; use option::{None, Some}; diff --git a/src/libstd/term.rs b/src/libstd/term.rs index af7fde5a174..2c12fd11e6e 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -1,6 +1,5 @@ //! Simple ANSI color library #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::Option; @@ -38,9 +37,9 @@ pub fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; return match os::getenv(~"TERM") { - option::Some(env) => { + option::Some(ref env) => { for vec::each(supported_terms) |term| { - if *term == env { return true; } + if *term == *env { return true; } } false } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 50366768e96..cb69c60a1c2 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -6,7 +6,6 @@ // while providing a base that other test frameworks may build off of. #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use either::Either; @@ -59,8 +58,8 @@ type TestDesc = { fn test_main(args: &[~str], tests: &[TestDesc]) { let opts = match parse_opts(args) { - either::Left(o) => o, - either::Right(m) => fail m + either::Left(move o) => o, + either::Right(move m) => fail m }; if !run_tests_console(&opts, tests) { fail ~"Some tests failed"; } } @@ -76,8 +75,8 @@ fn parse_opts(args: &[~str]) -> OptRes { let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")]; let matches = match getopts::getopts(args_, opts) { - Ok(m) => m, - Err(f) => return either::Right(getopts::fail_str(f)) + Ok(move m) => m, + Err(move f) => return either::Right(getopts::fail_str(f)) }; let filter = @@ -120,13 +119,13 @@ fn run_tests_console(opts: &TestOpts, fn callback(event: &TestEvent, st: ConsoleTestState) { debug!("callback(event=%?)", event); match *event { - TeFiltered(filtered_tests) => { - st.total = vec::len(filtered_tests); + TeFiltered(ref filtered_tests) => { + st.total = filtered_tests.len(); let noun = if st.total != 1u { ~"tests" } else { ~"test" }; st.out.write_line(fmt!("\nrunning %u %s", st.total, noun)); } - TeWait(test) => st.out.write_str(fmt!("test %s ... ", test.name)), - TeResult(test, result) => { + TeWait(ref test) => st.out.write_str(fmt!("test %s ... ", test.name)), + TeResult(copy test, result) => { match st.log_out { Some(f) => write_log(f, result, &test), None => () @@ -141,7 +140,7 @@ fn run_tests_console(opts: &TestOpts, st.failed += 1u; write_failed(st.out, st.use_color); st.out.write_line(~""); - st.failures.push(copy test); + st.failures.push(test); } TrIgnored => { st.ignored += 1u; @@ -154,11 +153,11 @@ fn run_tests_console(opts: &TestOpts, } let log_out = match opts.logfile { - Some(path) => match io::file_writer(&Path(path), + Some(ref path) => match io::file_writer(&Path(*path), ~[io::Create, io::Truncate]) { result::Ok(w) => Some(w), - result::Err(s) => { - fail(fmt!("can't open output file: %s", s)) + result::Err(ref s) => { + fail(fmt!("can't open output file: %s", *s)) } }, None => None @@ -347,7 +346,7 @@ fn filter_tests(opts: &TestOpts, } else { let filter_str = match opts.filter { - option::Some(f) => f, + option::Some(copy f) => f, option::None => ~"" }; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 890a7a0b468..2975d27e064 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::Eq; use libc::{c_char, c_int, c_long, size_t, time_t}; @@ -576,7 +575,7 @@ fn strptime(s: &str, format: &str) -> Result { match rdr.read_char() { '%' => match parse_type(s, pos, rdr.read_char(), &tm) { Ok(next) => pos = next, - Err(e) => { result = Err(e); break; } + Err(copy e) => { result = Err(e); break; } }, c => { if c != ch { break } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 1476d6bdf31..ae79892b873 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -1,7 +1,6 @@ //! Utilities that leverage libuv's `uv_timer_*` API #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use uv = uv; use uv::iotask; diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 3419f1cb90c..184dfd36279 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -6,7 +6,6 @@ * red-black tree or something else. */ #[warn(deprecated_mode)]; -#[forbid(deprecated_pattern)]; use core::cmp::{Eq, Ord}; use core::option::{Some, None}; diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index e76b8529730..d353be2b44b 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -1,5 +1,4 @@ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; mod icu { #[legacy_exports]; diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index cde88db031e..508426588d0 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -1,7 +1,6 @@ //! A process-wide libuv event loop for library use. #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; export get; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 2e008830558..c31238ecf4f 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -6,7 +6,6 @@ */ #[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; export IoTask; export spawn_iotask; @@ -149,7 +148,7 @@ extern fn wake_up_cb(async_handle: *ll::uv_async_t, while msg_po.peek() { match msg_po.recv() { - Interaction(cb) => cb(loop_ptr), + Interaction(ref cb) => (*cb)(loop_ptr), TeardownLoop => begin_teardown(data) } } -- cgit 1.4.1-3-g733a5 From 70ae3e7bf212b0db5949e113858bae1da0e6ae29 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 28 Sep 2012 14:55:31 -0700 Subject: De-export std::{bitv, cell, timer}. Part of #3583. --- src/libstd/bitv.rs | 12 +++++------- src/libstd/cell.rs | 6 +++--- src/libstd/std.rc | 3 --- src/libstd/timer.rs | 10 ++++------ 4 files changed, 12 insertions(+), 19 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 33065fffd03..370c5ddb566 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -2,8 +2,6 @@ use vec::{to_mut, from_elem}; -export Bitv, from_bytes, from_bools, from_fn; - struct SmallBitv { /// only the lowest nbits of this value are used. the rest is undefined. mut bits: u32 @@ -209,12 +207,12 @@ enum BitvVariant { Big(~BigBitv), Small(~SmallBitv) } enum Op {Union, Intersect, Assign, Difference} // The bitvector type -struct Bitv { +pub struct Bitv { rep: BitvVariant, nbits: uint } -fn Bitv (nbits: uint, init: bool) -> Bitv { +pub fn Bitv (nbits: uint, init: bool) -> Bitv { let rep = if nbits <= 32 { Small(~SmallBitv(if init {!0} else {0})) } @@ -519,7 +517,7 @@ impl Bitv { * with the most significant bits of each byte coming first. Each * bit becomes true if equal to 1 or false if equal to 0. */ -fn from_bytes(bytes: &[u8]) -> Bitv { +pub fn from_bytes(bytes: &[u8]) -> Bitv { from_fn(bytes.len() * 8, |i| { let b = bytes[i / 8] as uint; let offset = i % 8; @@ -530,7 +528,7 @@ fn from_bytes(bytes: &[u8]) -> Bitv { /** * Transform a [bool] into a bitv by converting each bool into a bit. */ -fn from_bools(bools: &[bool]) -> Bitv { +pub fn from_bools(bools: &[bool]) -> Bitv { from_fn(bools.len(), |i| bools[i]) } @@ -538,7 +536,7 @@ fn from_bools(bools: &[bool]) -> Bitv { * Create a bitv of the specified length where the value at each * index is f(index). */ -fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv { +pub fn from_fn(len: uint, f: fn(index: uint) -> bool) -> Bitv { let bitv = Bitv(len, false); for uint::range(0, len) |i| { bitv.set(i, f(i)); diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 4ef695f4198..43e47e1e1a9 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -3,16 +3,16 @@ /// /// Similar to a mutable option type, but friendlier. -struct Cell { +pub struct Cell { mut value: Option } /// Creates a new full cell with the given value. -fn Cell(+value: T) -> Cell { +pub fn Cell(+value: T) -> Cell { Cell { value: Some(move value) } } -fn empty_cell() -> Cell { +pub fn empty_cell() -> Cell { Cell { value: None } } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 5370f20cfa1..13f7b967723 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -69,9 +69,7 @@ mod uv_global_loop; #[legacy_exports] mod c_vec; -#[legacy_exports] mod timer; -#[legacy_exports] mod cell; // Concurrency @@ -85,7 +83,6 @@ mod comm; // Collections -#[legacy_exports] mod bitv; #[legacy_exports] mod deque; diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index ae79892b873..a2f9796f89e 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -7,8 +7,6 @@ use uv::iotask; use iotask::IoTask; use comm = core::comm; -export delayed_send, sleep, recv_timeout; - /** * Wait for timeout period then send provided value over a channel * @@ -25,8 +23,8 @@ export delayed_send, sleep, recv_timeout; * * ch - a channel of type T to send a `val` on * * val - a value of type T to send over the provided `ch` */ -fn delayed_send(iotask: IoTask, - msecs: uint, ch: comm::Chan, +val: T) { +pub fn delayed_send(iotask: IoTask, + msecs: uint, ch: comm::Chan, +val: T) { unsafe { let timer_done_po = core::comm::Port::<()>(); let timer_done_ch = core::comm::Chan(timer_done_po); @@ -74,7 +72,7 @@ fn delayed_send(iotask: IoTask, * * `iotask` - a `uv::iotask` that the tcp request will run on * * msecs - an amount of time, in milliseconds, for the current task to block */ -fn sleep(iotask: IoTask, msecs: uint) { +pub fn sleep(iotask: IoTask, msecs: uint) { let exit_po = core::comm::Port::<()>(); let exit_ch = core::comm::Chan(exit_po); delayed_send(iotask, msecs, exit_ch, ()); @@ -101,7 +99,7 @@ fn sleep(iotask: IoTask, msecs: uint) { * on the provided port in the allotted timeout period, then the result will * be a `some(T)`. If not, then `none` will be returned. */ -fn recv_timeout(iotask: IoTask, +pub fn recv_timeout(iotask: IoTask, msecs: uint, wait_po: comm::Port) -> Option { let timeout_po = comm::Port::<()>(); -- cgit 1.4.1-3-g733a5 From 43a9d90b482c519462bad8c60ccd237506505c78 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 28 Sep 2012 16:05:33 -0700 Subject: De-export std::{arc,comm,sync}. Part of #3583. --- src/libstd/arc.rs | 29 ++++++++++++----------------- src/libstd/comm.rs | 4 +--- src/libstd/std.rc | 3 --- src/libstd/sync.rs | 17 +++++++---------- 4 files changed, 20 insertions(+), 33 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 3a9fd36a05e..9d15deab660 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -11,14 +11,9 @@ use private::{SharedMutableState, shared_mutable_state, use sync::{Mutex, mutex_with_condvars, RWlock, rwlock_with_condvars}; -export ARC, clone, get; -export Condvar; -export MutexARC, mutex_arc_with_condvars, unwrap_mutex_arc; -export RWARC, rw_arc_with_condvars, RWWriteMode, RWReadMode; -export unwrap_rw_arc; /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. -struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar } +pub struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar } impl &Condvar { /// Atomically exit the associated ARC and block until a signal is sent. @@ -71,7 +66,7 @@ impl &Condvar { struct ARC { x: SharedMutableState } /// Create an atomically reference counted wrapper. -fn ARC(+data: T) -> ARC { +pub fn ARC(+data: T) -> ARC { ARC { x: unsafe { shared_mutable_state(move data) } } } @@ -79,7 +74,7 @@ fn ARC(+data: T) -> ARC { * Access the underlying data in an atomically reference counted * wrapper. */ -fn get(rc: &a/ARC) -> &a/T { +pub fn get(rc: &a/ARC) -> &a/T { unsafe { get_shared_immutable_state(&rc.x) } } @@ -90,7 +85,7 @@ fn get(rc: &a/ARC) -> &a/T { * object. However, one of the `arc` objects can be sent to another task, * allowing them to share the underlying data. */ -fn clone(rc: &ARC) -> ARC { +pub fn clone(rc: &ARC) -> ARC { ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } } } @@ -118,14 +113,14 @@ struct MutexARCInner { lock: Mutex, failed: bool, data: T } struct MutexARC { x: SharedMutableState> } /// Create a mutex-protected ARC with the supplied data. -fn MutexARC(+user_data: T) -> MutexARC { +pub fn MutexARC(+user_data: T) -> MutexARC { mutex_arc_with_condvars(move user_data, 1) } /** * Create a mutex-protected ARC with the supplied data and a specified number * of condvars (as sync::mutex_with_condvars). */ -fn mutex_arc_with_condvars(+user_data: T, +pub fn mutex_arc_with_condvars(+user_data: T, num_condvars: uint) -> MutexARC { let data = MutexARCInner { lock: mutex_with_condvars(num_condvars), @@ -196,7 +191,7 @@ impl &MutexARC { * Will additionally fail if another task has failed while accessing the arc. */ // FIXME(#2585) make this a by-move method on the arc -fn unwrap_mutex_arc(+arc: MutexARC) -> T { +pub fn unwrap_mutex_arc(+arc: MutexARC) -> T { let MutexARC { x: x } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let MutexARCInner { failed: failed, data: data, _ } <- inner; @@ -252,14 +247,14 @@ struct RWARC { } /// Create a reader/writer ARC with the supplied data. -fn RWARC(+user_data: T) -> RWARC { +pub fn RWARC(+user_data: T) -> RWARC { rw_arc_with_condvars(move user_data, 1) } /** * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -fn rw_arc_with_condvars(+user_data: T, +pub fn rw_arc_with_condvars(+user_data: T, num_condvars: uint) -> RWARC { let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), @@ -374,7 +369,7 @@ impl &RWARC { * in write mode. */ // FIXME(#2585) make this a by-move method on the arc -fn unwrap_rw_arc(+arc: RWARC) -> T { +pub fn unwrap_rw_arc(+arc: RWARC) -> T { let RWARC { x: x, _ } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let RWARCInner { failed: failed, data: data, _ } <- inner; @@ -395,10 +390,10 @@ fn borrow_rwlock(state: &r/mut RWARCInner) -> &r/RWlock { // FIXME (#3154) ice with struct/& prevents these from being structs. /// The "write permission" token used for RWARC.write_downgrade(). -enum RWWriteMode = +pub enum RWWriteMode = (&mut T, sync::RWlockWriteMode, PoisonOnFail); /// The "read permission" token used for RWARC.write_downgrade(). -enum RWReadMode = (&T, sync::RWlockReadMode); +pub enum RWReadMode = (&T, sync::RWlockReadMode); impl &RWWriteMode { /// Access the pre-downgrade RWARC in write mode. diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 58958d6115e..4bed7d13d0b 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -9,10 +9,8 @@ Higher level communication abstractions. use pipes::{Channel, Recv, Chan, Port, Selectable}; -export DuplexStream; - /// An extension of `pipes::stream` that allows both sending and receiving. -struct DuplexStream { +pub struct DuplexStream { priv chan: Chan, priv port: Port , } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 13f7b967723..798ae4be6dd 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -74,11 +74,8 @@ mod cell; // Concurrency -#[legacy_exports] mod sync; -#[legacy_exports] mod arc; -#[legacy_exports] mod comm; // Collections diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index c94a1ab46bf..2b2cd2b0ba7 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -7,9 +7,6 @@ * in std. */ -export Condvar, Semaphore, Mutex, mutex_with_condvars; -export RWlock, rwlock_with_condvars, RWlockReadMode, RWlockWriteMode; - use private::{Exclusive, exclusive}; /**************************************************************************** @@ -176,7 +173,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>) } /// A mechanism for atomic-unlock-and-deschedule blocking and signalling. -struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } } +pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } } impl &Condvar { /** @@ -379,14 +376,14 @@ impl &Semaphore { struct Mutex { priv sem: Sem<~[mut Waitqueue]> } /// Create a new mutex, with one associated condvar. -fn Mutex() -> Mutex { mutex_with_condvars(1) } +pub fn Mutex() -> Mutex { mutex_with_condvars(1) } /** * Create a new mutex, with a specified number of associated condvars. This * will allow calling wait_on/signal_on/broadcast_on with condvar IDs between * 0 and num_condvars-1. (If num_condvars is 0, lock_cond will be allowed but * any operations on the condvar will fail.) */ -fn mutex_with_condvars(num_condvars: uint) -> Mutex { +pub fn mutex_with_condvars(num_condvars: uint) -> Mutex { Mutex { sem: new_sem_and_signal(1, num_condvars) } } @@ -429,13 +426,13 @@ struct RWlock { } /// Create a new rwlock, with one associated condvar. -fn RWlock() -> RWlock { rwlock_with_condvars(1) } +pub fn RWlock() -> RWlock { rwlock_with_condvars(1) } /** * Create a new rwlock, with a specified number of associated condvars. * Similar to mutex_with_condvars. */ -fn rwlock_with_condvars(num_condvars: uint) -> RWlock { +pub fn rwlock_with_condvars(num_condvars: uint) -> RWlock { RWlock { order_lock: semaphore(1), access_lock: new_sem_and_signal(1, num_condvars), state: exclusive(RWlockInner { read_mode: false, @@ -646,9 +643,9 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r { } /// The "write permission" token used for rwlock.write_downgrade(). -struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } } +pub struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } } /// The "read permission" token used for rwlock.write_downgrade(). -struct RWlockReadMode { priv lock: &RWlock, drop { } } +pub struct RWlockReadMode { priv lock: &RWlock, drop { } } impl &RWlockWriteMode { /// Access the pre-downgrade rwlock in write mode. -- cgit 1.4.1-3-g733a5 From 1948ddf583fd958a54599d7e06dc3098e563c03f Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 28 Sep 2012 16:25:57 -0700 Subject: De-mode std::unicode. Part of #3583. --- src/libstd/std.rc | 1 - src/libstd/unicode.rs | 289 +++++++++++++++++++++++++------------------------- 2 files changed, 143 insertions(+), 147 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 798ae4be6dd..faca45fa6f7 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -124,7 +124,6 @@ mod cmp; mod base64; #[cfg(unicode)] -#[legacy_exports] mod unicode; diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index d353be2b44b..bafe385ed19 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -1,157 +1,155 @@ #[forbid(deprecated_mode)]; -mod icu { - #[legacy_exports]; - type UBool = u8; - type UProperty = int; - type UChar32 = char; - - const TRUE : u8 = 1u8; - const FALSE : u8 = 1u8; - - const UCHAR_ALPHABETIC : UProperty = 0; - const UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC - const UCHAR_ASCII_HEX_DIGIT : UProperty = 1; - const UCHAR_BIDI_CONTROL : UProperty = 2; - - const UCHAR_BIDI_MIRRORED : UProperty = 3; - const UCHAR_DASH : UProperty = 4; - const UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5; - const UCHAR_DEPRECATED : UProperty = 6; - - const UCHAR_DIACRITIC : UProperty = 7; - const UCHAR_EXTENDER : UProperty = 8; - const UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9; - const UCHAR_GRAPHEME_BASE : UProperty = 10; - - const UCHAR_GRAPHEME_EXTEND : UProperty = 11; - const UCHAR_GRAPHEME_LINK : UProperty = 12; - const UCHAR_HEX_DIGIT : UProperty = 13; - const UCHAR_HYPHEN : UProperty = 14; - - const UCHAR_ID_CONTINUE : UProperty = 15; - const UCHAR_ID_START : UProperty = 16; - const UCHAR_IDEOGRAPHIC : UProperty = 17; - const UCHAR_IDS_BINARY_OPERATOR : UProperty = 18; - - const UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19; - const UCHAR_JOIN_CONTROL : UProperty = 20; - const UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21; - const UCHAR_LOWERCASE : UProperty = 22; - - const UCHAR_MATH : UProperty = 23; - const UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24; - const UCHAR_QUOTATION_MARK : UProperty = 25; - const UCHAR_RADICAL : UProperty = 26; - - const UCHAR_SOFT_DOTTED : UProperty = 27; - const UCHAR_TERMINAL_PUNCTUATION : UProperty = 28; - const UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29; - const UCHAR_UPPERCASE : UProperty = 30; - - const UCHAR_WHITE_SPACE : UProperty = 31; - const UCHAR_XID_CONTINUE : UProperty = 32; - const UCHAR_XID_START : UProperty = 33; - const UCHAR_CASE_SENSITIVE : UProperty = 34; - - const UCHAR_S_TERM : UProperty = 35; - const UCHAR_VARIATION_SELECTOR : UProperty = 36; - const UCHAR_NFD_INERT : UProperty = 37; - const UCHAR_NFKD_INERT : UProperty = 38; - - const UCHAR_NFC_INERT : UProperty = 39; - const UCHAR_NFKC_INERT : UProperty = 40; - const UCHAR_SEGMENT_STARTER : UProperty = 41; - const UCHAR_PATTERN_SYNTAX : UProperty = 42; - - const UCHAR_PATTERN_WHITE_SPACE : UProperty = 43; - const UCHAR_POSIX_ALNUM : UProperty = 44; - const UCHAR_POSIX_BLANK : UProperty = 45; - const UCHAR_POSIX_GRAPH : UProperty = 46; - - const UCHAR_POSIX_PRINT : UProperty = 47; - const UCHAR_POSIX_XDIGIT : UProperty = 48; - const UCHAR_CASED : UProperty = 49; - const UCHAR_CASE_IGNORABLE : UProperty = 50; - - const UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51; - const UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52; - const UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53; - const UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54; - - const UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55; - const UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56; - const UCHAR_BINARY_LIMIT : UProperty = 57; - const UCHAR_BIDI_CLASS : UProperty = 0x1000; - - const UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS - const UCHAR_BLOCK : UProperty = 0x1001; - const UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002; - const UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003; - - const UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004; - const UCHAR_GENERAL_CATEGORY : UProperty = 0x1005; - const UCHAR_JOINING_GROUP : UProperty = 0x1006; - const UCHAR_JOINING_TYPE : UProperty = 0x1007; - - const UCHAR_LINE_BREAK : UProperty = 0x1008; - const UCHAR_NUMERIC_TYPE : UProperty = 0x1009; - const UCHAR_SCRIPT : UProperty = 0x100A; - const UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B; - - const UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C; - const UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D; - const UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E; - const UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F; - - const UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010; - const UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011; - const UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012; - const UCHAR_SENTENCE_BREAK : UProperty = 0x1013; - - const UCHAR_WORD_BREAK : UProperty = 0x1014; - const UCHAR_INT_LIMIT : UProperty = 0x1015; - - const UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000; - const UCHAR_MASK_START : UProperty = 0x2000; +pub mod icu { + pub type UBool = u8; + pub type UProperty = int; + pub type UChar32 = char; + + pub const TRUE : u8 = 1u8; + pub const FALSE : u8 = 1u8; + + pub const UCHAR_ALPHABETIC : UProperty = 0; + pub const UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC + pub const UCHAR_ASCII_HEX_DIGIT : UProperty = 1; + pub const UCHAR_BIDI_CONTROL : UProperty = 2; + + pub const UCHAR_BIDI_MIRRORED : UProperty = 3; + pub const UCHAR_DASH : UProperty = 4; + pub const UCHAR_DEFAULT_IGNORABLE_CODE_POINT : UProperty = 5; + pub const UCHAR_DEPRECATED : UProperty = 6; + + pub const UCHAR_DIACRITIC : UProperty = 7; + pub const UCHAR_EXTENDER : UProperty = 8; + pub const UCHAR_FULL_COMPOSITION_EXCLUSION : UProperty = 9; + pub const UCHAR_GRAPHEME_BASE : UProperty = 10; + + pub const UCHAR_GRAPHEME_EXTEND : UProperty = 11; + pub const UCHAR_GRAPHEME_LINK : UProperty = 12; + pub const UCHAR_HEX_DIGIT : UProperty = 13; + pub const UCHAR_HYPHEN : UProperty = 14; + + pub const UCHAR_ID_CONTINUE : UProperty = 15; + pub const UCHAR_ID_START : UProperty = 16; + pub const UCHAR_IDEOGRAPHIC : UProperty = 17; + pub const UCHAR_IDS_BINARY_OPERATOR : UProperty = 18; + + pub const UCHAR_IDS_TRINARY_OPERATOR : UProperty = 19; + pub const UCHAR_JOIN_CONTROL : UProperty = 20; + pub const UCHAR_LOGICAL_ORDER_EXCEPTION : UProperty = 21; + pub const UCHAR_LOWERCASE : UProperty = 22; + + pub const UCHAR_MATH : UProperty = 23; + pub const UCHAR_NONCHARACTER_CODE_POINT : UProperty = 24; + pub const UCHAR_QUOTATION_MARK : UProperty = 25; + pub const UCHAR_RADICAL : UProperty = 26; + + pub const UCHAR_SOFT_DOTTED : UProperty = 27; + pub const UCHAR_TERMINAL_PUNCTUATION : UProperty = 28; + pub const UCHAR_UNIFIED_IDEOGRAPH : UProperty = 29; + pub const UCHAR_UPPERCASE : UProperty = 30; + + pub const UCHAR_WHITE_SPACE : UProperty = 31; + pub const UCHAR_XID_CONTINUE : UProperty = 32; + pub const UCHAR_XID_START : UProperty = 33; + pub const UCHAR_CASE_SENSITIVE : UProperty = 34; + + pub const UCHAR_S_TERM : UProperty = 35; + pub const UCHAR_VARIATION_SELECTOR : UProperty = 36; + pub const UCHAR_NFD_INERT : UProperty = 37; + pub const UCHAR_NFKD_INERT : UProperty = 38; + + pub const UCHAR_NFC_INERT : UProperty = 39; + pub const UCHAR_NFKC_INERT : UProperty = 40; + pub const UCHAR_SEGMENT_STARTER : UProperty = 41; + pub const UCHAR_PATTERN_SYNTAX : UProperty = 42; + + pub const UCHAR_PATTERN_WHITE_SPACE : UProperty = 43; + pub const UCHAR_POSIX_ALNUM : UProperty = 44; + pub const UCHAR_POSIX_BLANK : UProperty = 45; + pub const UCHAR_POSIX_GRAPH : UProperty = 46; + + pub const UCHAR_POSIX_PRINT : UProperty = 47; + pub const UCHAR_POSIX_XDIGIT : UProperty = 48; + pub const UCHAR_CASED : UProperty = 49; + pub const UCHAR_CASE_IGNORABLE : UProperty = 50; + + pub const UCHAR_CHANGES_WHEN_LOWERCASED : UProperty = 51; + pub const UCHAR_CHANGES_WHEN_UPPERCASED : UProperty = 52; + pub const UCHAR_CHANGES_WHEN_TITLECASED : UProperty = 53; + pub const UCHAR_CHANGES_WHEN_CASEFOLDED : UProperty = 54; + + pub const UCHAR_CHANGES_WHEN_CASEMAPPED : UProperty = 55; + pub const UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED : UProperty = 56; + pub const UCHAR_BINARY_LIMIT : UProperty = 57; + pub const UCHAR_BIDI_CLASS : UProperty = 0x1000; + + pub const UCHAR_INT_START : UProperty = 0x1000; // UCHAR_BIDI_CLASS + pub const UCHAR_BLOCK : UProperty = 0x1001; + pub const UCHAR_CANONICAL_COMBINING_CLASS : UProperty = 0x1002; + pub const UCHAR_DECOMPOSITION_TYPE : UProperty = 0x1003; + + pub const UCHAR_EAST_ASIAN_WIDTH : UProperty = 0x1004; + pub const UCHAR_GENERAL_CATEGORY : UProperty = 0x1005; + pub const UCHAR_JOINING_GROUP : UProperty = 0x1006; + pub const UCHAR_JOINING_TYPE : UProperty = 0x1007; + + pub const UCHAR_LINE_BREAK : UProperty = 0x1008; + pub const UCHAR_NUMERIC_TYPE : UProperty = 0x1009; + pub const UCHAR_SCRIPT : UProperty = 0x100A; + pub const UCHAR_HANGUL_SYLLABLE_TYPE : UProperty = 0x100B; + + pub const UCHAR_NFD_QUICK_CHECK : UProperty = 0x100C; + pub const UCHAR_NFKD_QUICK_CHECK : UProperty = 0x100D; + pub const UCHAR_NFC_QUICK_CHECK : UProperty = 0x100E; + pub const UCHAR_NFKC_QUICK_CHECK : UProperty = 0x100F; + + pub const UCHAR_LEAD_CANONICAL_COMBINING_CLASS : UProperty = 0x1010; + pub const UCHAR_TRAIL_CANONICAL_COMBINING_CLASS : UProperty = 0x1011; + pub const UCHAR_GRAPHEME_CLUSTER_BREAK : UProperty = 0x1012; + pub const UCHAR_SENTENCE_BREAK : UProperty = 0x1013; + + pub const UCHAR_WORD_BREAK : UProperty = 0x1014; + pub const UCHAR_INT_LIMIT : UProperty = 0x1015; + + pub const UCHAR_GENERAL_CATEGORY_MASK : UProperty = 0x2000; + pub const UCHAR_MASK_START : UProperty = 0x2000; // = UCHAR_GENERAL_CATEGORY_MASK - const UCHAR_MASK_LIMIT : UProperty = 0x2001; + pub const UCHAR_MASK_LIMIT : UProperty = 0x2001; - const UCHAR_NUMERIC_VALUE : UProperty = 0x3000; - const UCHAR_DOUBLE_START : UProperty = 0x3000; + pub const UCHAR_NUMERIC_VALUE : UProperty = 0x3000; + pub const UCHAR_DOUBLE_START : UProperty = 0x3000; // = UCHAR_NUMERIC_VALUE - const UCHAR_DOUBLE_LIMIT : UProperty = 0x3001; + pub const UCHAR_DOUBLE_LIMIT : UProperty = 0x3001; - const UCHAR_AGE : UProperty = 0x4000; - const UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE - const UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001; - const UCHAR_CASE_FOLDING : UProperty = 0x4002; + pub const UCHAR_AGE : UProperty = 0x4000; + pub const UCHAR_STRING_START : UProperty = 0x4000; // = UCHAR_AGE + pub const UCHAR_BIDI_MIRRORING_GLYPH : UProperty = 0x4001; + pub const UCHAR_CASE_FOLDING : UProperty = 0x4002; - const UCHAR_ISO_COMMENT : UProperty = 0x4003; - const UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004; - const UCHAR_NAME : UProperty = 0x4005; - const UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006; + pub const UCHAR_ISO_COMMENT : UProperty = 0x4003; + pub const UCHAR_LOWERCASE_MAPPING : UProperty = 0x4004; + pub const UCHAR_NAME : UProperty = 0x4005; + pub const UCHAR_SIMPLE_CASE_FOLDING : UProperty = 0x4006; - const UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007; - const UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008; - const UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009; - const UCHAR_TITLECASE_MAPPING : UProperty = 0x400A; + pub const UCHAR_SIMPLE_LOWERCASE_MAPPING : UProperty = 0x4007; + pub const UCHAR_SIMPLE_TITLECASE_MAPPING : UProperty = 0x4008; + pub const UCHAR_SIMPLE_UPPERCASE_MAPPING : UProperty = 0x4009; + pub const UCHAR_TITLECASE_MAPPING : UProperty = 0x400A; - const UCHAR_UNICODE_1_NAME : UProperty = 0x400B; - const UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C; - const UCHAR_STRING_LIMIT : UProperty = 0x400D; + pub const UCHAR_UNICODE_1_NAME : UProperty = 0x400B; + pub const UCHAR_UPPERCASE_MAPPING : UProperty = 0x400C; + pub const UCHAR_STRING_LIMIT : UProperty = 0x400D; - const UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000; - const UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000; + pub const UCHAR_SCRIPT_EXTENSIONS : UProperty = 0x7000; + pub const UCHAR_OTHER_PROPERTY_START : UProperty = 0x7000; // = UCHAR_SCRIPT_EXTENSIONS; - const UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001; + pub const UCHAR_OTHER_PROPERTY_LIMIT : UProperty = 0x7001; - const UCHAR_INVALID_CODE : UProperty = -1; + pub const UCHAR_INVALID_CODE : UProperty = -1; #[link_name = "icuuc"] #[abi = "cdecl"] - extern mod libicu { - #[legacy_exports]; + pub extern mod libicu { pure fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool; pure fn u_isdigit(c: UChar32) -> UBool; pure fn u_islower(c: UChar32) -> UBool; @@ -162,12 +160,12 @@ mod icu { } } -pure fn is_XID_start(c: char) -> bool { +pub pure fn is_XID_start(c: char) -> bool { return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } -pure fn is_XID_continue(c: char) -> bool { +pub pure fn is_XID_continue(c: char) -> bool { return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } @@ -177,7 +175,7 @@ Function: is_digit Returns true if a character is a digit. */ -pure fn is_digit(c: char) -> bool { +pub pure fn is_digit(c: char) -> bool { return icu::libicu::u_isdigit(c) == icu::TRUE; } @@ -186,7 +184,7 @@ Function: is_lower Returns true if a character is a lowercase letter. */ -pure fn is_lower(c: char) -> bool { +pub pure fn is_lower(c: char) -> bool { return icu::libicu::u_islower(c) == icu::TRUE; } @@ -195,7 +193,7 @@ Function: is_space Returns true if a character is space. */ -pure fn is_space(c: char) -> bool { +pub pure fn is_space(c: char) -> bool { return icu::libicu::u_isspace(c) == icu::TRUE; } @@ -204,13 +202,12 @@ Function: is_upper Returns true if a character is an uppercase letter. */ -pure fn is_upper(c: char) -> bool { +pub pure fn is_upper(c: char) -> bool { return icu::libicu::u_isupper(c) == icu::TRUE; } #[cfg(test)] mod tests { - #[legacy_exports]; #[test] fn test_is_digit() { -- cgit 1.4.1-3-g733a5 From e17d998e9530ee5a9da37f98dab2e33ad6a1d0f9 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 28 Sep 2012 16:24:57 -0700 Subject: De-export std::{time, prettyprint{,2}, arena}. Part of #3583. --- src/libstd/arena.rs | 10 +++------- src/libstd/prettyprint2.rs | 4 ++-- src/libstd/std.rc | 4 ---- src/libstd/time.rs | 38 ++++++++++++-------------------------- 4 files changed, 17 insertions(+), 39 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index de3c5774bfe..4d2b910fa85 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -24,8 +24,6 @@ #[forbid(deprecated_mode)]; -export Arena, arena_with_size; - use list::{List, Cons, Nil}; use cast::reinterpret_cast; use sys::TypeDesc; @@ -33,12 +31,10 @@ use libc::size_t; #[abi = "rust-intrinsic"] extern mod rusti { - #[legacy_exports]; fn move_val_init(&dst: T, -src: T); fn needs_drop() -> bool; } extern mod rustrt { - #[legacy_exports]; #[rust_stack] fn rust_call_tydesc_glue(root: *u8, tydesc: *TypeDesc, field: size_t); } @@ -51,7 +47,7 @@ const tydesc_drop_glue_index: size_t = 3 as size_t; // will always stay at 0. type Chunk = {data: @[u8], mut fill: uint, is_pod: bool}; -struct Arena { +pub struct Arena { // The head is seperated out from the list as a unbenchmarked // microoptimization, to avoid needing to case on the list to // access the head. @@ -74,13 +70,13 @@ fn chunk(size: uint, is_pod: bool) -> Chunk { { data: unsafe { cast::transmute(v) }, mut fill: 0u, is_pod: is_pod } } -fn arena_with_size(initial_size: uint) -> Arena { +pub fn arena_with_size(initial_size: uint) -> Arena { return Arena {mut head: chunk(initial_size, false), mut pod_head: chunk(initial_size, true), mut chunks: @Nil}; } -fn Arena() -> Arena { +pub fn Arena() -> Arena { arena_with_size(32u) } diff --git a/src/libstd/prettyprint2.rs b/src/libstd/prettyprint2.rs index 325d240eb57..68421a217ee 100644 --- a/src/libstd/prettyprint2.rs +++ b/src/libstd/prettyprint2.rs @@ -4,11 +4,11 @@ use io::Writer; use io::WriterUtil; use serialization2; -struct Serializer { +pub struct Serializer { wr: io::Writer, } -fn Serializer(wr: io::Writer) -> Serializer { +pub fn Serializer(wr: io::Writer) -> Serializer { Serializer { wr: wr } } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index faca45fa6f7..cf2e1d6567f 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -111,13 +111,9 @@ mod sha1; mod md4; mod tempfile; mod term; -#[legacy_exports] mod time; -#[legacy_exports] mod prettyprint; -#[legacy_exports] mod prettyprint2; -#[legacy_exports] mod arena; mod par; mod cmp; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 9f6f9b07737..43cbc6da9bd 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -5,20 +5,6 @@ use libc::{c_char, c_int, c_long, size_t, time_t}; use io::{Reader, ReaderUtil}; use result::{Result, Ok, Err}; -export - Timespec, - get_time, - precise_time_ns, - precise_time_s, - tzset, - Tm, - empty_tm, - now, - at, - now_utc, - at_utc, - strptime; - #[abi = "cdecl"] extern mod rustrt { #[legacy_exports]; @@ -34,7 +20,7 @@ extern mod rustrt { } /// A record specifying a time value in seconds and nanoseconds. -type Timespec = {sec: i64, nsec: i32}; +pub type Timespec = {sec: i64, nsec: i32}; impl Timespec : Eq { pure fn eq(other: &Timespec) -> bool { @@ -47,7 +33,7 @@ impl Timespec : Eq { * Returns the current time as a `timespec` containing the seconds and * nanoseconds since 1970-01-01T00:00:00Z. */ -fn get_time() -> Timespec { +pub fn get_time() -> Timespec { let mut sec = 0i64; let mut nsec = 0i32; rustrt::get_time(sec, nsec); @@ -58,7 +44,7 @@ fn get_time() -> Timespec { * Returns the current value of a high-resolution performance counter * in nanoseconds since an unspecified epoch. */ -fn precise_time_ns() -> u64 { +pub fn precise_time_ns() -> u64 { let mut ns = 0u64; rustrt::precise_time_ns(ns); ns @@ -68,11 +54,11 @@ fn precise_time_ns() -> u64 { * Returns the current value of a high-resolution performance counter * in seconds since an unspecified epoch. */ -fn precise_time_s() -> float { +pub fn precise_time_s() -> float { return (precise_time_ns() as float) / 1000000000.; } -fn tzset() { +pub fn tzset() { rustrt::rust_tzset(); } @@ -109,7 +95,7 @@ impl Tm_ : Eq { pure fn ne(other: &Tm_) -> bool { !self.eq(other) } } -enum Tm { +pub enum Tm { Tm_(Tm_) } @@ -118,7 +104,7 @@ impl Tm : Eq { pure fn ne(other: &Tm) -> bool { *self != *(*other) } } -fn empty_tm() -> Tm { +pub fn empty_tm() -> Tm { Tm_({ tm_sec: 0_i32, tm_min: 0_i32, @@ -136,7 +122,7 @@ fn empty_tm() -> Tm { } /// Returns the specified time in UTC -fn at_utc(clock: Timespec) -> Tm { +pub fn at_utc(clock: Timespec) -> Tm { let mut {sec, nsec} = clock; let mut tm = empty_tm(); rustrt::rust_gmtime(sec, nsec, tm); @@ -144,12 +130,12 @@ fn at_utc(clock: Timespec) -> Tm { } /// Returns the current time in UTC -fn now_utc() -> Tm { +pub fn now_utc() -> Tm { at_utc(get_time()) } /// Returns the specified time in the local timezone -fn at(clock: Timespec) -> Tm { +pub fn at(clock: Timespec) -> Tm { let mut {sec, nsec} = clock; let mut tm = empty_tm(); rustrt::rust_localtime(sec, nsec, tm); @@ -157,12 +143,12 @@ fn at(clock: Timespec) -> Tm { } /// Returns the current time in the local timezone -fn now() -> Tm { +pub fn now() -> Tm { at(get_time()) } /// Parses the time from the string according to the format string. -fn strptime(s: &str, format: &str) -> Result { +pub fn strptime(s: &str, format: &str) -> Result { type TmMut = { mut tm_sec: i32, mut tm_min: i32, -- cgit 1.4.1-3-g733a5 From eba5eeaef843d9f2a8b84926ba12dfa84d6d3541 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 28 Sep 2012 17:08:22 -0700 Subject: De-export std::deque. Part of #3583. --- src/libstd/deque.rs | 5 ++--- src/libstd/std.rc | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 22fdca3b0ab..da05174a6f5 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -6,7 +6,7 @@ use option::{Some, None}; use dvec::DVec; use core::cmp::{Eq}; -trait Deque { +pub trait Deque { fn size() -> uint; fn add_front(+v: T); fn add_back(+v: T); @@ -19,7 +19,7 @@ trait Deque { // FIXME (#2343) eventually, a proper datatype plus an exported impl would // be preferrable. -fn create() -> Deque { +pub fn create() -> Deque { type Cell = Option; let initial_capacity: uint = 32u; // 2^5 @@ -119,7 +119,6 @@ fn create() -> Deque { #[cfg(test)] mod tests { - #[legacy_exports]; #[test] fn test_simple() { let d: deque::Deque = deque::create::(); diff --git a/src/libstd/std.rc b/src/libstd/std.rc index cf2e1d6567f..27b9dfac2bb 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -81,7 +81,6 @@ mod comm; // Collections mod bitv; -#[legacy_exports] mod deque; #[legacy_exports] mod fun_treemap; -- cgit 1.4.1-3-g733a5 From 9e6d3cf3c9634afeadb11ce1917e159b64c6395f Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 28 Sep 2012 17:43:57 -0700 Subject: De-export std::c_vec. Part of Part of #3583. --- src/libstd/c_vec.rs | 21 +++++++-------------- src/libstd/std.rc | 1 - 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index f4df063a93d..1ff5b63ee12 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -26,19 +26,13 @@ * still held if needed. */ -export CVec; -export CVec, c_vec_with_dtor; -export get, set; -export len; -export ptr; - /** * The type representing a foreign chunk of memory * * Wrapped in a enum for opacity; FIXME #818 when it is possible to have * truly opaque types, this should be revisited. */ -enum CVec { +pub enum CVec { CVecCtor({ base: *mut T, len: uint, rsrc: @DtorRes}) } @@ -70,7 +64,7 @@ fn DtorRes(dtor: Option) -> DtorRes { * * base - A foreign pointer to a buffer * * len - The number of elements in the buffer */ -unsafe fn CVec(base: *mut T, len: uint) -> CVec { +pub unsafe fn CVec(base: *mut T, len: uint) -> CVec { return CVecCtor({ base: base, len: len, @@ -89,7 +83,7 @@ unsafe fn CVec(base: *mut T, len: uint) -> CVec { * * dtor - A function to run when the value is destructed, useful * for freeing the buffer, etc. */ -unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: fn@()) +pub unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: fn@()) -> CVec { return CVecCtor({ base: base, @@ -107,7 +101,7 @@ unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: fn@()) * * Fails if `ofs` is greater or equal to the length of the vector */ -fn get(t: CVec, ofs: uint) -> T { +pub fn get(t: CVec, ofs: uint) -> T { assert ofs < len(t); return unsafe { *ptr::mut_offset((*t).base, ofs) }; } @@ -117,7 +111,7 @@ fn get(t: CVec, ofs: uint) -> T { * * Fails if `ofs` is greater or equal to the length of the vector */ -fn set(t: CVec, ofs: uint, +v: T) { +pub fn set(t: CVec, ofs: uint, +v: T) { assert ofs < len(t); unsafe { *ptr::mut_offset((*t).base, ofs) = v }; } @@ -127,18 +121,17 @@ fn set(t: CVec, ofs: uint, +v: T) { */ /// Returns the length of the vector -fn len(t: CVec) -> uint { +pub fn len(t: CVec) -> uint { return (*t).len; } /// Returns a pointer to the first element of the vector -unsafe fn ptr(t: CVec) -> *mut T { +pub unsafe fn ptr(t: CVec) -> *mut T { return (*t).base; } #[cfg(test)] mod tests { - #[legacy_exports]; use libc::*; fn malloc(n: size_t) -> CVec { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 27b9dfac2bb..5b181d2e4c0 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -67,7 +67,6 @@ mod uv_global_loop; // Utility modules -#[legacy_exports] mod c_vec; mod timer; mod cell; -- cgit 1.4.1-3-g733a5 From 8cc61c816a0f08535f6300af4a5eaf30b8094c57 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 1 Oct 2012 14:01:42 -0700 Subject: De-export std::{rope,smallintmap}. Part of #3583. --- src/libstd/rope.rs | 139 ++++++++++++++++++++++------------------------ src/libstd/smallintmap.rs | 14 ++--- src/libstd/std.rc | 2 - 3 files changed, 74 insertions(+), 81 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 3f10fdb2b1d..47539b2dab6 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -26,14 +26,14 @@ #[forbid(deprecated_mode)]; /// The type of ropes. -type Rope = node::Root; +pub type Rope = node::Root; /* Section: Creating a rope */ /// Create an empty rope -fn empty() -> Rope { +pub fn empty() -> Rope { return node::Empty; } @@ -54,7 +54,7 @@ fn empty() -> Rope { * * this operation does not copy the string; * * the function runs in linear time. */ -fn of_str(str: @~str) -> Rope { +pub fn of_str(str: @~str) -> Rope { return of_substr(str, 0u, str::len(*str)); } @@ -80,7 +80,7 @@ fn of_str(str: @~str) -> Rope { * * this function does _not_ check the validity of the substring; * * this function fails if `byte_offset` or `byte_len` do not match `str`. */ -fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope { +pub fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } if byte_offset + byte_len > str::len(*str) { fail; } return node::Content(node::of_substr(str, byte_offset, byte_len)); @@ -97,7 +97,7 @@ Section: Adding things to a rope * * * this function executes in near-constant time */ -fn append_char(rope: Rope, char: char) -> Rope { +pub fn append_char(rope: Rope, char: char) -> Rope { return append_str(rope, @str::from_chars(~[char])); } @@ -108,7 +108,7 @@ fn append_char(rope: Rope, char: char) -> Rope { * * * this function executes in near-linear time */ -fn append_str(rope: Rope, str: @~str) -> Rope { +pub fn append_str(rope: Rope, str: @~str) -> Rope { return append_rope(rope, of_str(str)) } @@ -118,7 +118,7 @@ fn append_str(rope: Rope, str: @~str) -> Rope { * # Performance note * * this function executes in near-constant time */ -fn prepend_char(rope: Rope, char: char) -> Rope { +pub fn prepend_char(rope: Rope, char: char) -> Rope { return prepend_str(rope, @str::from_chars(~[char])); } @@ -128,12 +128,12 @@ fn prepend_char(rope: Rope, char: char) -> Rope { * # Performance note * * this function executes in near-linear time */ -fn prepend_str(rope: Rope, str: @~str) -> Rope { +pub fn prepend_str(rope: Rope, str: @~str) -> Rope { return append_rope(of_str(str), rope) } /// Concatenate two ropes -fn append_rope(left: Rope, right: Rope) -> Rope { +pub fn append_rope(left: Rope, right: Rope) -> Rope { match (left) { node::Empty => return right, node::Content(left_content) => { @@ -154,7 +154,7 @@ fn append_rope(left: Rope, right: Rope) -> Rope { * rope remains balanced. However, this function does not take any further * measure to ensure that the result is balanced. */ -fn concat(v: ~[Rope]) -> Rope { +pub fn concat(v: ~[Rope]) -> Rope { //Copy `v` into a mut vector let mut len = vec::len(v); if len == 0u { return node::Empty; } @@ -197,7 +197,7 @@ Section: Keeping ropes healthy * If you perform numerous rope concatenations, it is generally a good idea * to rebalance your rope at some point, before using it for other purposes. */ -fn bal(rope:Rope) -> Rope { +pub fn bal(rope:Rope) -> Rope { match (rope) { node::Empty => return rope, node::Content(x) => match (node::bal(x)) { @@ -225,7 +225,7 @@ Section: Transforming ropes * * this function fails if char_offset/char_len do not represent * valid positions in rope */ -fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { +pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { if char_len == 0u { return node::Empty; } match (rope) { node::Empty => fail, @@ -250,7 +250,7 @@ fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { * * this function fails if byte_offset/byte_len do not represent * valid positions in rope */ -fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope { +pub fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } match (rope) { node::Empty => fail, @@ -276,7 +276,7 @@ Section: Comparing ropes * A negative value if `left < right`, 0 if eq(left, right) or a positive * value if `left > right` */ -fn cmp(left: Rope, right: Rope) -> int { +pub fn cmp(left: Rope, right: Rope) -> int { match ((left, right)) { (node::Empty, node::Empty) => return 0, (node::Empty, _) => return -1, @@ -291,7 +291,7 @@ fn cmp(left: Rope, right: Rope) -> int { * Returns `true` if both ropes have the same content (regardless of * their structure), `false` otherwise */ -fn eq(left: Rope, right: Rope) -> bool { +pub fn eq(left: Rope, right: Rope) -> bool { return cmp(left, right) == 0; } @@ -306,7 +306,7 @@ fn eq(left: Rope, right: Rope) -> bool { * `true` if `left <= right` in lexicographical order (regardless of their * structure), `false` otherwise */ -fn le(left: Rope, right: Rope) -> bool { +pub fn le(left: Rope, right: Rope) -> bool { return cmp(left, right) <= 0; } @@ -321,7 +321,7 @@ fn le(left: Rope, right: Rope) -> bool { * `true` if `left < right` in lexicographical order (regardless of their * structure), `false` otherwise */ -fn lt(left: Rope, right: Rope) -> bool { +pub fn lt(left: Rope, right: Rope) -> bool { return cmp(left, right) < 0; } @@ -336,7 +336,7 @@ fn lt(left: Rope, right: Rope) -> bool { * `true` if `left >= right` in lexicographical order (regardless of their * structure), `false` otherwise */ -fn ge(left: Rope, right: Rope) -> bool { +pub fn ge(left: Rope, right: Rope) -> bool { return cmp(left, right) >= 0; } @@ -351,7 +351,7 @@ fn ge(left: Rope, right: Rope) -> bool { * `true` if `left > right` in lexicographical order (regardless of their * structure), `false` otherwise */ -fn gt(left: Rope, right: Rope) -> bool { +pub fn gt(left: Rope, right: Rope) -> bool { return cmp(left, right) > 0; } @@ -379,7 +379,7 @@ Section: Iterating * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -fn loop_chars(rope: Rope, it: fn(char) -> bool) -> bool { +pub fn loop_chars(rope: Rope, it: fn(char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) @@ -393,7 +393,7 @@ fn loop_chars(rope: Rope, it: fn(char) -> bool) -> bool { * * rope - A rope to traverse. It may be empty * * it - A block to execute with each consecutive character of the rope. */ -fn iter_chars(rope: Rope, it: fn(char)) { +pub fn iter_chars(rope: Rope, it: fn(char)) { do loop_chars(rope) |x| { it(x); true @@ -422,17 +422,15 @@ fn iter_chars(rope: Rope, it: fn(char)) { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -fn loop_leaves(rope: Rope, it: fn(node::Leaf) -> bool) -> bool{ +pub fn loop_leaves(rope: Rope, it: fn(node::Leaf) -> bool) -> bool{ match (rope) { node::Empty => return true, node::Content(x) => return node::loop_leaves(x, it) } } -mod iterator { - #[legacy_exports]; - mod leaf { - #[legacy_exports]; +pub mod iterator { + pub mod leaf { fn start(rope: Rope) -> node::leaf_iterator::T { match (rope) { node::Empty => return node::leaf_iterator::empty(), @@ -443,8 +441,7 @@ mod iterator { return node::leaf_iterator::next(it); } } - mod char { - #[legacy_exports]; + pub mod char { fn start(rope: Rope) -> node::char_iterator::T { match (rope) { node::Empty => return node::char_iterator::empty(), @@ -472,7 +469,7 @@ mod iterator { * * Constant time. */ -fn height(rope: Rope) -> uint { +pub fn height(rope: Rope) -> uint { match (rope) { node::Empty => return 0u, node::Content(x) => return node::height(x) @@ -488,7 +485,7 @@ fn height(rope: Rope) -> uint { * * Constant time. */ -pure fn char_len(rope: Rope) -> uint { +pub pure fn char_len(rope: Rope) -> uint { match (rope) { node::Empty => return 0u, node::Content(x) => return node::char_len(x) @@ -502,7 +499,7 @@ pure fn char_len(rope: Rope) -> uint { * * Constant time. */ -pure fn byte_len(rope: Rope) -> uint { +pub pure fn byte_len(rope: Rope) -> uint { match (rope) { node::Empty => return 0u, node::Content(x) => return node::byte_len(x) @@ -525,7 +522,7 @@ pure fn byte_len(rope: Rope) -> uint { * This function executes in a time proportional to the height of the * rope + the (bounded) length of the largest leaf. */ -fn char_at(rope: Rope, pos: uint) -> char { +pub fn char_at(rope: Rope, pos: uint) -> char { match (rope) { node::Empty => fail, node::Content(x) => return node::char_at(x, pos) @@ -537,10 +534,9 @@ fn char_at(rope: Rope, pos: uint) -> char { Section: Implementation */ mod node { - #[legacy_exports]; /// Implementation of type `rope` - enum Root { + pub enum Root { /// An empty rope Empty, /// A non-empty rope @@ -564,7 +560,7 @@ mod node { * string can be shared between several ropes, e.g. for indexing * purposes. */ - type Leaf = { + pub type Leaf = { byte_offset: uint, byte_len: uint, char_len: uint, @@ -588,7 +584,7 @@ mod node { * * Used for rebalancing and to allocate stacks for traversals. */ - type Concat = { + pub type Concat = { //FIXME (#2744): Perhaps a `vec` instead of `left`/`right` left: @Node, right: @Node, @@ -597,7 +593,7 @@ mod node { height: uint }; - enum Node { + pub enum Node { /// A leaf consisting in a `str` Leaf(Leaf), /// The concatenation of two ropes @@ -609,14 +605,14 @@ mod node { * * This is not a strict value */ - const hint_max_leaf_char_len: uint = 256u; + pub const hint_max_leaf_char_len: uint = 256u; /** * The maximal height that _should_ be permitted in a tree. * * This is not a strict value */ - const hint_max_node_height: uint = 16u; + pub const hint_max_node_height: uint = 16u; /** * Adopt a string as a node. @@ -628,7 +624,7 @@ mod node { * Performance note: The complexity of this function is linear in * the length of `str`. */ - fn of_str(str: @~str) -> @Node { + pub fn of_str(str: @~str) -> @Node { return of_substr(str, 0u, str::len(*str)); } @@ -649,7 +645,7 @@ mod node { * Behavior is undefined if `byte_start` or `byte_len` do not represent * valid positions in `str` */ - fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @Node { + pub fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @Node { return of_substr_unsafer(str, byte_start, byte_len, str::count_chars(*str, byte_start, byte_len)); } @@ -675,8 +671,8 @@ mod node { * * Behavior is undefined if `char_len` does not accurately represent the * number of chars between byte_start and byte_start+byte_len */ - fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, - char_len: uint) -> @Node { + pub fn of_substr_unsafer(str: @~str, byte_start: uint, byte_len: uint, + char_len: uint) -> @Node { assert(byte_start + byte_len <= str::len(*str)); let candidate = @Leaf({ byte_offset: byte_start, @@ -733,7 +729,7 @@ mod node { } } - pure fn byte_len(node: @Node) -> uint { + pub pure fn byte_len(node: @Node) -> uint { //FIXME (#2744): Could we do this without the pattern-matching? match (*node) { Leaf(y) => return y.byte_len, @@ -741,7 +737,7 @@ mod node { } } - pure fn char_len(node: @Node) -> uint { + pub pure fn char_len(node: @Node) -> uint { match (*node) { Leaf(y) => return y.char_len, Concat(ref y) => return y.char_len @@ -756,7 +752,7 @@ mod node { * * forest - The forest. This vector is progressively rewritten during * execution and should be discarded as meaningless afterwards. */ - fn tree_from_forest_destructive(forest: &[mut @Node]) -> @Node { + pub fn tree_from_forest_destructive(forest: &[mut @Node]) -> @Node { let mut i; let mut len = vec::len(forest); while len > 1u { @@ -800,7 +796,7 @@ mod node { return forest[0]; } - fn serialize_node(node: @Node) -> ~str unsafe { + pub fn serialize_node(node: @Node) -> ~str unsafe { let mut buf = vec::to_mut(vec::from_elem(byte_len(node), 0u8)); let mut offset = 0u;//Current position in the buffer let it = leaf_iterator::start(node); @@ -831,7 +827,7 @@ mod node { * * This function executes in linear time. */ - fn flatten(node: @Node) -> @Node unsafe { + pub fn flatten(node: @Node) -> @Node unsafe { match (*node) { Leaf(_) => return node, Concat(ref x) => { @@ -860,7 +856,7 @@ mod node { * * `option::some(x)` otherwise, in which case `x` has the same contents * as `node` bot lower height and/or fragmentation. */ - fn bal(node: @Node) -> Option<@Node> { + pub fn bal(node: @Node) -> Option<@Node> { if height(node) < hint_max_node_height { return option::None; } //1. Gather all leaves as a forest let mut forest = ~[]; @@ -896,7 +892,8 @@ mod node { * This function fails if `byte_offset` or `byte_len` do not represent * valid positions in `node`. */ - fn sub_bytes(node: @Node, byte_offset: uint, byte_len: uint) -> @Node { + pub fn sub_bytes(node: @Node, byte_offset: uint, + byte_len: uint) -> @Node { let mut node = node; let mut byte_offset = byte_offset; loop { @@ -957,7 +954,8 @@ mod node { * This function fails if `char_offset` or `char_len` do not represent * valid positions in `node`. */ - fn sub_chars(node: @Node, char_offset: uint, char_len: uint) -> @Node { + pub fn sub_chars(node: @Node, char_offset: uint, + char_len: uint) -> @Node { let mut node = node; let mut char_offset = char_offset; loop { @@ -1002,7 +1000,7 @@ mod node { }; } - fn concat2(left: @Node, right: @Node) -> @Node { + pub fn concat2(left: @Node, right: @Node) -> @Node { return @Concat({left : left, right : right, char_len: char_len(left) + char_len(right), @@ -1011,14 +1009,14 @@ mod node { }) } - fn height(node: @Node) -> uint { + pub fn height(node: @Node) -> uint { match (*node) { Leaf(_) => return 0u, Concat(ref x) => return x.height } } - fn cmp(a: @Node, b: @Node) -> int { + pub fn cmp(a: @Node, b: @Node) -> int { let ita = char_iterator::start(a); let itb = char_iterator::start(b); let mut result = 0; @@ -1039,7 +1037,7 @@ mod node { return result; } - fn loop_chars(node: @Node, it: fn(char) -> bool) -> bool { + pub fn loop_chars(node: @Node, it: fn(char) -> bool) -> bool { return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, @@ -1061,7 +1059,7 @@ mod node { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ - fn loop_leaves(node: @Node, it: fn(Leaf) -> bool) -> bool{ + pub fn loop_leaves(node: @Node, it: fn(Leaf) -> bool) -> bool{ let mut current = node; loop { match (*current) { @@ -1092,7 +1090,7 @@ mod node { * proportional to the height of the rope + the (bounded) * length of the largest leaf. */ - fn char_at(node: @Node, pos: uint) -> char { + pub fn char_at(node: @Node, pos: uint) -> char { let mut node = node; let mut pos = pos; loop { @@ -1107,19 +1105,18 @@ mod node { }; } - mod leaf_iterator { - #[legacy_exports]; - type T = { + pub mod leaf_iterator { + pub type T = { stack: ~[mut @Node], mut stackpos: int }; - fn empty() -> T { + pub fn empty() -> T { let stack : ~[mut @Node] = ~[mut]; return {stack: move stack, mut stackpos: -1} } - fn start(node: @Node) -> T { + pub fn start(node: @Node) -> T { let stack = vec::to_mut(vec::from_elem(height(node)+1u, node)); return { stack: move stack, @@ -1127,7 +1124,7 @@ mod node { } } - fn next(it: &T) -> Option { + pub fn next(it: &T) -> Option { if it.stackpos < 0 { return option::None; } loop { let current = it.stack[it.stackpos]; @@ -1145,15 +1142,14 @@ mod node { } } - mod char_iterator { - #[legacy_exports]; - type T = { + pub mod char_iterator { + pub type T = { leaf_iterator: leaf_iterator::T, mut leaf: Option, mut leaf_byte_pos: uint }; - fn start(node: @Node) -> T { + pub fn start(node: @Node) -> T { return { leaf_iterator: leaf_iterator::start(node), mut leaf: option::None, @@ -1161,7 +1157,7 @@ mod node { } } - fn empty() -> T { + pub fn empty() -> T { return { leaf_iterator: leaf_iterator::empty(), mut leaf: option::None, @@ -1169,7 +1165,7 @@ mod node { } } - fn next(it: &T) -> Option { + pub fn next(it: &T) -> Option { loop { match (get_current_or_next_leaf(it)) { option::None => return option::None, @@ -1184,7 +1180,7 @@ mod node { }; } - fn get_current_or_next_leaf(it: &T) -> Option { + pub fn get_current_or_next_leaf(it: &T) -> Option { match ((*it).leaf) { option::Some(_) => return (*it).leaf, option::None => { @@ -1201,7 +1197,7 @@ mod node { } } - fn get_next_char_in_leaf(it: &T) -> Option { + pub fn get_next_char_in_leaf(it: &T) -> Option { match copy (*it).leaf { option::None => return option::None, option::Some(aleaf) => { @@ -1224,7 +1220,6 @@ mod node { #[cfg(test)] mod tests { - #[legacy_exports]; //Utility function, used for sanity check fn rope_to_string(r: Rope) -> ~str { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 1100485e7f1..2e7f47e0af0 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -13,12 +13,12 @@ use map::Map; // requires this to be. type SmallIntMap_ = {v: DVec>}; -enum SmallIntMap { +pub enum SmallIntMap { SmallIntMap_(@SmallIntMap_) } /// Create a smallintmap -fn mk() -> SmallIntMap { +pub fn mk() -> SmallIntMap { let v = DVec(); return SmallIntMap_(@{v: move v}); } @@ -28,7 +28,7 @@ fn mk() -> SmallIntMap { * the specified key then the original value is replaced. */ #[inline(always)] -fn insert(self: SmallIntMap, key: uint, +val: T) { +pub fn insert(self: SmallIntMap, key: uint, +val: T) { //io::println(fmt!("%?", key)); self.v.grow_set_elt(key, &None, Some(val)); } @@ -37,7 +37,7 @@ fn insert(self: SmallIntMap, key: uint, +val: T) { * Get the value for the specified key. If the key does not exist * in the map then returns none */ -pure fn find(self: SmallIntMap, key: uint) -> Option { +pub pure fn find(self: SmallIntMap, key: uint) -> Option { if key < self.v.len() { return self.v.get_elt(key); } return None::; } @@ -49,7 +49,7 @@ pure fn find(self: SmallIntMap, key: uint) -> Option { * * If the key does not exist in the map */ -pure fn get(self: SmallIntMap, key: uint) -> T { +pub pure fn get(self: SmallIntMap, key: uint) -> T { match find(self, key) { None => { error!("smallintmap::get(): key not present"); @@ -60,7 +60,7 @@ pure fn get(self: SmallIntMap, key: uint) -> T { } /// Returns true if the map contains a value for the specified key -fn contains_key(self: SmallIntMap, key: uint) -> bool { +pub fn contains_key(self: SmallIntMap, key: uint) -> bool { return !find(self, key).is_none(); } @@ -139,6 +139,6 @@ impl SmallIntMap: ops::Index { } /// Cast the given smallintmap to a map::map -fn as_map(s: SmallIntMap) -> map::Map { +pub fn as_map(s: SmallIntMap) -> map::Map { s as map::Map:: } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 5b181d2e4c0..a38d9772b5c 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -87,9 +87,7 @@ mod fun_treemap; mod list; #[legacy_exports] mod map; -#[legacy_exports] mod rope; -#[legacy_exports] mod smallintmap; mod sort; mod treemap; -- cgit 1.4.1-3-g733a5 From 13979eb7e2fddd3f46f4e83fbc41ed656636ce80 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 1 Oct 2012 17:32:50 -0700 Subject: De-export std::test. Part of #3583. --- src/libstd/std.rc | 1 - src/libstd/test.rs | 25 +++++++------------------ 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/std.rc b/src/libstd/std.rc index a38d9772b5c..6f2c38b03fe 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -121,7 +121,6 @@ mod unicode; // Compiler support modules -#[legacy_exports] mod test; #[legacy_exports] mod serialization; diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 691f0e840e6..1df10a4d799 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -15,17 +15,6 @@ use libc::size_t; use task::TaskBuilder; use comm = core::comm; -export TestName; -export TestFn; -export TestDesc; -export test_main; -export TestResult; -export TestOpts; -export TrOk; -export TrFailed; -export TrIgnored; -export run_tests_console; - #[abi = "cdecl"] extern mod rustrt { #[legacy_exports]; @@ -36,17 +25,17 @@ extern mod rustrt { // paths; i.e. it should be a series of identifiers seperated by double // colons. This way if some test runner wants to arrange the tests // hierarchically it may. -type TestName = ~str; +pub type TestName = ~str; // A function that runs a test. If the function returns successfully, // the test succeeds; if the function fails then the test fails. We // may need to come up with a more clever definition of test in order // to support isolation of tests into tasks. -type TestFn = fn~(); +pub type TestFn = fn~(); // The definition of a single test. A test runner will run a list of // these. -type TestDesc = { +pub type TestDesc = { name: TestName, testfn: TestFn, ignore: bool, @@ -55,7 +44,7 @@ type TestDesc = { // The default console test runner. It accepts the command line // arguments and a vector of test_descs (generated at compile time). -fn test_main(args: &[~str], tests: &[TestDesc]) { +pub fn test_main(args: &[~str], tests: &[TestDesc]) { let opts = match parse_opts(args) { either::Left(move o) => o, @@ -64,7 +53,7 @@ fn test_main(args: &[~str], tests: &[TestDesc]) { if !run_tests_console(&opts, tests) { fail ~"Some tests failed"; } } -type TestOpts = {filter: Option<~str>, run_ignored: bool, +pub type TestOpts = {filter: Option<~str>, run_ignored: bool, logfile: Option<~str>}; type OptRes = Either; @@ -93,7 +82,7 @@ fn parse_opts(args: &[~str]) -> OptRes { return either::Left(test_opts); } -enum TestResult { TrOk, TrFailed, TrIgnored, } +pub enum TestResult { TrOk, TrFailed, TrIgnored, } impl TestResult : Eq { pure fn eq(other: &TestResult) -> bool { @@ -113,7 +102,7 @@ type ConsoleTestState = mut failures: ~[TestDesc]}; // A simple console test runner -fn run_tests_console(opts: &TestOpts, +pub fn run_tests_console(opts: &TestOpts, tests: &[TestDesc]) -> bool { fn callback(event: &TestEvent, st: ConsoleTestState) { -- cgit 1.4.1-3-g733a5 From fa010a6ee45f5ca106a4a475e06f4fa75d0c0970 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 1 Oct 2012 17:26:50 -0700 Subject: De-export std::{uv, uv_ll, uv_iotask, uv_global_loop}. Part of #3583. --- src/libstd/std.rc | 4 - src/libstd/uv.rs | 11 +- src/libstd/uv_global_loop.rs | 6 +- src/libstd/uv_iotask.rs | 14 +-- src/libstd/uv_ll.rs | 271 +++++++++++++++++++++---------------------- 5 files changed, 139 insertions(+), 167 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 6f2c38b03fe..4d5eefec053 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -55,13 +55,9 @@ mod net_tcp; mod net_url; // libuv modules -#[legacy_exports] mod uv; -#[legacy_exports] mod uv_ll; -#[legacy_exports] mod uv_iotask; -#[legacy_exports] mod uv_global_loop; diff --git a/src/libstd/uv.rs b/src/libstd/uv.rs index 311c9f28dd8..e0fd013907c 100644 --- a/src/libstd/uv.rs +++ b/src/libstd/uv.rs @@ -23,11 +23,6 @@ * facilities. */ -use ll = uv_ll; -export ll; - -use iotask = uv_iotask; -export iotask; - -use global_loop = uv_global_loop; -export global_loop; +pub use ll = uv_ll; +pub use iotask = uv_iotask; +pub use global_loop = uv_global_loop; diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 9ccacd1f7f6..869c3efa38f 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -2,8 +2,6 @@ #[forbid(deprecated_mode)]; -export get; - use ll = uv_ll; use iotask = uv_iotask; use get_gl = get; @@ -15,7 +13,6 @@ use task::TaskBuilder; use either::{Left, Right}; extern mod rustrt { - #[legacy_exports]; fn rust_uv_get_kernel_global_chan_ptr() -> *libc::uintptr_t; } @@ -31,7 +28,7 @@ extern mod rustrt { * * A `hl::high_level_loop` that encapsulates communication with the global * loop. */ -fn get() -> IoTask { +pub fn get() -> IoTask { return get_monitor_task_gl(); } @@ -112,7 +109,6 @@ fn spawn_loop() -> IoTask { #[cfg(test)] mod test { - #[legacy_exports]; extern fn simple_timer_close_cb(timer_ptr: *ll::uv_timer_t) unsafe { let exit_ch_ptr = ll::get_data_for_uv_handle( timer_ptr as *libc::c_void) as *comm::Chan; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index ab50cc9d929..876aa6f4af0 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -7,11 +7,6 @@ #[forbid(deprecated_mode)]; -export IoTask; -export spawn_iotask; -export interact; -export exit; - use libc::c_void; use ptr::p2::addr_of; use comm = core::comm; @@ -20,14 +15,14 @@ use task::TaskBuilder; use ll = uv_ll; /// Used to abstract-away direct interaction with a libuv loop. -enum IoTask { +pub enum IoTask { IoTask_({ async_handle: *ll::uv_async_t, op_chan: Chan }) } -fn spawn_iotask(+task: task::TaskBuilder) -> IoTask { +pub fn spawn_iotask(+task: task::TaskBuilder) -> IoTask { do listen |iotask_ch| { @@ -64,7 +59,7 @@ fn spawn_iotask(+task: task::TaskBuilder) -> IoTask { * module. It is not safe to send the `loop_ptr` param to this callback out * via ports/chans. */ -unsafe fn interact(iotask: IoTask, +pub unsafe fn interact(iotask: IoTask, +cb: fn~(*c_void)) { send_msg(iotask, Interaction(move cb)); } @@ -76,7 +71,7 @@ unsafe fn interact(iotask: IoTask, * async handle and do a sanity check to make sure that all other handles are * closed, causing a failure otherwise. */ -fn exit(iotask: IoTask) unsafe { +pub fn exit(iotask: IoTask) unsafe { send_msg(iotask, TeardownLoop); } @@ -170,7 +165,6 @@ extern fn tear_down_close_cb(handle: *ll::uv_async_t) unsafe { #[cfg(test)] mod test { - #[legacy_exports]; extern fn async_close_cb(handle: *ll::uv_async_t) unsafe { log(debug, fmt!("async_close_cb handle %?", handle)); let exit_ch = (*(ll::get_data_for_uv_handle(handle) diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index fca34c01bc1..f0594475d04 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -27,13 +27,13 @@ use comm = core::comm; use ptr::to_unsafe_ptr; // libuv struct mappings -type uv_ip4_addr = { +pub type uv_ip4_addr = { ip: ~[u8], port: int }; -type uv_ip6_addr = uv_ip4_addr; +pub type uv_ip6_addr = uv_ip4_addr; -enum uv_handle_type { +pub enum uv_handle_type { UNKNOWN_HANDLE = 0, UV_TCP, UV_UDP, @@ -51,9 +51,9 @@ enum uv_handle_type { UV_FS_EVENT } -type handle_type = libc::c_uint; +pub type handle_type = libc::c_uint; -type uv_handle_fields = { +pub type uv_handle_fields = { loop_handle: *libc::c_void, type_: handle_type, close_cb: *u8, @@ -61,7 +61,7 @@ type uv_handle_fields = { }; // unix size: 8 -type uv_err_t = { +pub type uv_err_t = { code: libc::c_int, sys_errno_: libc::c_int }; @@ -71,13 +71,13 @@ type uv_err_t = { // in other types as a pointer to be used in other // operations (so mostly treat it as opaque, once you // have it in this form..) -type uv_stream_t = { +pub type uv_stream_t = { fields: uv_handle_fields }; // 64bit unix size: 272 #[cfg(unix)] -type uv_tcp_t = { +pub type uv_tcp_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -91,11 +91,11 @@ type uv_tcp_t = { }; // 32bit unix size: 328 (164) #[cfg(target_arch="x86_64")] -type uv_tcp_t_32bit_unix_riders = { +pub type uv_tcp_t_32bit_unix_riders = { a29: *u8 }; #[cfg(target_arch="x86")] -type uv_tcp_t_32bit_unix_riders = { +pub type uv_tcp_t_32bit_unix_riders = { a29: *u8, a30: *u8, a31: *u8, a32: *u8, a33: *u8, a34: *u8, a35: *u8, a36: *u8 @@ -103,7 +103,7 @@ type uv_tcp_t_32bit_unix_riders = { // 32bit win32 size: 240 (120) #[cfg(windows)] -type uv_tcp_t = { +pub type uv_tcp_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -116,20 +116,20 @@ type uv_tcp_t = { // unix size: 48 #[cfg(unix)] -type uv_connect_t = { +pub type uv_connect_t = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8 }; // win32 size: 88 (44) #[cfg(windows)] -type uv_connect_t = { +pub type uv_connect_t = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, a08: *u8, a09: *u8, a10: *u8 }; // unix size: 16 -type uv_buf_t = { +pub type uv_buf_t = { base: *u8, len: libc::size_t }; @@ -138,7 +138,7 @@ type uv_buf_t = { // unix size: 144 #[cfg(unix)] -type uv_write_t = { +pub type uv_write_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -147,16 +147,16 @@ type uv_write_t = { a14: uv_write_t_32bit_unix_riders }; #[cfg(target_arch="x86_64")] -type uv_write_t_32bit_unix_riders = { +pub type uv_write_t_32bit_unix_riders = { a13: *u8 }; #[cfg(target_arch="x86")] -type uv_write_t_32bit_unix_riders = { +pub type uv_write_t_32bit_unix_riders = { a13: *u8, a14: *u8 }; // win32 size: 136 (68) #[cfg(windows)] -type uv_write_t = { +pub type uv_write_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -166,7 +166,7 @@ type uv_write_t = { // 64bit unix size: 120 // 32bit unix size: 152 (76) #[cfg(unix)] -type uv_async_t = { +pub type uv_async_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -174,16 +174,16 @@ type uv_async_t = { a11: uv_async_t_32bit_unix_riders }; #[cfg(target_arch="x86_64")] -type uv_async_t_32bit_unix_riders = { +pub type uv_async_t_32bit_unix_riders = { a10: *u8 }; #[cfg(target_arch="x86")] -type uv_async_t_32bit_unix_riders = { +pub type uv_async_t_32bit_unix_riders = { a10: *u8, a11: *u8, a12: *u8, a13: *u8 }; // win32 size 132 (68) #[cfg(windows)] -type uv_async_t = { +pub type uv_async_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -194,7 +194,7 @@ type uv_async_t = { // 64bit unix size: 128 // 32bit unix size: 84 #[cfg(unix)] -type uv_timer_t = { +pub type uv_timer_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -202,17 +202,17 @@ type uv_timer_t = { a11: uv_timer_t_32bit_unix_riders }; #[cfg(target_arch="x86_64")] -type uv_timer_t_32bit_unix_riders = { +pub type uv_timer_t_32bit_unix_riders = { a10: *u8, a11: *u8 }; #[cfg(target_arch="x86")] -type uv_timer_t_32bit_unix_riders = { +pub type uv_timer_t_32bit_unix_riders = { a10: *u8, a11: *u8, a12: *u8, a13: *u8, a14: *u8, a15: *u8, a16: *u8 }; // win32 size: 64 #[cfg(windows)] -type uv_timer_t = { +pub type uv_timer_t = { fields: uv_handle_fields, a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, @@ -220,7 +220,7 @@ type uv_timer_t = { }; // unix size: 16 -type sockaddr_in = { +pub type sockaddr_in = { mut sin_family: u16, mut sin_port: u16, mut sin_addr: u32, // in_addr: this is an opaque, per-platform struct @@ -230,12 +230,12 @@ type sockaddr_in = { // unix size: 28 .. FIXME #1645 // stuck with 32 becuse of rust padding structs? #[cfg(target_arch="x86_64")] -type sockaddr_in6 = { +pub type sockaddr_in6 = { a0: *u8, a1: *u8, a2: *u8, a3: *u8 }; #[cfg(target_arch="x86")] -type sockaddr_in6 = { +pub type sockaddr_in6 = { a0: *u8, a1: *u8, a2: *u8, a3: *u8, a4: *u8, a5: *u8, @@ -244,17 +244,16 @@ type sockaddr_in6 = { // unix size: 28 .. FIXME #1645 // stuck with 32 becuse of rust padding structs? -type addr_in = addr_in_impl::addr_in; +pub type addr_in = addr_in_impl::addr_in; #[cfg(unix)] -mod addr_in_impl { - #[legacy_exports]; +pub mod addr_in_impl { #[cfg(target_arch="x86_64")] - type addr_in = { + pub type addr_in = { a0: *u8, a1: *u8, a2: *u8, a3: *u8 }; #[cfg(target_arch="x86")] - type addr_in = { + pub type addr_in = { a0: *u8, a1: *u8, a2: *u8, a3: *u8, a4: *u8, a5: *u8, @@ -262,65 +261,60 @@ mod addr_in_impl { }; } #[cfg(windows)] -mod addr_in_impl { - #[legacy_exports]; - type addr_in = { +pub mod addr_in_impl { + pub type addr_in = { a0: *u8, a1: *u8, a2: *u8, a3: *u8 }; } // unix size: 48, 32bit: 32 -type addrinfo = addrinfo_impl::addrinfo; +pub type addrinfo = addrinfo_impl::addrinfo; #[cfg(target_os="linux")] -mod addrinfo_impl { - #[legacy_exports]; +pub mod addrinfo_impl { #[cfg(target_arch="x86_64")] - type addrinfo = { + pub type addrinfo = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8 }; #[cfg(target_arch="x86")] - type addrinfo = { + pub type addrinfo = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8 }; } #[cfg(target_os="macos")] #[cfg(target_os="freebsd")] -mod addrinfo_impl { - #[legacy_exports]; - type addrinfo = { +pub mod addrinfo_impl { + pub type addrinfo = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8 }; } #[cfg(windows)] -mod addrinfo_impl { - #[legacy_exports]; - type addrinfo = { +pub mod addrinfo_impl { + pub type addrinfo = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8 }; } // unix size: 72 -type uv_getaddrinfo_t = { +pub type uv_getaddrinfo_t = { a00: *u8, a01: *u8, a02: *u8, a03: *u8, a04: *u8, a05: *u8, a06: *u8, a07: *u8, a08: *u8 }; -mod uv_ll_struct_stubgen { - #[legacy_exports]; - fn gen_stub_uv_tcp_t() -> uv_tcp_t { +pub mod uv_ll_struct_stubgen { + pub fn gen_stub_uv_tcp_t() -> uv_tcp_t { return gen_stub_os(); #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] - fn gen_stub_os() -> uv_tcp_t { + pub fn gen_stub_os() -> uv_tcp_t { return gen_stub_arch(); #[cfg(target_arch="x86_64")] - fn gen_stub_arch() -> uv_tcp_t { + pub fn gen_stub_arch() -> uv_tcp_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -345,7 +339,7 @@ mod uv_ll_struct_stubgen { }; } #[cfg(target_arch="x86")] - fn gen_stub_arch() -> uv_tcp_t { + pub fn gen_stub_arch() -> uv_tcp_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -373,7 +367,7 @@ mod uv_ll_struct_stubgen { } } #[cfg(windows)] - fn gen_stub_os() -> uv_tcp_t { + pub fn gen_stub_os() -> uv_tcp_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -394,7 +388,7 @@ mod uv_ll_struct_stubgen { } } #[cfg(unix)] - fn gen_stub_uv_connect_t() -> uv_connect_t { + pub fn gen_stub_uv_connect_t() -> uv_connect_t { return { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, @@ -402,7 +396,7 @@ mod uv_ll_struct_stubgen { }; } #[cfg(windows)] - fn gen_stub_uv_connect_t() -> uv_connect_t { + pub fn gen_stub_uv_connect_t() -> uv_connect_t { return { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, @@ -412,10 +406,10 @@ mod uv_ll_struct_stubgen { }; } #[cfg(unix)] - fn gen_stub_uv_async_t() -> uv_async_t { + pub fn gen_stub_uv_async_t() -> uv_async_t { return gen_stub_arch(); #[cfg(target_arch = "x86_64")] - fn gen_stub_arch() -> uv_async_t { + pub fn gen_stub_arch() -> uv_async_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -430,7 +424,7 @@ mod uv_ll_struct_stubgen { }; } #[cfg(target_arch = "x86")] - fn gen_stub_arch() -> uv_async_t { + pub fn gen_stub_arch() -> uv_async_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -447,7 +441,7 @@ mod uv_ll_struct_stubgen { } } #[cfg(windows)] - fn gen_stub_uv_async_t() -> uv_async_t { + pub fn gen_stub_uv_async_t() -> uv_async_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -461,10 +455,10 @@ mod uv_ll_struct_stubgen { }; } #[cfg(unix)] - fn gen_stub_uv_timer_t() -> uv_timer_t { + pub fn gen_stub_uv_timer_t() -> uv_timer_t { return gen_stub_arch(); #[cfg(target_arch = "x86_64")] - fn gen_stub_arch() -> uv_timer_t { + pub fn gen_stub_arch() -> uv_timer_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -479,7 +473,7 @@ mod uv_ll_struct_stubgen { }; } #[cfg(target_arch = "x86")] - fn gen_stub_arch() -> uv_timer_t { + pub fn gen_stub_arch() -> uv_timer_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -498,7 +492,7 @@ mod uv_ll_struct_stubgen { } } #[cfg(windows)] - fn gen_stub_uv_timer_t() -> uv_timer_t { + pub fn gen_stub_uv_timer_t() -> uv_timer_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -511,10 +505,10 @@ mod uv_ll_struct_stubgen { }; } #[cfg(unix)] - fn gen_stub_uv_write_t() -> uv_write_t { + pub fn gen_stub_uv_write_t() -> uv_write_t { return gen_stub_arch(); #[cfg(target_arch="x86_64")] - fn gen_stub_arch() -> uv_write_t { + pub fn gen_stub_arch() -> uv_write_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -528,7 +522,7 @@ mod uv_ll_struct_stubgen { }; } #[cfg(target_arch="x86")] - fn gen_stub_arch() -> uv_write_t { + pub fn gen_stub_arch() -> uv_write_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -543,7 +537,7 @@ mod uv_ll_struct_stubgen { } } #[cfg(windows)] - fn gen_stub_uv_write_t() -> uv_write_t { + pub fn gen_stub_uv_write_t() -> uv_write_t { return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, @@ -556,7 +550,7 @@ mod uv_ll_struct_stubgen { a12: 0 as *u8 }; } - fn gen_stub_uv_getaddrinfo_t() -> uv_getaddrinfo_t { + pub fn gen_stub_uv_getaddrinfo_t() -> uv_getaddrinfo_t { { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, a07: 0 as *u8, @@ -567,7 +561,6 @@ mod uv_ll_struct_stubgen { #[nolink] extern mod rustrt { - #[legacy_exports]; // libuv public API fn rust_uv_loop_new() -> *libc::c_void; fn rust_uv_loop_delete(lp: *libc::c_void); @@ -686,32 +679,32 @@ extern mod rustrt { fn rust_uv_helper_addr_in_size() -> libc::c_uint; } -unsafe fn loop_new() -> *libc::c_void { +pub unsafe fn loop_new() -> *libc::c_void { return rustrt::rust_uv_loop_new(); } -unsafe fn loop_delete(loop_handle: *libc::c_void) { +pub unsafe fn loop_delete(loop_handle: *libc::c_void) { rustrt::rust_uv_loop_delete(loop_handle); } -unsafe fn loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int { +pub unsafe fn loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int { return rustrt::rust_uv_loop_refcount(loop_ptr); } -unsafe fn run(loop_handle: *libc::c_void) { +pub unsafe fn run(loop_handle: *libc::c_void) { rustrt::rust_uv_run(loop_handle); } -unsafe fn close(handle: *T, cb: *u8) { +pub unsafe fn close(handle: *T, cb: *u8) { rustrt::rust_uv_close(handle as *libc::c_void, cb); } -unsafe fn tcp_init(loop_handle: *libc::c_void, handle: *uv_tcp_t) +pub unsafe fn tcp_init(loop_handle: *libc::c_void, handle: *uv_tcp_t) -> libc::c_int { return rustrt::rust_uv_tcp_init(loop_handle, handle); } // FIXME ref #2064 -unsafe fn tcp_connect(connect_ptr: *uv_connect_t, +pub unsafe fn tcp_connect(connect_ptr: *uv_connect_t, tcp_handle_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in, after_connect_cb: *u8) @@ -722,7 +715,7 @@ unsafe fn tcp_connect(connect_ptr: *uv_connect_t, after_connect_cb, addr_ptr); } // FIXME ref #2064 -unsafe fn tcp_connect6(connect_ptr: *uv_connect_t, +pub unsafe fn tcp_connect6(connect_ptr: *uv_connect_t, tcp_handle_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in6, after_connect_cb: *u8) @@ -731,30 +724,30 @@ unsafe fn tcp_connect6(connect_ptr: *uv_connect_t, after_connect_cb, addr_ptr); } // FIXME ref #2064 -unsafe fn tcp_bind(tcp_server_ptr: *uv_tcp_t, +pub unsafe fn tcp_bind(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in) -> libc::c_int { return rustrt::rust_uv_tcp_bind(tcp_server_ptr, addr_ptr); } // FIXME ref #2064 -unsafe fn tcp_bind6(tcp_server_ptr: *uv_tcp_t, +pub unsafe fn tcp_bind6(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in6) -> libc::c_int { return rustrt::rust_uv_tcp_bind6(tcp_server_ptr, addr_ptr); } -unsafe fn listen(stream: *T, backlog: libc::c_int, +pub unsafe fn listen(stream: *T, backlog: libc::c_int, cb: *u8) -> libc::c_int { return rustrt::rust_uv_listen(stream as *libc::c_void, backlog, cb); } -unsafe fn accept(server: *libc::c_void, client: *libc::c_void) +pub unsafe fn accept(server: *libc::c_void, client: *libc::c_void) -> libc::c_int { return rustrt::rust_uv_accept(server as *libc::c_void, client as *libc::c_void); } -unsafe fn write(req: *uv_write_t, stream: *T, +pub unsafe fn write(req: *uv_write_t, stream: *T, buf_in: *~[uv_buf_t], cb: *u8) -> libc::c_int { let buf_ptr = vec::raw::to_ptr(*buf_in); let buf_cnt = vec::len(*buf_in) as i32; @@ -762,28 +755,28 @@ unsafe fn write(req: *uv_write_t, stream: *T, stream as *libc::c_void, buf_ptr, buf_cnt, cb); } -unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, +pub unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, on_read: *u8) -> libc::c_int { return rustrt::rust_uv_read_start(stream as *libc::c_void, on_alloc, on_read); } -unsafe fn read_stop(stream: *uv_stream_t) -> libc::c_int { +pub unsafe fn read_stop(stream: *uv_stream_t) -> libc::c_int { return rustrt::rust_uv_read_stop(stream as *libc::c_void); } -unsafe fn last_error(loop_handle: *libc::c_void) -> uv_err_t { +pub unsafe fn last_error(loop_handle: *libc::c_void) -> uv_err_t { return rustrt::rust_uv_last_error(loop_handle); } -unsafe fn strerror(err: *uv_err_t) -> *libc::c_char { +pub unsafe fn strerror(err: *uv_err_t) -> *libc::c_char { return rustrt::rust_uv_strerror(err); } -unsafe fn err_name(err: *uv_err_t) -> *libc::c_char { +pub unsafe fn err_name(err: *uv_err_t) -> *libc::c_char { return rustrt::rust_uv_err_name(err); } -unsafe fn async_init(loop_handle: *libc::c_void, +pub unsafe fn async_init(loop_handle: *libc::c_void, async_handle: *uv_async_t, cb: *u8) -> libc::c_int { return rustrt::rust_uv_async_init(loop_handle, @@ -791,10 +784,10 @@ unsafe fn async_init(loop_handle: *libc::c_void, cb); } -unsafe fn async_send(async_handle: *uv_async_t) { +pub unsafe fn async_send(async_handle: *uv_async_t) { return rustrt::rust_uv_async_send(async_handle); } -unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t { +pub unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t { let out_buf = { base: ptr::null(), len: 0 as libc::size_t }; let out_buf_ptr = ptr::addr_of(&out_buf); log(debug, fmt!("buf_init - input %u len %u out_buf: %u", @@ -814,21 +807,21 @@ unsafe fn buf_init(input: *u8, len: uint) -> uv_buf_t { return out_buf; //return result; } -unsafe fn ip4_addr(ip: &str, port: int) +pub unsafe fn ip4_addr(ip: &str, port: int) -> sockaddr_in { do str::as_c_str(ip) |ip_buf| { rustrt::rust_uv_ip4_addr(ip_buf as *u8, port as libc::c_int) } } -unsafe fn ip6_addr(ip: &str, port: int) +pub unsafe fn ip6_addr(ip: &str, port: int) -> sockaddr_in6 { do str::as_c_str(ip) |ip_buf| { rustrt::rust_uv_ip6_addr(ip_buf as *u8, port as libc::c_int) } } -unsafe fn ip4_name(src: &sockaddr_in) -> ~str { +pub unsafe fn ip4_name(src: &sockaddr_in) -> ~str { // ipv4 addr max size: 15 + 1 trailing null byte let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8, 0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8]; @@ -844,7 +837,7 @@ unsafe fn ip4_name(src: &sockaddr_in) -> ~str { str::raw::from_buf(dst_buf) } } -unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { +pub unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { // ipv6 addr max size: 45 + 1 trailing null byte let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8, 0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8, @@ -865,19 +858,19 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { } } -unsafe fn timer_init(loop_ptr: *libc::c_void, +pub unsafe fn timer_init(loop_ptr: *libc::c_void, timer_ptr: *uv_timer_t) -> libc::c_int { return rustrt::rust_uv_timer_init(loop_ptr, timer_ptr); } -unsafe fn timer_start(timer_ptr: *uv_timer_t, cb: *u8, timeout: uint, +pub unsafe fn timer_start(timer_ptr: *uv_timer_t, cb: *u8, timeout: uint, repeat: uint) -> libc::c_int { return rustrt::rust_uv_timer_start(timer_ptr, cb, timeout as libc::c_uint, repeat as libc::c_uint); } -unsafe fn timer_stop(timer_ptr: *uv_timer_t) -> libc::c_int { +pub unsafe fn timer_stop(timer_ptr: *uv_timer_t) -> libc::c_int { return rustrt::rust_uv_timer_stop(timer_ptr); } -unsafe fn getaddrinfo(loop_ptr: *libc::c_void, +pub unsafe fn getaddrinfo(loop_ptr: *libc::c_void, handle: *uv_getaddrinfo_t, cb: *u8, node_name_ptr: *u8, @@ -890,83 +883,84 @@ unsafe fn getaddrinfo(loop_ptr: *libc::c_void, service_name_ptr, hints) } -unsafe fn freeaddrinfo(res: *addrinfo) { +pub unsafe fn freeaddrinfo(res: *addrinfo) { rustrt::rust_uv_freeaddrinfo(res); } // libuv struct initializers -unsafe fn tcp_t() -> uv_tcp_t { +pub unsafe fn tcp_t() -> uv_tcp_t { return uv_ll_struct_stubgen::gen_stub_uv_tcp_t(); } -unsafe fn connect_t() -> uv_connect_t { +pub unsafe fn connect_t() -> uv_connect_t { return uv_ll_struct_stubgen::gen_stub_uv_connect_t(); } -unsafe fn write_t() -> uv_write_t { +pub unsafe fn write_t() -> uv_write_t { return uv_ll_struct_stubgen::gen_stub_uv_write_t(); } -unsafe fn async_t() -> uv_async_t { +pub unsafe fn async_t() -> uv_async_t { return uv_ll_struct_stubgen::gen_stub_uv_async_t(); } -unsafe fn timer_t() -> uv_timer_t { +pub unsafe fn timer_t() -> uv_timer_t { return uv_ll_struct_stubgen::gen_stub_uv_timer_t(); } -unsafe fn getaddrinfo_t() -> uv_getaddrinfo_t { +pub unsafe fn getaddrinfo_t() -> uv_getaddrinfo_t { return uv_ll_struct_stubgen::gen_stub_uv_getaddrinfo_t(); } // data access helpers -unsafe fn get_loop_for_uv_handle(handle: *T) +pub unsafe fn get_loop_for_uv_handle(handle: *T) -> *libc::c_void { return rustrt::rust_uv_get_loop_for_uv_handle(handle as *libc::c_void); } -unsafe fn get_stream_handle_from_connect_req(connect: *uv_connect_t) +pub unsafe fn get_stream_handle_from_connect_req(connect: *uv_connect_t) -> *uv_stream_t { return rustrt::rust_uv_get_stream_handle_from_connect_req( connect); } -unsafe fn get_stream_handle_from_write_req( +pub unsafe fn get_stream_handle_from_write_req( write_req: *uv_write_t) -> *uv_stream_t { return rustrt::rust_uv_get_stream_handle_from_write_req( write_req); } -unsafe fn get_data_for_uv_loop(loop_ptr: *libc::c_void) -> *libc::c_void { +pub unsafe fn get_data_for_uv_loop(loop_ptr: *libc::c_void) -> *libc::c_void { rustrt::rust_uv_get_data_for_uv_loop(loop_ptr) } -unsafe fn set_data_for_uv_loop(loop_ptr: *libc::c_void, data: *libc::c_void) { +pub unsafe fn set_data_for_uv_loop(loop_ptr: *libc::c_void, + data: *libc::c_void) { rustrt::rust_uv_set_data_for_uv_loop(loop_ptr, data); } -unsafe fn get_data_for_uv_handle(handle: *T) -> *libc::c_void { +pub unsafe fn get_data_for_uv_handle(handle: *T) -> *libc::c_void { return rustrt::rust_uv_get_data_for_uv_handle(handle as *libc::c_void); } -unsafe fn set_data_for_uv_handle(handle: *T, +pub unsafe fn set_data_for_uv_handle(handle: *T, data: *U) { rustrt::rust_uv_set_data_for_uv_handle(handle as *libc::c_void, data as *libc::c_void); } -unsafe fn get_data_for_req(req: *T) -> *libc::c_void { +pub unsafe fn get_data_for_req(req: *T) -> *libc::c_void { return rustrt::rust_uv_get_data_for_req(req as *libc::c_void); } -unsafe fn set_data_for_req(req: *T, +pub unsafe fn set_data_for_req(req: *T, data: *U) { rustrt::rust_uv_set_data_for_req(req as *libc::c_void, data as *libc::c_void); } -unsafe fn get_base_from_buf(buf: uv_buf_t) -> *u8 { +pub unsafe fn get_base_from_buf(buf: uv_buf_t) -> *u8 { return rustrt::rust_uv_get_base_from_buf(buf); } -unsafe fn get_len_from_buf(buf: uv_buf_t) -> libc::size_t { +pub unsafe fn get_len_from_buf(buf: uv_buf_t) -> libc::size_t { return rustrt::rust_uv_get_len_from_buf(buf); } -unsafe fn malloc_buf_base_of(suggested_size: libc::size_t) +pub unsafe fn malloc_buf_base_of(suggested_size: libc::size_t) -> *u8 { return rustrt::rust_uv_malloc_buf_base_of(suggested_size); } -unsafe fn free_base_of_buf(buf: uv_buf_t) { +pub unsafe fn free_base_of_buf(buf: uv_buf_t) { rustrt::rust_uv_free_base_of_buf(buf); } -unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str { +pub unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str { let err = last_error(uv_loop); let err_ptr = ptr::addr_of(&err); let err_name = str::raw::from_c_str(err_name(err_ptr)); @@ -975,7 +969,7 @@ unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str { err_name, err_msg); } -unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data { +pub unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data { let err = last_error(uv_loop); let err_ptr = ptr::addr_of(&err); let err_name = str::raw::from_c_str(err_name(err_ptr)); @@ -983,33 +977,33 @@ unsafe fn get_last_err_data(uv_loop: *libc::c_void) -> uv_err_data { { err_name: err_name, err_msg: err_msg } } -type uv_err_data = { +pub type uv_err_data = { err_name: ~str, err_msg: ~str }; -unsafe fn is_ipv4_addrinfo(input: *addrinfo) -> bool { +pub unsafe fn is_ipv4_addrinfo(input: *addrinfo) -> bool { rustrt::rust_uv_is_ipv4_addrinfo(input) } -unsafe fn is_ipv6_addrinfo(input: *addrinfo) -> bool { +pub unsafe fn is_ipv6_addrinfo(input: *addrinfo) -> bool { rustrt::rust_uv_is_ipv6_addrinfo(input) } -unsafe fn get_INADDR_NONE() -> u32 { +pub unsafe fn get_INADDR_NONE() -> u32 { rustrt::rust_uv_helper_get_INADDR_NONE() } -unsafe fn get_next_addrinfo(input: *addrinfo) -> *addrinfo { +pub unsafe fn get_next_addrinfo(input: *addrinfo) -> *addrinfo { rustrt::rust_uv_get_next_addrinfo(input) } -unsafe fn addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in { +pub unsafe fn addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in { rustrt::rust_uv_addrinfo_as_sockaddr_in(input) } -unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 { +pub unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 { rustrt::rust_uv_addrinfo_as_sockaddr_in6(input) } #[cfg(test)] -mod test { - #[legacy_exports]; +pub mod test { + enum tcp_read_data { tcp_read_eof, tcp_read_more(~[u8]), @@ -1510,22 +1504,19 @@ mod test { #[cfg(target_os="win32")] #[cfg(target_os="darwin")] #[cfg(target_os="linux")] - mod tcp_and_server_client_test { - #[legacy_exports]; + pub mod tcp_and_server_client_test { #[cfg(target_arch="x86_64")] - mod impl64 { - #[legacy_exports]; + pub mod impl64 { #[test] - fn test_uv_ll_tcp_server_and_request() unsafe { + pub fn test_uv_ll_tcp_server_and_request() unsafe { impl_uv_tcp_server_and_request(); } } #[cfg(target_arch="x86")] - mod impl32 { - #[legacy_exports]; + pub mod impl32 { #[test] #[ignore(cfg(target_os = "linux"))] - fn test_uv_ll_tcp_server_and_request() unsafe { + pub fn test_uv_ll_tcp_server_and_request() unsafe { impl_uv_tcp_server_and_request(); } } -- cgit 1.4.1-3-g733a5 From 201513e8590bfc627546054f5ce317add7eef1e6 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 2 Oct 2012 12:02:59 -0700 Subject: De-export std::{fun_treemap, list, map}. Part of #3583. --- src/libstd/fun_treemap.rs | 16 +++++----------- src/libstd/list.rs | 26 +++++++++++++------------- src/libstd/map.rs | 32 ++++++++++++-------------------- src/libstd/std.rc | 3 --- 4 files changed, 30 insertions(+), 47 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 6388e8983d2..2973c8cc9f7 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -15,13 +15,7 @@ use core::cmp::{Eq, Ord}; use option::{Some, None}; use option = option; -export Treemap; -export init; -export insert; -export find; -export traverse; - -type Treemap = @TreeNode; +pub type Treemap = @TreeNode; enum TreeNode { Empty, @@ -29,10 +23,10 @@ enum TreeNode { } /// Create a treemap -fn init() -> Treemap { @Empty } +pub fn init() -> Treemap { @Empty } /// Insert a value into the map -fn insert(m: Treemap, +k: K, +v: V) +pub fn insert(m: Treemap, +k: K, +v: V) -> Treemap { @match m { @Empty => Node(@k, @v, @Empty, @Empty), @@ -47,7 +41,7 @@ fn insert(m: Treemap, +k: K, +v: V) } /// Find a value based on the key -fn find(m: Treemap, +k: K) -> Option { +pub fn find(m: Treemap, +k: K) -> Option { match *m { Empty => None, Node(@ref kk, @copy v, left, right) => { @@ -59,7 +53,7 @@ fn find(m: Treemap, +k: K) -> Option { } /// Visit all pairs in the map in order. -fn traverse(m: Treemap, f: fn((&K), (&V))) { +pub fn traverse(m: Treemap, f: fn((&K), (&V))) { match *m { Empty => (), /* diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 2a7019f5a58..5b0931ebdee 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -6,13 +6,13 @@ use core::option; use option::*; use option::{Some, None}; -enum List { +pub enum List { Cons(T, @List), Nil, } /// Cregate a list from a vector -fn from_vec(v: &[T]) -> @List { +pub fn from_vec(v: &[T]) -> @List { vec::foldr(v, @Nil::, |h, t| @Cons(*h, t)) } @@ -29,7 +29,7 @@ fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { +pub fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -42,7 +42,7 @@ fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -fn find(ls: @List, f: fn((&T)) -> bool) -> Option { +pub fn find(ls: @List, f: fn((&T)) -> bool) -> Option { let mut ls = ls; loop { ls = match *ls { @@ -56,7 +56,7 @@ fn find(ls: @List, f: fn((&T)) -> bool) -> Option { } /// Returns true if a list contains an element with the given value -fn has(ls: @List, +elt: T) -> bool { +pub fn has(ls: @List, +elt: T) -> bool { for each(ls) |e| { if *e == elt { return true; } } @@ -64,7 +64,7 @@ fn has(ls: @List, +elt: T) -> bool { } /// Returns true if the list is empty -pure fn is_empty(ls: @List) -> bool { +pub pure fn is_empty(ls: @List) -> bool { match *ls { Nil => true, _ => false @@ -72,19 +72,19 @@ pure fn is_empty(ls: @List) -> bool { } /// Returns true if the list is not empty -pure fn is_not_empty(ls: @List) -> bool { +pub pure fn is_not_empty(ls: @List) -> bool { return !is_empty(ls); } /// Returns the length of a list -fn len(ls: @List) -> uint { +pub fn len(ls: @List) -> uint { let mut count = 0u; iter(ls, |_e| count += 1u); count } /// Returns all but the first element of a list -pure fn tail(ls: @List) -> @List { +pub pure fn tail(ls: @List) -> @List { match *ls { Cons(_, tl) => return tl, Nil => fail ~"list empty" @@ -92,7 +92,7 @@ pure fn tail(ls: @List) -> @List { } /// Returns the first element of a list -pure fn head(ls: @List) -> T { +pub pure fn head(ls: @List) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad @@ -101,7 +101,7 @@ pure fn head(ls: @List) -> T { } /// Appends one list to another -pure fn append(l: @List, m: @List) -> @List { +pub pure fn append(l: @List, m: @List) -> @List { match *l { Nil => return m, Cons(copy x, xs) => { @@ -120,7 +120,7 @@ pure fn push(ll: &mut @list, +vv: T) { */ /// Iterate over a list -fn iter(l: @List, f: fn((&T))) { +pub fn iter(l: @List, f: fn((&T))) { let mut cur = l; loop { cur = match *cur { @@ -134,7 +134,7 @@ fn iter(l: @List, f: fn((&T))) { } /// Iterate over a list -fn each(l: @List, f: fn((&T)) -> bool) { +pub fn each(l: @List, f: fn((&T)) -> bool) { let mut cur = l; loop { cur = match *cur { diff --git a/src/libstd/map.rs b/src/libstd/map.rs index fce75cbda75..84fee092562 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -11,16 +11,12 @@ use core::cmp::Eq; use hash::Hash; use to_bytes::IterBytes; -export HashMap, hashfn, eqfn, Set, Map, chained, set_add; -export hash_from_vec; -export vec_from_set; - /// A convenience type to treat a hashmap as a set -type Set = HashMap; +pub type Set = HashMap; -type HashMap = chained::T; +pub type HashMap = chained::T; -trait Map { +pub trait Map { /// Return the number of elements in the map pure fn size() -> uint; @@ -82,10 +78,9 @@ trait Map { } mod util { - #[legacy_exports]; - type Rational = {num: int, den: int}; // : int::positive(*.den); + pub type Rational = {num: int, den: int}; // : int::positive(*.den); - pure fn rational_leq(x: Rational, y: Rational) -> bool { + pub pure fn rational_leq(x: Rational, y: Rational) -> bool { // NB: Uses the fact that rationals have positive denominators WLOG: x.num * y.den <= y.num * x.den @@ -95,9 +90,7 @@ mod util { // FIXME (#2344): package this up and export it as a datatype usable for // external code that doesn't want to pay the cost of a box. -mod chained { - #[legacy_exports]; - export T, mk, HashMap; +pub mod chained { const initial_capacity: uint = 32u; // 2^5 @@ -113,7 +106,7 @@ mod chained { mut chains: ~[mut Option<@Entry>] } - type T = @HashMap_; + pub type T = @HashMap_; enum SearchResult { NotFound, @@ -366,7 +359,7 @@ mod chained { vec::to_mut(vec::from_elem(nchains, None)) } - fn mk() -> T { + pub fn mk() -> T { let slf: T = @HashMap_ {count: 0u, chains: chains(initial_capacity)}; slf @@ -378,18 +371,18 @@ Function: hashmap Construct a hashmap. */ -fn HashMap() +pub fn HashMap() -> HashMap { chained::mk() } /// Convenience function for adding keys to a hashmap with nil type keys -fn set_add(set: Set, +key: K) -> bool { +pub fn set_add(set: Set, +key: K) -> bool { set.insert(key, ()) } /// Convert a set into a vector. -fn vec_from_set(s: Set) -> ~[T] { +pub fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.size()) |push| { for s.each_key() |k| { push(k); @@ -398,7 +391,7 @@ fn vec_from_set(s: Set) -> ~[T] { } /// Construct a hashmap from a vector -fn hash_from_vec( +pub fn hash_from_vec( items: &[(K, V)]) -> HashMap { let map = HashMap(); for vec::each(items) |item| { @@ -517,7 +510,6 @@ impl @Mut>: #[cfg(test)] mod tests { - #[legacy_exports]; #[test] fn test_simple() { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 4d5eefec053..4831ac993a2 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -77,11 +77,8 @@ mod comm; mod bitv; mod deque; -#[legacy_exports] mod fun_treemap; -#[legacy_exports] mod list; -#[legacy_exports] mod map; mod rope; mod smallintmap; -- cgit 1.4.1-3-g733a5 From 92841793114d7e60e3227d9087dc8741e7592789 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 2 Oct 2012 12:19:04 -0700 Subject: libstd: Switch off legacy modes in both core and std. --- src/cargo/cargo.rs | 4 +- src/fuzzer/fuzzer.rs | 2 +- src/libcore/cast.rs | 2 +- src/libcore/comm.rs | 4 +- src/libcore/core.rc | 1 - src/libcore/os.rs | 4 +- src/libcore/ptr.rs | 2 +- src/libcore/rand.rs | 4 +- src/libcore/stackwalk.rs | 7 ++- src/libstd/ebml.rs | 8 +-- src/libstd/serialization.rs | 72 +++++++++++----------- src/libstd/std.rc | 1 - src/libsyntax/ast.rs | 24 ++++---- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/parse/obsolete.rs | 2 +- src/rt/rust_builtin.cpp | 10 +++ src/rt/rustrt.def.in | 2 + src/rustc/middle/borrowck.rs | 2 +- src/rustc/middle/trans/common.rs | 4 +- src/rustc/middle/trans/datum.rs | 2 +- src/rustc/middle/ty.rs | 38 ++++++------ .../middle/typeck/infer/region_var_bindings.rs | 4 +- src/test/bench/graph500-bfs.rs | 2 +- src/test/bench/shootout-mandelbrot.rs | 2 +- 24 files changed, 108 insertions(+), 97 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 6136652c873..81c0ce9a5b7 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -144,7 +144,7 @@ fn is_uuid(id: ~str) -> bool { if vec::len(parts) == 5u { let mut correct = 0u; for vec::eachi(parts) |i, part| { - fn is_hex_digit(ch: char) -> bool { + fn is_hex_digit(+ch: char) -> bool { ('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F') @@ -402,7 +402,7 @@ fn need_dir(s: &Path) { } fn valid_pkg_name(s: &str) -> bool { - fn is_valid_digit(c: char) -> bool { + fn is_valid_digit(+c: char) -> bool { ('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index ace96c389ef..cd312362d6a 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -221,7 +221,7 @@ fn under(n: uint, it: fn(uint)) { while i < n { it(i); i += 1u; } } -fn as_str(f: fn@(io::Writer)) -> ~str { +fn as_str(f: fn@(+x: io::Writer)) -> ~str { io::with_str_writer(f) } diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 714c85c75c3..21f5861b89e 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -3,7 +3,7 @@ #[abi = "rust-intrinsic"] extern mod rusti { fn forget(-x: T); - fn reinterpret_cast(e: T) -> U; + fn reinterpret_cast(&&e: T) -> U; } /// Casts the value at `src` to U. The two types must have the same length. diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 81b648d9840..ff9f9498a98 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -33,7 +33,7 @@ will once again be the preferred module for intertask communication. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +#[warn(deprecated_mode)]; #[forbid(deprecated_pattern)]; use either::Either; @@ -166,7 +166,7 @@ fn as_raw_port(ch: comm::Chan, f: fn(*rust_port) -> U) -> U { * Constructs a channel. The channel is bound to the port used to * construct it. */ -pub fn Chan(p: Port) -> Chan { +pub fn Chan(&&p: Port) -> Chan { Chan_(rustrt::get_port_id((**p).po)) } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index c781a26185a..6cada58fa02 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -36,7 +36,6 @@ Implicitly, all crates behave as if they included the following prologue: // Don't link to core. We are core. #[no_core]; -#[legacy_modes]; #[legacy_exports]; #[warn(deprecated_mode)]; diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 1b53a163ad5..1cf4fbab6c9 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -35,7 +35,7 @@ extern mod rustrt { fn rust_getcwd() -> ~str; fn rust_path_is_dir(path: *libc::c_char) -> c_int; fn rust_path_exists(path: *libc::c_char) -> c_int; - fn rust_list_files(path: ~str) -> ~[~str]; + fn rust_list_files2(&&path: ~str) -> ~[~str]; fn rust_process_wait(handle: c_int) -> c_int; fn last_os_error() -> ~str; fn rust_set_exit_status(code: libc::intptr_t); @@ -582,7 +582,7 @@ pub fn list_dir(p: &Path) -> ~[~str] { #[cfg(windows)] fn star(p: &Path) -> Path { p.push("*") } - do rustrt::rust_list_files(star(p).to_str()).filter |filename| { + do rustrt::rust_list_files2(star(p).to_str()).filter |filename| { *filename != ~"." && *filename != ~".." } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 550b0121e45..fad7eddd2d8 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -21,7 +21,7 @@ extern mod libc_ { #[abi = "rust-intrinsic"] extern mod rusti { - fn addr_of(val: T) -> *T; + fn addr_of(&&val: T) -> *T; } /// Get an unsafe pointer to a value diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 501afc0c4bc..f6b7dfa568c 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -11,7 +11,7 @@ enum rctx {} extern mod rustrt { fn rand_seed() -> ~[u8]; fn rand_new() -> *rctx; - fn rand_new_seeded(seed: ~[u8]) -> *rctx; + fn rand_new_seeded2(&&seed: ~[u8]) -> *rctx; fn rand_next(c: *rctx) -> u32; fn rand_free(c: *rctx); } @@ -276,7 +276,7 @@ pub fn Rng() -> Rng { * length. */ pub fn seeded_rng(seed: &~[u8]) -> Rng { - @RandRes(rustrt::rand_new_seeded(*seed)) as Rng + @RandRes(rustrt::rand_new_seeded2(*seed)) as Rng } type XorShiftState = { diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 4cc91b8b425..d0f8de136e2 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -1,7 +1,8 @@ #[doc(hidden)]; // FIXME #3538 // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// XXX: Can't do this because frame_address needs a deprecated mode. +//#[forbid(deprecated_mode)]; #[forbid(deprecated_pattern)]; use cast::reinterpret_cast; @@ -74,7 +75,7 @@ fn breakpoint() { rustrt::rust_dbg_breakpoint() } -fn frame_address(f: fn(*u8)) { +fn frame_address(f: fn(++x: *u8)) { rusti::frame_address(f) } @@ -86,5 +87,5 @@ extern mod rustrt { #[abi = "rust-intrinsic"] extern mod rusti { #[legacy_exports]; - fn frame_address(f: fn(*u8)); + fn frame_address(f: fn(++x: *u8)); } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index b88142e9502..7c5b7929f84 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -588,11 +588,11 @@ impl EbmlDeserializer: serialization::Deserializer { #[test] fn test_option_int() { - fn serialize_1(s: S, v: int) { + fn serialize_1(&&s: S, v: int) { s.emit_i64(v as i64); } - fn serialize_0(s: S, v: Option) { + fn serialize_0(&&s: S, v: Option) { do s.emit_enum(~"core::option::t") { match v { None => s.emit_enum_variant( @@ -606,11 +606,11 @@ fn test_option_int() { } } - fn deserialize_1(s: S) -> int { + fn deserialize_1(&&s: S) -> int { s.read_i64() as int } - fn deserialize_0(s: S) -> Option { + fn deserialize_0(&&s: S) -> Option { do s.read_enum(~"core::option::t") { do s.read_enum_variant |i| { match i { diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index 7cf7779f13d..e9067bc6404 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -81,7 +81,7 @@ trait Deserializer { // // In some cases, these should eventually be coded as traits. -fn emit_from_vec(s: S, v: ~[T], f: fn(T)) { +fn emit_from_vec(&&s: S, &&v: ~[T], f: fn(&&x: T)) { do s.emit_vec(vec::len(v)) { for vec::eachi(v) |i,e| { do s.emit_vec_elt(i) { @@ -91,7 +91,7 @@ fn emit_from_vec(s: S, v: ~[T], f: fn(T)) { } } -fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { +fn read_to_vec(&&d: D, f: fn() -> T) -> ~[T] { do d.read_vec |len| { do vec::from_fn(len) |i| { d.read_vec_elt(i, || f()) @@ -100,11 +100,11 @@ fn read_to_vec(d: D, f: fn() -> T) -> ~[T] { } trait SerializerHelpers { - fn emit_from_vec(v: ~[T], f: fn(T)); + fn emit_from_vec(&&v: ~[T], f: fn(&&x: T)); } impl S: SerializerHelpers { - fn emit_from_vec(v: ~[T], f: fn(T)) { + fn emit_from_vec(&&v: ~[T], f: fn(&&x: T)) { emit_from_vec(self, v, f) } } @@ -119,127 +119,127 @@ impl D: DeserializerHelpers { } } -fn serialize_uint(s: S, v: uint) { +fn serialize_uint(&&s: S, v: uint) { s.emit_uint(v); } -fn deserialize_uint(d: D) -> uint { +fn deserialize_uint(&&d: D) -> uint { d.read_uint() } -fn serialize_u8(s: S, v: u8) { +fn serialize_u8(&&s: S, v: u8) { s.emit_u8(v); } -fn deserialize_u8(d: D) -> u8 { +fn deserialize_u8(&&d: D) -> u8 { d.read_u8() } -fn serialize_u16(s: S, v: u16) { +fn serialize_u16(&&s: S, v: u16) { s.emit_u16(v); } -fn deserialize_u16(d: D) -> u16 { +fn deserialize_u16(&&d: D) -> u16 { d.read_u16() } -fn serialize_u32(s: S, v: u32) { +fn serialize_u32(&&s: S, v: u32) { s.emit_u32(v); } -fn deserialize_u32(d: D) -> u32 { +fn deserialize_u32(&&d: D) -> u32 { d.read_u32() } -fn serialize_u64(s: S, v: u64) { +fn serialize_u64(&&s: S, v: u64) { s.emit_u64(v); } -fn deserialize_u64(d: D) -> u64 { +fn deserialize_u64(&&d: D) -> u64 { d.read_u64() } -fn serialize_int(s: S, v: int) { +fn serialize_int(&&s: S, v: int) { s.emit_int(v); } -fn deserialize_int(d: D) -> int { +fn deserialize_int(&&d: D) -> int { d.read_int() } -fn serialize_i8(s: S, v: i8) { +fn serialize_i8(&&s: S, v: i8) { s.emit_i8(v); } -fn deserialize_i8(d: D) -> i8 { +fn deserialize_i8(&&d: D) -> i8 { d.read_i8() } -fn serialize_i16(s: S, v: i16) { +fn serialize_i16(&&s: S, v: i16) { s.emit_i16(v); } -fn deserialize_i16(d: D) -> i16 { +fn deserialize_i16(&&d: D) -> i16 { d.read_i16() } -fn serialize_i32(s: S, v: i32) { +fn serialize_i32(&&s: S, v: i32) { s.emit_i32(v); } -fn deserialize_i32(d: D) -> i32 { +fn deserialize_i32(&&d: D) -> i32 { d.read_i32() } -fn serialize_i64(s: S, v: i64) { +fn serialize_i64(&&s: S, v: i64) { s.emit_i64(v); } -fn deserialize_i64(d: D) -> i64 { +fn deserialize_i64(&&d: D) -> i64 { d.read_i64() } -fn serialize_str(s: S, v: &str) { +fn serialize_str(&&s: S, v: &str) { s.emit_str(v); } -fn deserialize_str(d: D) -> ~str { +fn deserialize_str(&&d: D) -> ~str { d.read_str() } -fn serialize_float(s: S, v: float) { +fn serialize_float(&&s: S, v: float) { s.emit_float(v); } -fn deserialize_float(d: D) -> float { +fn deserialize_float(&&d: D) -> float { d.read_float() } -fn serialize_f32(s: S, v: f32) { +fn serialize_f32(&&s: S, v: f32) { s.emit_f32(v); } -fn deserialize_f32(d: D) -> f32 { +fn deserialize_f32(&&d: D) -> f32 { d.read_f32() } -fn serialize_f64(s: S, v: f64) { +fn serialize_f64(&&s: S, v: f64) { s.emit_f64(v); } -fn deserialize_f64(d: D) -> f64 { +fn deserialize_f64(&&d: D) -> f64 { d.read_f64() } -fn serialize_bool(s: S, v: bool) { +fn serialize_bool(&&s: S, v: bool) { s.emit_bool(v); } -fn deserialize_bool(d: D) -> bool { +fn deserialize_bool(&&d: D) -> bool { d.read_bool() } -fn serialize_Option(s: S, v: Option, st: fn(T)) { +fn serialize_Option(&&s: S, &&v: Option, st: fn(&&x: T)) { do s.emit_enum(~"option") { match v { None => do s.emit_enum_variant(~"none", 0u, 0u) { @@ -254,7 +254,7 @@ fn serialize_Option(s: S, v: Option, st: fn(T)) { } } -fn deserialize_Option(d: D, st: fn() -> T) +fn deserialize_Option(&&d: D, st: fn() -> T) -> Option { do d.read_enum(~"option") { do d.read_enum_variant |i| { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 4831ac993a2..aa26c4af29c 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -18,7 +18,6 @@ not required in or otherwise suitable for the core library. #[no_core]; -#[legacy_modes]; #[legacy_exports]; #[allow(vecs_implicitly_copyable)]; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 67841158ce1..e17b52fb27d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -69,7 +69,7 @@ impl ident: cmp::Eq { } impl ident: to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { self.repr.iter_bytes(lsb0, f) } } @@ -328,7 +328,7 @@ enum binding_mode { } impl binding_mode : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { bind_by_value => 0u8.iter_bytes(lsb0, f), @@ -402,7 +402,7 @@ enum pat_ { enum mutability { m_mutbl, m_imm, m_const, } impl mutability : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -541,7 +541,7 @@ enum inferable { } impl inferable : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { expl(ref t) => to_bytes::iter_bytes_2(&0u8, t, lsb0, f), @@ -577,7 +577,7 @@ impl inferable : cmp::Eq { enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy } impl rmode : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -937,7 +937,7 @@ enum trait_method { enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, } impl int_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -966,7 +966,7 @@ impl int_ty : cmp::Eq { enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, } impl uint_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -993,7 +993,7 @@ impl uint_ty : cmp::Eq { enum float_ty { ty_f, ty_f32, ty_f64, } impl float_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -1102,7 +1102,7 @@ impl ty : cmp::Eq { } impl ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.span.lo, &self.span.hi, lsb0, f); } } @@ -1126,7 +1126,7 @@ enum purity { } impl purity : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -1146,7 +1146,7 @@ enum ret_style { } impl ret_style : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -1443,7 +1443,7 @@ enum item_ { enum class_mutability { class_mutable, class_immutable } impl class_mutability : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 2431947184d..e8099de246c 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -254,7 +254,7 @@ pure fn is_call_expr(e: @expr) -> bool { // This makes def_id hashable impl def_id : core::to_bytes::IterBytes { #[inline(always)] - pure fn iter_bytes(lsb0: bool, f: core::to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: core::to_bytes::Cb) { core::to_bytes::iter_bytes_2(&self.crate, &self.node, lsb0, f); } } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 9cfa84ad9e0..782535f5c2b 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -36,7 +36,7 @@ impl ObsoleteSyntax : cmp::Eq { impl ObsoleteSyntax: to_bytes::IterBytes { #[inline(always)] - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as uint).iter_bytes(lsb0, f); } } diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 91c5760d3e9..6f985601f8b 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -180,6 +180,11 @@ rand_new_seeded(rust_vec_box* seed) { return rctx; } +extern "C" CDECL void * +rand_new_seeded2(rust_vec_box** seed) { + return rand_new_seeded(*seed); +} + extern "C" CDECL size_t rand_next(randctx *rctx) { return isaac_rand(rctx); @@ -371,6 +376,11 @@ rust_list_files(rust_str *path) { return vec; } +extern "C" CDECL rust_vec_box* +rust_list_files2(rust_str **path) { + return rust_list_files(*path); +} + extern "C" CDECL int rust_path_is_dir(char *path) { struct stat buf; diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 43f24f4dd4f..551378a3d6c 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -27,6 +27,7 @@ rust_port_select rand_free rand_new rand_new_seeded +rand_new_seeded2 rand_next rand_seed rust_get_sched_id @@ -40,6 +41,7 @@ rust_get_stdin rust_get_stdout rust_get_stderr rust_list_files +rust_list_files2 rust_log_console_on rust_log_console_off rust_port_begin_detach diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 4906eb4a0a3..414890cbd7c 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -415,7 +415,7 @@ impl root_map_key : cmp::Eq { } impl root_map_key : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f); } } diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index d68bdb08221..6768f3e71a0 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -1142,7 +1142,7 @@ impl mono_id_ : cmp::Eq { } impl mono_param_id : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { mono_precise(t, mids) => to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), &mids, lsb0, f), @@ -1156,7 +1156,7 @@ impl mono_param_id : to_bytes::IterBytes { } impl mono_id_ : core::to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f); } } diff --git a/src/rustc/middle/trans/datum.rs b/src/rustc/middle/trans/datum.rs index 59e8cd72025..241fa5e53af 100644 --- a/src/rustc/middle/trans/datum.rs +++ b/src/rustc/middle/trans/datum.rs @@ -146,7 +146,7 @@ impl DatumMode: cmp::Eq { } impl DatumMode: to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as uint).iter_bytes(lsb0, f) } } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 973db90ff66..a96388e9d77 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -248,7 +248,7 @@ impl creader_cache_key : cmp::Eq { } impl creader_cache_key : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f); } } @@ -263,7 +263,7 @@ impl intern_key : cmp::Eq { } impl intern_key : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.sty, &self.o_def_id, lsb0, f); } } @@ -406,7 +406,7 @@ enum closure_kind { } impl closure_kind : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (self as u8).iter_bytes(lsb0, f) } } @@ -424,7 +424,7 @@ enum fn_proto { } impl fn_proto : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { proto_bare => 0u8.iter_bytes(lsb0, f), @@ -502,7 +502,7 @@ impl param_ty : cmp::Eq { } impl param_ty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f) } } @@ -676,7 +676,7 @@ enum InferTy { } impl InferTy : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f), IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f) @@ -685,7 +685,7 @@ impl InferTy : to_bytes::IterBytes { } impl param_bound : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { bound_copy => 0u8.iter_bytes(lsb0, f), bound_owned => 1u8.iter_bytes(lsb0, f), @@ -749,25 +749,25 @@ impl purity: purity_to_str { } impl RegionVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } impl TyVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } impl IntVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } impl FnVid : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { (*self).iter_bytes(lsb0, f) } } @@ -2505,7 +2505,7 @@ fn index_sty(cx: ctxt, sty: &sty) -> Option { } impl bound_region : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { ty::br_self => 0u8.iter_bytes(lsb0, f), @@ -2522,7 +2522,7 @@ impl bound_region : to_bytes::IterBytes { } impl region : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { re_bound(ref br) => to_bytes::iter_bytes_2(&0u8, br, lsb0, f), @@ -2542,7 +2542,7 @@ impl region : to_bytes::IterBytes { } impl vstore : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { vstore_fixed(ref u) => to_bytes::iter_bytes_2(&0u8, u, lsb0, f), @@ -2557,7 +2557,7 @@ impl vstore : to_bytes::IterBytes { } impl substs : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_3(&self.self_r, &self.self_ty, &self.tps, lsb0, f) @@ -2565,28 +2565,28 @@ impl substs : to_bytes::IterBytes { } impl mt : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.ty, &self.mutbl, lsb0, f) } } impl field : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.ident, &self.mt, lsb0, f) } } impl arg : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.mode, &self.ty, lsb0, f) } } impl sty : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { ty_nil => 0u8.iter_bytes(lsb0, f), ty_bool => 1u8.iter_bytes(lsb0, f), diff --git a/src/rustc/middle/typeck/infer/region_var_bindings.rs b/src/rustc/middle/typeck/infer/region_var_bindings.rs index c86850e19d2..8bbdab74d23 100644 --- a/src/rustc/middle/typeck/infer/region_var_bindings.rs +++ b/src/rustc/middle/typeck/infer/region_var_bindings.rs @@ -350,7 +350,7 @@ impl Constraint : cmp::Eq { } impl Constraint : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { match self { ConstrainVarSubVar(ref v0, ref v1) => to_bytes::iter_bytes_3(&0u8, v0, v1, lsb0, f), @@ -377,7 +377,7 @@ impl TwoRegions : cmp::Eq { } impl TwoRegions : to_bytes::IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f) } } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index f35a3ce735f..a34fcc89c04 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(i: uint, c: color) -> color { + fn~(+i: uint, +c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index d9859d54648..ee38b957b0c 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -94,7 +94,7 @@ type devnull = {dn: int}; impl devnull: io::Writer { fn write(_b: &[const u8]) {} - fn seek(_i: int, _s: io::SeekStyle) {} + fn seek(+_i: int, +_s: io::SeekStyle) {} fn tell() -> uint {0_u} fn flush() -> int {0} fn get_type() -> io::WriterType { io::File } -- cgit 1.4.1-3-g733a5 From f78cdcb6364cf938bfeb71da0c7eca62e257d537 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Tue, 2 Oct 2012 11:37:37 -0700 Subject: Removing explicit uses of + mode This removes most explicit uses of the + argument mode. Pending a snapshot, I had to remove the forbid(deprecated_modes) pragma from a bunch of files. I'll put it back! + mode still has to be used in a few places for functions that get moved (see task.rs) The changes outside core and std are due to the to_bytes trait and making the compiler (with legacy modes on) agree with the libraries (with legacy modes off) about modes. --- src/libcore/at_vec.rs | 18 +++---- src/libcore/cast.rs | 18 +++---- src/libcore/comm.rs | 10 ++-- src/libcore/dlist.rs | 32 ++++++------- src/libcore/dvec.rs | 28 +++++------ src/libcore/either.rs | 7 +-- src/libcore/extfmt.rs | 10 ++-- src/libcore/future.rs | 6 +-- src/libcore/int-template.rs | 4 +- src/libcore/io.rs | 18 +++---- src/libcore/iter-trait.rs | 10 ++-- src/libcore/iter.rs | 27 +++++------ src/libcore/mutable.rs | 7 ++- src/libcore/ops.rs | 2 +- src/libcore/option.rs | 32 ++++++------- src/libcore/os.rs | 6 +-- src/libcore/pipes.rs | 68 +++++++++++++------------- src/libcore/private.rs | 10 ++-- src/libcore/reflect.rs | 2 +- src/libcore/result.rs | 18 +++---- src/libcore/run.rs | 6 +-- src/libcore/send_map.rs | 8 ++-- src/libcore/stackwalk.rs | 2 + src/libcore/str.rs | 2 +- src/libcore/sys.rs | 2 +- src/libcore/task.rs | 16 +++---- src/libcore/task/local_data.rs | 32 ++++++------- src/libcore/task/local_data_priv.rs | 2 +- src/libcore/task/spawn.rs | 20 ++++---- src/libcore/util.rs | 10 ++-- src/libcore/vec.rs | 96 ++++++++++++++++++------------------- src/libstd/getopts.rs | 2 +- src/libstd/net_tcp.rs | 8 ++-- src/libstd/net_url.rs | 2 +- src/libstd/rope.rs | 4 +- src/libstd/std.rc | 3 ++ src/rustc/middle/lint.rs | 8 +++- src/test/bench/graph500-bfs.rs | 2 +- 38 files changed, 282 insertions(+), 276 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 6936de2bccb..7d410c0337a 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -1,7 +1,7 @@ //! Managed vectors // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cast::transmute; @@ -48,7 +48,7 @@ pub pure fn capacity(v: @[const T]) -> uint { */ #[inline(always)] pub pure fn build_sized(size: uint, - builder: &fn(push: pure fn(+v: A))) -> @[A] { + builder: &fn(push: pure fn(v: A))) -> @[A] { let mut vec: @[const A] = @[]; unsafe { raw::reserve(&mut vec, size); } builder(|+x| unsafe { raw::push(&mut vec, move x) }); @@ -66,7 +66,7 @@ pub pure fn build_sized(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build(builder: &fn(push: pure fn(+v: A))) -> @[A] { +pub pure fn build(builder: &fn(push: pure fn(v: A))) -> @[A] { build_sized(4, builder) } @@ -83,8 +83,8 @@ pub pure fn build(builder: &fn(push: pure fn(+v: A))) -> @[A] { * onto the vector being constructed. */ #[inline(always)] -pub pure fn build_sized_opt(+size: Option, - builder: &fn(push: pure fn(+v: A))) -> @[A] { +pub pure fn build_sized_opt(size: Option, + builder: &fn(push: pure fn(v: A))) -> @[A] { build_sized(size.get_default(4), builder) } @@ -126,7 +126,7 @@ pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> @[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem(n_elts: uint, +t: T) -> @[T] { +pub pure fn from_elem(n_elts: uint, t: T) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(copy t); i += 1u; } @@ -166,7 +166,7 @@ pub mod raw { } #[inline(always)] - pub unsafe fn push(v: &mut @[const T], +initval: T) { + pub unsafe fn push(v: &mut @[const T], initval: T) { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; if (**repr).unboxed.alloc > fill { @@ -178,7 +178,7 @@ pub mod raw { } // This doesn't bother to make sure we have space. #[inline(always)] // really pretty please - pub unsafe fn push_fast(v: &mut @[const T], +initval: T) { + pub unsafe fn push_fast(v: &mut @[const T], initval: T) { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::(); @@ -187,7 +187,7 @@ pub mod raw { rusti::move_val_init(*p, move initval); } - pub unsafe fn push_slow(v: &mut @[const T], +initval: T) { + pub unsafe fn push_slow(v: &mut @[const T], initval: T) { reserve_at_least(v, v.len() + 1u); push_fast(v, move initval); } diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index 21f5861b89e..f4f0d7b6104 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -21,7 +21,7 @@ pub unsafe fn reinterpret_cast(src: &T) -> U { * reinterpret_cast on managed pointer types. */ #[inline(always)] -pub unsafe fn forget(+thing: T) { rusti::forget(move thing); } +pub unsafe fn forget(thing: T) { rusti::forget(move thing); } /** * Force-increment the reference count on a shared box. If used @@ -29,7 +29,7 @@ pub unsafe fn forget(+thing: T) { rusti::forget(move thing); } * and/or reinterpret_cast when such calls would otherwise scramble a box's * reference count */ -pub unsafe fn bump_box_refcount(+t: @T) { forget(move t); } +pub unsafe fn bump_box_refcount(t: @T) { forget(move t); } /** * Transform a value of one type into a value of another type. @@ -40,7 +40,7 @@ pub unsafe fn bump_box_refcount(+t: @T) { forget(move t); } * assert transmute("L") == ~[76u8, 0u8]; */ #[inline(always)] -pub unsafe fn transmute(+thing: L) -> G { +pub unsafe fn transmute(thing: L) -> G { let newthing: G = reinterpret_cast(&thing); forget(move thing); move newthing @@ -48,33 +48,33 @@ pub unsafe fn transmute(+thing: L) -> G { /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_mut(+ptr: &a/T) -> &a/mut T { transmute(move ptr) } +pub unsafe fn transmute_mut(ptr: &a/T) -> &a/mut T { transmute(move ptr) } /// Coerce a mutable reference to be immutable. #[inline(always)] -pub unsafe fn transmute_immut(+ptr: &a/mut T) -> &a/T { +pub unsafe fn transmute_immut(ptr: &a/mut T) -> &a/T { transmute(move ptr) } /// Coerce a borrowed pointer to have an arbitrary associated region. #[inline(always)] -pub unsafe fn transmute_region(+ptr: &a/T) -> &b/T { transmute(move ptr) } +pub unsafe fn transmute_region(ptr: &a/T) -> &b/T { transmute(move ptr) } /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_mut_unsafe(+ptr: *const T) -> *mut T { +pub unsafe fn transmute_mut_unsafe(ptr: *const T) -> *mut T { transmute(ptr) } /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_immut_unsafe(+ptr: *const T) -> *T { +pub unsafe fn transmute_immut_unsafe(ptr: *const T) -> *T { transmute(ptr) } /// Coerce a borrowed mutable pointer to have an arbitrary associated region. #[inline(always)] -pub unsafe fn transmute_mut_region(+ptr: &a/mut T) -> &b/mut T { +pub unsafe fn transmute_mut_region(ptr: &a/mut T) -> &b/mut T { transmute(move ptr) } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index ff9f9498a98..64c38d13e49 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -32,8 +32,8 @@ will once again be the preferred module for intertask communication. */ -// NB: transitionary, de-mode-ing. -#[warn(deprecated_mode)]; +// NB: transitionary, de-mode-ing +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use either::Either; @@ -75,7 +75,7 @@ pub fn Port() -> Port { impl Port { fn chan() -> Chan { Chan(self) } - fn send(+v: T) { self.chan().send(move v) } + fn send(v: T) { self.chan().send(move v) } fn recv() -> T { recv(self) } fn peek() -> bool { peek(self) } @@ -84,7 +84,7 @@ impl Port { impl Chan { fn chan() -> Chan { self } - fn send(+v: T) { send(self, move v) } + fn send(v: T) { send(self, move v) } fn recv() -> T { recv_chan(self) } fn peek() -> bool { peek_chan(self) } @@ -174,7 +174,7 @@ pub fn Chan(&&p: Port) -> Chan { * Sends data over a channel. The sent data is moved into the channel, * whereupon the caller loses access to it. */ -pub fn send(ch: Chan, +data: T) { +pub fn send(ch: Chan, data: T) { let Chan_(p) = ch; let data_ptr = ptr::addr_of(&data) as *(); let res = rustrt::rust_port_id_send(p, data_ptr); diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 4e08dd4c2f3..17ddd6ea73b 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -9,7 +9,7 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; type DListLink = Option>; @@ -80,7 +80,7 @@ impl DListNode { } /// Creates a new dlist node with the given data. -pure fn new_dlist_node(+data: T) -> DListNode { +pure fn new_dlist_node(data: T) -> DListNode { DListNode(@{data: move data, mut linked: false, mut prev: None, mut next: None}) } @@ -91,13 +91,13 @@ pure fn DList() -> DList { } /// Creates a new dlist with a single element -pub pure fn from_elem(+data: T) -> DList { +pub pure fn from_elem(data: T) -> DList { let list = DList(); unsafe { list.push(move data); } list } -pub fn from_vec(+vec: &[T]) -> DList { +pub fn from_vec(vec: &[T]) -> DList { do vec::foldl(DList(), vec) |list,data| { list.push(*data); // Iterating left-to-right -- add newly to the tail. list @@ -115,7 +115,7 @@ fn concat(lists: DList>) -> DList { } priv impl DList { - pure fn new_link(+data: T) -> DListLink { + pure fn new_link(data: T) -> DListLink { Some(DListNode(@{data: move data, mut linked: true, mut prev: None, mut next: None})) } @@ -142,7 +142,7 @@ priv impl DList { // Link two nodes together. If either of them are 'none', also sets // the head and/or tail pointers appropriately. #[inline(always)] - fn link(+before: DListLink, +after: DListLink) { + fn link(before: DListLink, after: DListLink) { match before { Some(neighbour) => neighbour.next = after, None => self.hd = after @@ -163,12 +163,12 @@ priv impl DList { self.size -= 1; } - fn add_head(+nobe: DListLink) { + fn add_head(nobe: DListLink) { self.link(nobe, self.hd); // Might set tail too. self.hd = nobe; self.size += 1; } - fn add_tail(+nobe: DListLink) { + fn add_tail(nobe: DListLink) { self.link(self.tl, nobe); // Might set head too. self.tl = nobe; self.size += 1; @@ -198,27 +198,27 @@ impl DList { pure fn is_not_empty() -> bool { self.len() != 0 } /// Add data to the head of the list. O(1). - fn push_head(+data: T) { + fn push_head(data: T) { self.add_head(self.new_link(move data)); } /** * Add data to the head of the list, and get the new containing * node. O(1). */ - fn push_head_n(+data: T) -> DListNode { + fn push_head_n(data: T) -> DListNode { let mut nobe = self.new_link(move data); self.add_head(nobe); option::get(&nobe) } /// Add data to the tail of the list. O(1). - fn push(+data: T) { + fn push(data: T) { self.add_tail(self.new_link(move data)); } /** * Add data to the tail of the list, and get the new containing * node. O(1). */ - fn push_n(+data: T) -> DListNode { + fn push_n(data: T) -> DListNode { let mut nobe = self.new_link(move data); self.add_tail(nobe); option::get(&nobe) @@ -227,7 +227,7 @@ impl DList { * Insert data into the middle of the list, left of the given node. * O(1). */ - fn insert_before(+data: T, neighbour: DListNode) { + fn insert_before(data: T, neighbour: DListNode) { self.insert_left(self.new_link(move data), neighbour); } /** @@ -242,7 +242,7 @@ impl DList { * Insert data in the middle of the list, left of the given node, * and get its containing node. O(1). */ - fn insert_before_n(+data: T, neighbour: DListNode) -> DListNode { + fn insert_before_n(data: T, neighbour: DListNode) -> DListNode { let mut nobe = self.new_link(move data); self.insert_left(nobe, neighbour); option::get(&nobe) @@ -251,7 +251,7 @@ impl DList { * Insert data into the middle of the list, right of the given node. * O(1). */ - fn insert_after(+data: T, neighbour: DListNode) { + fn insert_after(data: T, neighbour: DListNode) { self.insert_right(neighbour, self.new_link(move data)); } /** @@ -266,7 +266,7 @@ impl DList { * Insert data in the middle of the list, right of the given node, * and get its containing node. O(1). */ - fn insert_after_n(+data: T, neighbour: DListNode) -> DListNode { + fn insert_after_n(data: T, neighbour: DListNode) -> DListNode { let mut nobe = self.new_link(move data); self.insert_right(neighbour, nobe); option::get(&nobe) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 3ce5a7153fd..a2a70908797 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -10,7 +10,7 @@ Note that recursive use is not permitted. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cast::reinterpret_cast; @@ -61,17 +61,17 @@ pub fn DVec() -> DVec { } /// Creates a new dvec with a single element -pub fn from_elem(+e: A) -> DVec { +pub fn from_elem(e: A) -> DVec { DVec_({mut data: ~[move e]}) } /// Creates a new dvec with the contents of a vector -pub fn from_vec(+v: ~[A]) -> DVec { +pub fn from_vec(v: ~[A]) -> DVec { DVec_({mut data: move v}) } /// Consumes the vector and returns its contents -pub fn unwrap(+d: DVec) -> ~[A] { +pub fn unwrap(d: DVec) -> ~[A] { let DVec_({data: v}) <- d; move v } @@ -87,7 +87,7 @@ priv impl DVec { } #[inline(always)] - fn check_out(f: &fn(+v: ~[A]) -> B) -> B { + fn check_out(f: &fn(v: ~[A]) -> B) -> B { unsafe { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; @@ -98,7 +98,7 @@ priv impl DVec { } #[inline(always)] - fn give_back(+data: ~[A]) { + fn give_back(data: ~[A]) { unsafe { self.data = move data; } @@ -120,7 +120,7 @@ impl DVec { * and return a new vector to replace it with. */ #[inline(always)] - fn swap(f: &fn(+v: ~[A]) -> ~[A]) { + fn swap(f: &fn(v: ~[A]) -> ~[A]) { self.check_out(|v| self.give_back(f(move v))) } @@ -130,7 +130,7 @@ impl DVec { * and return a new vector to replace it with. */ #[inline(always)] - fn swap_mut(f: &fn(+v: ~[mut A]) -> ~[mut A]) { + fn swap_mut(f: &fn(v: ~[mut A]) -> ~[mut A]) { do self.swap |v| { vec::from_mut(f(vec::to_mut(move v))) } @@ -148,7 +148,7 @@ impl DVec { } /// Overwrite the current contents - fn set(+w: ~[A]) { + fn set(w: ~[A]) { self.check_not_borrowed(); self.data <- w; } @@ -164,7 +164,7 @@ impl DVec { } /// Insert a single item at the front of the list - fn unshift(+t: A) { + fn unshift(t: A) { unsafe { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; @@ -178,7 +178,7 @@ impl DVec { } /// Append a single item to the end of the list - fn push(+t: A) { + fn push(t: A) { self.check_not_borrowed(); self.data.push(move t); } @@ -295,7 +295,7 @@ impl DVec { } /// Overwrites the contents of the element at `idx` with `a` - fn set_elt(idx: uint, +a: A) { + fn set_elt(idx: uint, a: A) { self.check_not_borrowed(); self.data[idx] = a; } @@ -305,7 +305,7 @@ impl DVec { * growing the vector if necessary. New elements will be initialized * with `initval` */ - fn grow_set_elt(idx: uint, initval: &A, +val: A) { + fn grow_set_elt(idx: uint, initval: &A, val: A) { do self.swap |v| { let mut v = move v; v.grow_set(idx, initval, val); @@ -354,7 +354,7 @@ impl DVec { } impl DVec: Index { - pure fn index(+idx: uint) -> A { + pure fn index(idx: uint) -> A { self.get_elt(idx) } } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index dd3bcdfdf88..c64cd25e481 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; //! A type that represents one of two alternatives @@ -114,7 +114,8 @@ pub pure fn is_right(eith: &Either) -> bool { match *eith { Right(_) => true, _ => false } } -pub pure fn unwrap_left(+eith: Either) -> T { +// tjc: fix the next two after a snapshot +pub pure fn unwrap_left(eith: Either) -> T { //! Retrieves the value in the left branch. Fails if the either is Right. match move eith { @@ -122,7 +123,7 @@ pub pure fn unwrap_left(+eith: Either) -> T { } } -pub pure fn unwrap_right(+eith: Either) -> U { +pub pure fn unwrap_right(eith: Either) -> U { //! Retrieves the value in the right branch. Fails if the either is Left. match move eith { diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 25f92e61726..e10ff4bac71 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -87,7 +87,7 @@ mod ct { let mut pieces: ~[Piece] = ~[]; let lim = str::len(s); let mut buf = ~""; - fn flush_buf(+buf: ~str, pieces: &mut ~[Piece]) -> ~str { + fn flush_buf(buf: ~str, pieces: &mut ~[Piece]) -> ~str { if buf.len() > 0 { let piece = PieceString(move buf); pieces.push(move piece); @@ -323,7 +323,7 @@ mod rt { let mut s = str::from_char(c); return unsafe { pad(cv, s, PadNozero) }; } - pure fn conv_str(cv: Conv, +s: &str) -> ~str { + pure fn conv_str(cv: Conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed let mut unpadded = match cv.precision { @@ -405,7 +405,7 @@ mod rt { pure fn ne(other: &PadMode) -> bool { !self.eq(other) } } - fn pad(cv: Conv, +s: ~str, mode: PadMode) -> ~str { + fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str { let mut s = move s; // sadtimes let uwidth : uint = match cv.width { CountImplied => return s, @@ -518,7 +518,7 @@ mod rt2 { let mut s = str::from_char(c); return unsafe { pad(cv, s, PadNozero) }; } - pure fn conv_str(cv: Conv, +s: &str) -> ~str { + pure fn conv_str(cv: Conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed let mut unpadded = match cv.precision { @@ -600,7 +600,7 @@ mod rt2 { pure fn ne(other: &PadMode) -> bool { !self.eq(other) } } - fn pad(cv: Conv, +s: ~str, mode: PadMode) -> ~str { + fn pad(cv: Conv, s: ~str, mode: PadMode) -> ~str { let mut s = move s; // sadtimes let uwidth : uint = match cv.width { CountImplied => return s, diff --git a/src/libcore/future.rs b/src/libcore/future.rs index db311ea3e82..11b6a2c0135 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; /*! @@ -55,7 +55,7 @@ impl Future { } } -pub fn from_value(+val: A) -> Future { +pub fn from_value(val: A) -> Future { /*! * Create a future from a value * @@ -66,7 +66,7 @@ pub fn from_value(+val: A) -> Future { Future {state: Forced(~(move val))} } -pub fn from_port(+port: future_pipe::client::waiting) -> +pub fn from_port(port: future_pipe::client::waiting) -> Future { /*! * Create a future from a port diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index ddd26205000..6942d38d5d3 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use T = inst::T; @@ -231,7 +231,7 @@ fn test_to_str() { #[test] fn test_interfaces() { - fn test(+ten: U) { + fn test(ten: U) { assert (ten.to_int() == 10); let two: U = from_int(2); diff --git a/src/libcore/io.rs b/src/libcore/io.rs index f8f644a17ab..2efc96933da 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -813,7 +813,7 @@ pub mod fsync { } } - pub fn Res(+arg: Arg) -> Res{ + pub fn Res(arg: Arg) -> Res{ Res { arg: move arg } @@ -822,17 +822,17 @@ pub mod fsync { pub type Arg = { val: t, opt_level: Option, - fsync_fn: fn@(+f: t, Level) -> int + fsync_fn: fn@(f: t, Level) -> int }; // fsync file after executing blk // FIXME (#2004) find better way to create resources within lifetime of // outer res pub fn FILE_res_sync(file: &FILERes, opt_level: Option, - blk: fn(+v: Res<*libc::FILE>)) { + blk: fn(v: Res<*libc::FILE>)) { blk(move Res({ val: file.f, opt_level: opt_level, - fsync_fn: fn@(+file: *libc::FILE, l: Level) -> int { + fsync_fn: fn@(file: *libc::FILE, l: Level) -> int { return os::fsync_fd(libc::fileno(file), l) as int; } })); @@ -840,10 +840,10 @@ pub mod fsync { // fsync fd after executing blk pub fn fd_res_sync(fd: &FdRes, opt_level: Option, - blk: fn(+v: Res)) { + blk: fn(v: Res)) { blk(move Res({ val: fd.fd, opt_level: opt_level, - fsync_fn: fn@(+fd: fd_t, l: Level) -> int { + fsync_fn: fn@(fd: fd_t, l: Level) -> int { return os::fsync_fd(fd, l) as int; } })); @@ -853,11 +853,11 @@ pub mod fsync { pub trait FSyncable { fn fsync(l: Level) -> int; } // Call o.fsync after executing blk - pub fn obj_sync(+o: FSyncable, opt_level: Option, - blk: fn(+v: Res)) { + pub fn obj_sync(o: FSyncable, opt_level: Option, + blk: fn(v: Res)) { blk(Res({ val: o, opt_level: opt_level, - fsync_fn: fn@(+o: FSyncable, l: Level) -> int { + fsync_fn: fn@(o: FSyncable, l: Level) -> int { return o.fsync(l); } })); diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index a2fb4698d7c..09bfe2eff36 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -16,7 +16,7 @@ impl IMPL_T: iter::ExtendedIter { pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) } pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) } pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) } - pure fn foldl(+b0: B, blk: fn(&B, &A) -> B) -> B { + pure fn foldl(b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(&self, move b0, blk) } pure fn position(f: fn(&A) -> bool) -> Option { @@ -30,20 +30,20 @@ impl IMPL_T: iter::EqIter { } impl IMPL_T: iter::CopyableIter { - pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A] { + pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] { iter::filter_to_vec(&self, pred) } - pure fn map_to_vec(op: fn(+v: A) -> B) -> ~[B] { + pure fn map_to_vec(op: fn(v: A) -> B) -> ~[B] { iter::map_to_vec(&self, op) } pure fn to_vec() -> ~[A] { iter::to_vec(&self) } - pure fn flat_map_to_vec>(op: fn(+a: A) -> IB) + pure fn flat_map_to_vec>(op: fn(a: A) -> IB) -> ~[B] { iter::flat_map_to_vec(&self, op) } - pure fn find(p: fn(+a: A) -> bool) -> Option { iter::find(&self, p) } + pure fn find(p: fn(a: A) -> bool) -> Option { iter::find(&self, p) } } impl IMPL_T: iter::CopyableOrderedIter { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 5271555d299..bf3e91f7071 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -18,7 +18,7 @@ pub trait ExtendedIter { pure fn eachi(blk: fn(uint, v: &A) -> bool); pure fn all(blk: fn(&A) -> bool) -> bool; pure fn any(blk: fn(&A) -> bool) -> bool; - pure fn foldl(+b0: B, blk: fn(&B, &A) -> B) -> B; + pure fn foldl(b0: B, blk: fn(&B, &A) -> B) -> B; pure fn position(f: fn(&A) -> bool) -> Option; } @@ -36,10 +36,10 @@ pub trait TimesIx{ } pub trait CopyableIter { - pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A]; - pure fn map_to_vec(op: fn(+v: A) -> B) -> ~[B]; + pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A]; + pure fn map_to_vec(op: fn(v: A) -> B) -> ~[B]; pure fn to_vec() -> ~[A]; - pure fn find(p: fn(+a: A) -> bool) -> Option; + pure fn find(p: fn(a: A) -> bool) -> Option; } pub trait CopyableOrderedIter { @@ -64,7 +64,7 @@ pub trait Buildable { * onto the sequence being constructed. */ static pure fn build_sized(size: uint, - builder: fn(push: pure fn(+v: A))) -> self; + builder: fn(push: pure fn(v: A))) -> self; } pub pure fn eachi>(self: &IA, @@ -93,7 +93,7 @@ pub pure fn any>(self: &IA, } pub pure fn filter_to_vec>( - self: &IA, prd: fn(+a: A) -> bool) -> ~[A] { + self: &IA, prd: fn(a: A) -> bool) -> ~[A] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { if prd(*a) { push(*a); } @@ -102,7 +102,7 @@ pub pure fn filter_to_vec>( } pub pure fn map_to_vec>(self: &IA, - op: fn(+v: A) -> B) + op: fn(v: A) -> B) -> ~[B] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { @@ -112,8 +112,7 @@ pub pure fn map_to_vec>(self: &IA, } pub pure fn flat_map_to_vec,IB:BaseIter>( - self: &IA, op: fn(+a: A) -> IB) -> ~[B] { - + self: &IA, op: fn(a: A) -> IB) -> ~[B] { do vec::build |push| { for self.each |a| { for op(*a).each |b| { @@ -123,7 +122,7 @@ pub pure fn flat_map_to_vec,IB:BaseIter>( } } -pub pure fn foldl>(self: &IA, +b0: B, +pub pure fn foldl>(self: &IA, b0: B, blk: fn(&B, &A) -> B) -> B { let mut b <- b0; @@ -206,7 +205,7 @@ pub pure fn max>(self: &IA) -> A { } pub pure fn find>(self: &IA, - p: fn(+a: A) -> bool) -> Option { + p: fn(a: A) -> bool) -> Option { for self.each |i| { if p(*i) { return Some(*i) } } @@ -226,7 +225,7 @@ pub pure fn find>(self: &IA, * onto the sequence being constructed. */ #[inline(always)] -pub pure fn build>(builder: fn(push: pure fn(+v: A))) +pub pure fn build>(builder: fn(push: pure fn(v: A))) -> B { build_sized(4, builder) } @@ -247,7 +246,7 @@ pub pure fn build>(builder: fn(push: pure fn(+v: A))) #[inline(always)] pub pure fn build_sized_opt>( size: Option, - builder: fn(push: pure fn(+v: A))) -> B { + builder: fn(push: pure fn(v: A))) -> B { build_sized(size.get_default(4), builder) } @@ -285,7 +284,7 @@ pub pure fn from_fn>(n_elts: uint, * to the value `t`. */ pub pure fn from_elem>(n_elts: uint, - +t: T) -> BT { + t: T) -> BT { do build_sized(n_elts) |push| { let mut i: uint = 0; while i < n_elts { push(t); i += 1; } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index a1f65117ecf..5948c630cd8 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -8,8 +8,7 @@ dynamic checks: your program will fail if you attempt to perform mutation when the data structure should be immutable. */ - -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use util::with; @@ -24,11 +23,11 @@ struct Data { pub type Mut = Data; -pub fn Mut(+t: T) -> Mut { +pub fn Mut(t: T) -> Mut { Data {value: t, mode: ReadOnly} } -pub fn unwrap(+m: Mut) -> T { +pub fn unwrap(m: Mut) -> T { // Borrowck should prevent us from calling unwrap while the value // is in use, as that would be a move from a borrowed value. assert (m.mode as uint) == (ReadOnly as uint); diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 994e010e452..038c117b8be 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -77,6 +77,6 @@ pub trait Shr { #[lang="index"] pub trait Index { - pure fn index(+index: Index) -> Result; + pure fn index(index: Index) -> Result; } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 87d6aeefbc3..6bd326186cb 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -49,7 +49,7 @@ pub pure fn get_ref(opt: &r/Option) -> &r/T { } } -pub pure fn expect(opt: &Option, +reason: ~str) -> T { +pub pure fn expect(opt: &Option, reason: ~str) -> T { /*! * Gets the value out of an option, printing a specified message on * failure @@ -67,8 +67,8 @@ pub pure fn map(opt: &Option, f: fn(x: &T) -> U) -> Option { match *opt { Some(ref x) => Some(f(x)), None => None } } -pub pure fn map_consume(+opt: Option, - f: fn(+v: T) -> U) -> Option { +pub pure fn map_consume(opt: Option, + f: fn(v: T) -> U) -> Option { /*! * As `map`, but consumes the option and gives `f` ownership to avoid * copying. @@ -76,8 +76,8 @@ pub pure fn map_consume(+opt: Option, if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None } } -pub pure fn chain(+opt: Option, - f: fn(+t: T) -> Option) -> Option { +pub pure fn chain(opt: Option, + f: fn(t: T) -> Option) -> Option { /*! * Update an optional value by optionally running its content through a * function that returns an option. @@ -101,7 +101,7 @@ pub pure fn chain_ref(opt: &Option, match *opt { Some(ref x) => f(x), None => None } } -pub pure fn or(+opta: Option, +optb: Option) -> Option { +pub pure fn or(opta: Option, optb: Option) -> Option { /*! * Returns the leftmost some() value, or none if both are none. */ @@ -112,7 +112,7 @@ pub pure fn or(+opta: Option, +optb: Option) -> Option { } #[inline(always)] -pub pure fn while_some(+x: Option, blk: fn(+v: T) -> Option) { +pub pure fn while_some(x: Option, blk: fn(v: T) -> Option) { //! Applies a function zero or more times until the result is none. let mut opt <- x; @@ -133,13 +133,13 @@ pub pure fn is_some(opt: &Option) -> bool { !is_none(opt) } -pub pure fn get_default(opt: &Option, +def: T) -> T { +pub pure fn get_default(opt: &Option, def: T) -> T { //! Returns the contained value or a default match *opt { Some(copy x) => x, None => def } } -pub pure fn map_default(opt: &Option, +def: U, +pub pure fn map_default(opt: &Option, def: U, f: fn(x: &T) -> U) -> U { //! Applies a function to the contained value or returns a default @@ -151,10 +151,8 @@ pub pure fn iter(opt: &Option, f: fn(x: &T)) { match *opt { None => (), Some(ref t) => f(t) } } -// tjc: shouldn't this be - instead of +? -// then could get rid of some superfluous moves #[inline(always)] -pub pure fn unwrap(+opt: Option) -> T { +pub pure fn unwrap(opt: Option) -> T { /*! * Moves a value out of an option type and returns it. * @@ -174,7 +172,7 @@ pub fn swap_unwrap(opt: &mut Option) -> T { unwrap(util::replace(opt, None)) } -pub pure fn unwrap_expect(+opt: Option, reason: &str) -> T { +pub pure fn unwrap_expect(opt: Option, reason: &str) -> T { //! As unwrap, but with a specified failure message. if opt.is_none() { fail reason.to_unique(); } unwrap(move opt) @@ -197,7 +195,7 @@ impl &Option { chain_ref(self, f) } /// Applies a function to the contained value or returns a default - pure fn map_default(+def: U, f: fn(x: &T) -> U) -> U + pure fn map_default(def: U, f: fn(x: &T) -> U) -> U { map_default(self, move def, f) } /// Performs an operation on the contained value by reference pure fn iter(f: fn(x: &T)) { iter(self, f) } @@ -216,7 +214,7 @@ impl Option { * Fails if the value equals `none` */ pure fn get() -> T { get(&self) } - pure fn get_default(+def: T) -> T { get_default(&self, def) } + pure fn get_default(def: T) -> T { get_default(&self, def) } /** * Gets the value out of an option, printing a specified message on * failure @@ -225,9 +223,9 @@ impl Option { * * Fails if the value equals `none` */ - pure fn expect(+reason: ~str) -> T { expect(&self, reason) } + pure fn expect(reason: ~str) -> T { expect(&self, reason) } /// Applies a function zero or more times until the result is none. - pure fn while_some(blk: fn(+v: T) -> Option) { while_some(self, blk) } + pure fn while_some(blk: fn(v: T) -> Option) { while_some(self, blk) } } impl Option : Eq { diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 1cf4fbab6c9..f178502f6a0 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid #[forbid(deprecated_pattern)]; /*! @@ -768,7 +768,7 @@ struct OverriddenArgs { val: ~[~str] } -fn overridden_arg_key(+_v: @OverriddenArgs) {} +fn overridden_arg_key(_v: @OverriddenArgs) {} pub fn args() -> ~[~str] { unsafe { @@ -779,7 +779,7 @@ pub fn args() -> ~[~str] { } } -pub fn set_args(+new_args: ~[~str]) { +pub fn set_args(new_args: ~[~str]) { unsafe { let overridden_args = @OverriddenArgs { val: copy new_args }; task::local_data::local_data_set(overridden_arg_key, overridden_args); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 4d446df9cd5..e34c0db35e9 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -73,7 +73,7 @@ bounded and unbounded protocols allows for less code duplication. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cmp::Eq; @@ -169,7 +169,7 @@ impl PacketHeader { reinterpret_cast(&self.buffer) } - fn set_buffer(+b: ~Buffer) unsafe { + fn set_buffer(b: ~Buffer) unsafe { self.buffer = reinterpret_cast(&b); } } @@ -227,7 +227,7 @@ pub fn packet() -> *Packet { #[doc(hidden)] pub fn entangle_buffer( - +buffer: ~Buffer, + buffer: ~Buffer, init: fn(*libc::c_void, x: &T) -> *Packet) -> (SendPacketBuffered, RecvPacketBuffered) { @@ -239,12 +239,12 @@ pub fn entangle_buffer( #[abi = "rust-intrinsic"] #[doc(hidden)] extern mod rusti { - fn atomic_xchg(dst: &mut int, +src: int) -> int; - fn atomic_xchg_acq(dst: &mut int, +src: int) -> int; - fn atomic_xchg_rel(dst: &mut int, +src: int) -> int; + fn atomic_xchg(dst: &mut int, src: int) -> int; + fn atomic_xchg_acq(dst: &mut int, src: int) -> int; + fn atomic_xchg_rel(dst: &mut int, src: int) -> int; - fn atomic_xadd_acq(dst: &mut int, +src: int) -> int; - fn atomic_xsub_rel(dst: &mut int, +src: int) -> int; + fn atomic_xadd_acq(dst: &mut int, src: int) -> int; + fn atomic_xsub_rel(dst: &mut int, src: int) -> int; } // If I call the rusti versions directly from a polymorphic function, @@ -265,7 +265,7 @@ pub fn atomic_sub_rel(dst: &mut int, src: int) -> int { } #[doc(hidden)] -pub fn swap_task(+dst: &mut *rust_task, src: *rust_task) -> *rust_task { +pub fn swap_task(dst: &mut *rust_task, src: *rust_task) -> *rust_task { // It might be worth making both acquire and release versions of // this. unsafe { @@ -304,14 +304,14 @@ fn wait_event(this: *rust_task) -> *libc::c_void { } #[doc(hidden)] -fn swap_state_acq(+dst: &mut State, src: State) -> State { +fn swap_state_acq(dst: &mut State, src: State) -> State { unsafe { transmute(rusti::atomic_xchg_acq(transmute(move dst), src as int)) } } #[doc(hidden)] -fn swap_state_rel(+dst: &mut State, src: State) -> State { +fn swap_state_rel(dst: &mut State, src: State) -> State { unsafe { transmute(rusti::atomic_xchg_rel(transmute(move dst), src as int)) } @@ -343,7 +343,7 @@ struct BufferResource { } } -fn BufferResource(+b: ~Buffer) -> BufferResource { +fn BufferResource(b: ~Buffer) -> BufferResource { //let p = ptr::addr_of(*b); //error!("take %?", p); atomic_add_acq(&mut b.header.ref_count, 1); @@ -354,8 +354,8 @@ fn BufferResource(+b: ~Buffer) -> BufferResource { } #[doc(hidden)] -pub fn send(+p: SendPacketBuffered, - +payload: T) -> bool { +pub fn send(p: SendPacketBuffered, + payload: T) -> bool { let header = p.header(); let p_ = p.unwrap(); let p = unsafe { &*p_ }; @@ -398,7 +398,7 @@ pub fn send(+p: SendPacketBuffered, Fails if the sender closes the connection. */ -pub fn recv(+p: RecvPacketBuffered) -> T { +pub fn recv(p: RecvPacketBuffered) -> T { option::unwrap_expect(try_recv(move p), "connection closed") } @@ -408,7 +408,7 @@ Returns `none` if the sender has closed the connection without sending a message, or `Some(T)` if a message was received. */ -pub fn try_recv(+p: RecvPacketBuffered) +pub fn try_recv(p: RecvPacketBuffered) -> Option { let p_ = p.unwrap(); @@ -655,8 +655,8 @@ this case, `select2` may return either `left` or `right`. */ pub fn select2( - +a: RecvPacketBuffered, - +b: RecvPacketBuffered) + a: RecvPacketBuffered, + b: RecvPacketBuffered) -> Either<(Option, RecvPacketBuffered), (RecvPacketBuffered, Option)> { @@ -697,7 +697,7 @@ pub fn select2i(a: &A, b: &B) -> list of the remaining endpoints. */ -pub fn select(+endpoints: ~[RecvPacketBuffered]) +pub fn select(endpoints: ~[RecvPacketBuffered]) -> (uint, Option, ~[RecvPacketBuffered]) { let ready = wait_many(endpoints.map(|p| p.header())); @@ -859,7 +859,7 @@ endpoint is passed to the new task. pub fn spawn_service( init: extern fn() -> (SendPacketBuffered, RecvPacketBuffered), - +service: fn~(+v: RecvPacketBuffered)) + +service: fn~(v: RecvPacketBuffered)) -> SendPacketBuffered { let (client, server) = init(); @@ -883,7 +883,7 @@ receive state. pub fn spawn_service_recv( init: extern fn() -> (RecvPacketBuffered, SendPacketBuffered), - +service: fn~(+v: SendPacketBuffered)) + +service: fn~(v: SendPacketBuffered)) -> RecvPacketBuffered { let (client, server) = init(); @@ -914,10 +914,10 @@ pub trait Channel { // built in send kind. /// Sends a message. - fn send(+x: T); + fn send(x: T); /// Sends a message, or report if the receiver has closed the connection. - fn try_send(+x: T) -> bool; + fn try_send(x: T) -> bool; } /// A trait for things that can receive multiple messages. @@ -966,14 +966,14 @@ pub fn stream() -> (Chan, Port) { } impl Chan: Channel { - fn send(+x: T) { + fn send(x: T) { let mut endp = None; endp <-> self.endp; self.endp = Some( streamp::client::data(unwrap(move endp), move x)) } - fn try_send(+x: T) -> bool { + fn try_send(x: T) -> bool { let mut endp = None; endp <-> self.endp; match move streamp::client::try_data(unwrap(move endp), move x) { @@ -1041,7 +1041,7 @@ pub fn PortSet() -> PortSet{ impl PortSet : Recv { - fn add(+port: pipes::Port) { + fn add(port: pipes::Port) { self.ports.push(move port) } @@ -1091,7 +1091,7 @@ impl PortSet : Recv { pub type SharedChan = private::Exclusive>; impl SharedChan: Channel { - fn send(+x: T) { + fn send(x: T) { let mut xx = Some(move x); do self.with_imm |chan| { let mut x = None; @@ -1100,7 +1100,7 @@ impl SharedChan: Channel { } } - fn try_send(+x: T) -> bool { + fn try_send(x: T) -> bool { let mut xx = Some(move x); do self.with_imm |chan| { let mut x = None; @@ -1111,7 +1111,7 @@ impl SharedChan: Channel { } /// Converts a `chan` into a `shared_chan`. -pub fn SharedChan(+c: Chan) -> SharedChan { +pub fn SharedChan(c: Chan) -> SharedChan { private::exclusive(move c) } @@ -1165,13 +1165,13 @@ pub fn oneshot() -> (ChanOne, PortOne) { * Receive a message from a oneshot pipe, failing if the connection was * closed. */ -pub fn recv_one(+port: PortOne) -> T { +pub fn recv_one(port: PortOne) -> T { let oneshot::send(message) = recv(move port); move message } /// Receive a message from a oneshot pipe unless the connection was closed. -pub fn try_recv_one (+port: PortOne) -> Option { +pub fn try_recv_one (port: PortOne) -> Option { let message = try_recv(move port); if message.is_none() { None } @@ -1182,7 +1182,7 @@ pub fn try_recv_one (+port: PortOne) -> Option { } /// Send a message on a oneshot pipe, failing if the connection was closed. -pub fn send_one(+chan: ChanOne, +data: T) { +pub fn send_one(chan: ChanOne, data: T) { oneshot::client::send(move chan, move data); } @@ -1190,7 +1190,7 @@ pub fn send_one(+chan: ChanOne, +data: T) { * Send a message on a oneshot pipe, or return false if the connection was * closed. */ -pub fn try_send_one(+chan: ChanOne, +data: T) +pub fn try_send_one(chan: ChanOne, data: T) -> bool { oneshot::client::try_send(move chan, move data).is_some() } @@ -1198,7 +1198,7 @@ pub fn try_send_one(+chan: ChanOne, +data: T) pub mod rt { // These are used to hide the option constructors from the // compiler because their names are changing - pub fn make_some(+val: T) -> Option { Some(move val) } + pub fn make_some(val: T) -> Option { Some(move val) } pub fn make_none() -> Option { None } } diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 025a6f28976..c1b2b32edaf 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; #[doc(hidden)]; @@ -340,7 +340,7 @@ fn ArcDestruct(data: *libc::c_void) -> ArcDestruct { } } -pub unsafe fn unwrap_shared_mutable_state(+rc: SharedMutableState) +pub unsafe fn unwrap_shared_mutable_state(rc: SharedMutableState) -> T { struct DeathThroes { mut ptr: Option<~ArcData>, @@ -413,7 +413,7 @@ pub unsafe fn unwrap_shared_mutable_state(+rc: SharedMutableState) */ pub type SharedMutableState = ArcDestruct; -pub unsafe fn shared_mutable_state(+data: T) -> +pub unsafe fn shared_mutable_state(data: T) -> SharedMutableState { let data = ~ArcData { count: 1, unwrapper: 0, data: Some(move data) }; unsafe { @@ -502,7 +502,7 @@ struct ExData { lock: LittleLock, mut failed: bool, mut data: T, } */ pub struct Exclusive { x: SharedMutableState> } -pub fn exclusive(+user_data: T) -> Exclusive { +pub fn exclusive(user_data: T) -> Exclusive { let data = ExData { lock: LittleLock(), mut failed: false, mut data: user_data }; @@ -544,7 +544,7 @@ impl Exclusive { } // FIXME(#2585) make this a by-move method on the exclusive -pub fn unwrap_exclusive(+arc: Exclusive) -> T { +pub fn unwrap_exclusive(arc: Exclusive) -> T { let Exclusive { x: x } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let ExData { data: data, _ } <- inner; diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index af6a3f9b478..41006e1dfb5 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -27,7 +27,7 @@ fn align(size: uint, align: uint) -> uint { struct MovePtrAdaptor { inner: V } -pub fn MovePtrAdaptor(+v: V) -> MovePtrAdaptor { +pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor { MovePtrAdaptor { inner: move v } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index e454c068d47..e61690d5b2c 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -1,7 +1,7 @@ //! A type representing either success or failure // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cmp::Eq; @@ -102,7 +102,7 @@ pub pure fn to_either(res: &Result) * ok(parse_bytes(buf)) * } */ -pub fn chain(+res: Result, op: fn(+t: T) +pub fn chain(res: Result, op: fn(t: T) -> Result) -> Result { // XXX: Should be writable with move + match if res.is_ok() { @@ -121,8 +121,8 @@ pub fn chain(+res: Result, op: fn(+t: T) * successful result while handling an error. */ pub fn chain_err( - +res: Result, - op: fn(+t: V) -> Result) + res: Result, + op: fn(t: V) -> Result) -> Result { match move res { Ok(move t) => Ok(t), @@ -247,12 +247,12 @@ impl Result { } impl Result { - fn chain(op: fn(+t: T) -> Result) -> Result { + fn chain(op: fn(t: T) -> Result) -> Result { // XXX: Bad copy chain(copy self, op) } - fn chain_err(op: fn(+t: E) -> Result) -> Result { + fn chain_err(op: fn(t: E) -> Result) -> Result { // XXX: Bad copy chain_err(copy self, op) } @@ -348,7 +348,7 @@ pub fn iter_vec2(ss: &[S], ts: &[T], } /// Unwraps a result, assuming it is an `ok(T)` -pub fn unwrap(+res: Result) -> T { +pub fn unwrap(res: Result) -> T { match move res { Ok(move t) => move t, Err(_) => fail ~"unwrap called on an err result" @@ -356,7 +356,7 @@ pub fn unwrap(+res: Result) -> T { } /// Unwraps a result, assuming it is an `err(U)` -pub fn unwrap_err(+res: Result) -> U { +pub fn unwrap_err(res: Result) -> U { match move res { Err(move u) => move u, Ok(_) => fail ~"unwrap called on an ok result" @@ -389,7 +389,7 @@ mod tests { #[legacy_exports]; fn op1() -> result::Result { result::Ok(666) } - fn op2(+i: int) -> result::Result { + fn op2(i: int) -> result::Result { result::Ok(i as uint + 1u) } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 40c2bc83351..f3e98f6ba82 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; //! Process spawning @@ -224,7 +224,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { drop { destroy_repr(&self.r); } } - fn ProgRes(+r: ProgRepr) -> ProgRes { + fn ProgRes(r: ProgRepr) -> ProgRes { ProgRes { r: r } @@ -328,7 +328,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> return {status: status, out: move outs, err: move errs}; } -fn writeclose(fd: c_int, +s: ~str) { +fn writeclose(fd: c_int, s: ~str) { use io::WriterUtil; error!("writeclose %d, %s", fd as int, s); diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 1b219e16e09..4a56ee5b896 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -15,7 +15,7 @@ use to_bytes::IterBytes; pub trait SendMap { // FIXME(#3148) ^^^^ once find_ref() works, we can drop V:copy - fn insert(&mut self, +k: K, +v: V) -> bool; + fn insert(&mut self, k: K, +v: V) -> bool; fn remove(&mut self, k: &K) -> bool; fn clear(&mut self); pure fn len(&const self) -> uint; @@ -161,7 +161,7 @@ pub mod linear { } } - fn insert_opt_bucket(&mut self, +bucket: Option>) { + fn insert_opt_bucket(&mut self, bucket: Option>) { match move bucket { Some(Bucket {hash: move hash, key: move key, @@ -175,7 +175,7 @@ pub mod linear { /// Inserts the key value pair into the buckets. /// Assumes that there will be a bucket. /// True if there was no previous entry with that key - fn insert_internal(&mut self, hash: uint, +k: K, +v: V) -> bool { + fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { match self.bucket_for_key_with_hash(self.buckets, hash, &k) { TableFull => { fail ~"Internal logic error"; } FoundHole(idx) => { @@ -206,7 +206,7 @@ pub mod linear { } impl LinearMap { - fn insert(&mut self, +k: K, +v: V) -> bool { + fn insert(&mut self, k: K, v: V) -> bool { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index d0f8de136e2..09973148c8c 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -1,5 +1,7 @@ #[doc(hidden)]; // FIXME #3538 +#[legacy_modes]; // tjc: remove after snapshot + // NB: transitionary, de-mode-ing. // XXX: Can't do this because frame_address needs a deprecated mode. //#[forbid(deprecated_mode)]; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index e8a88f3bc1b..cf996a8b254 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -175,7 +175,7 @@ pub fn push_str(lhs: &const ~str, rhs: &str) { /// Concatenate two strings together #[inline(always)] -pub pure fn append(+lhs: ~str, rhs: &str) -> ~str { +pub pure fn append(lhs: ~str, rhs: &str) -> ~str { let mut v <- lhs; unsafe { push_str_no_overallocate(&mut v, rhs); diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 9f13a6c2207..12329616fbf 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -83,7 +83,7 @@ pub pure fn pref_align_of() -> uint { /// Returns the refcount of a shared box (as just before calling this) #[inline(always)] -pub pure fn refcount(+t: @T) -> uint { +pub pure fn refcount(t: @T) -> uint { unsafe { let ref_ptr: *uint = cast::reinterpret_cast(&t); *ref_ptr - 1 diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 912b7f712aa..5ca35a7f562 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; /*! @@ -232,7 +232,7 @@ pub enum TaskBuilder = { pub fn task() -> TaskBuilder { TaskBuilder({ opts: default_task_opts(), - gen_body: |body| move body, // Identity function + gen_body: |+body| move body, // Identity function can_not_copy: None, mut consumed: false, }) @@ -347,7 +347,7 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn future_result(blk: fn(+v: future::Future)) -> TaskBuilder { + fn future_result(blk: fn(v: future::Future)) -> TaskBuilder { // FIXME (#1087, #1857): Once linked failure and notification are // handled in the library, I can imagine implementing this by just // registering an arbitrary number of task::on_exit handlers and @@ -459,9 +459,9 @@ impl TaskBuilder { spawn::spawn_raw(move opts, x.gen_body(move f)); } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with(+arg: A, +f: fn~(+v: A)) { + fn spawn_with(arg: A, +f: fn~(+v: A)) { let arg = ~mut Some(move arg); - do self.spawn |move arg, move f|{ + do self.spawn |move arg, move f| { f(option::swap_unwrap(arg)) } } @@ -473,7 +473,7 @@ impl TaskBuilder { * child task, passes the port to child's body, and returns a channel * linked to the port to the parent. * - * This encapsulates Some boilerplate handshaking logic that would + * This encapsulates some boilerplate handshaking logic that would * otherwise be required to establish communication from the parent * to the child. */ @@ -1149,7 +1149,7 @@ fn test_avoid_copying_the_body_spawn() { #[test] fn test_avoid_copying_the_body_spawn_listener() { - do avoid_copying_the_body |f| { + do avoid_copying_the_body |+f| { spawn_listener(fn~(move f, _po: comm::Port) { f(); }); @@ -1167,7 +1167,7 @@ fn test_avoid_copying_the_body_task_spawn() { #[test] fn test_avoid_copying_the_body_spawn_listener_1() { - do avoid_copying_the_body |f| { + do avoid_copying_the_body |+f| { task().spawn_listener(fn~(move f, _po: comm::Port) { f(); }); diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index eda76518001..2130354229a 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -37,7 +37,7 @@ use local_data_priv::{ * * These two cases aside, the interface is safe. */ -pub type LocalDataKey = &fn(+v: @T); +pub type LocalDataKey = &fn(v: @T); /** * Remove a task-local data value from the table, returning the @@ -62,7 +62,7 @@ pub unsafe fn local_data_get( * that value is overwritten (and its destructor is run). */ pub unsafe fn local_data_set( - key: LocalDataKey, +data: @T) { + key: LocalDataKey, data: @T) { local_set(rt::rust_get_task(), key, data) } @@ -79,7 +79,7 @@ pub unsafe fn local_data_modify( #[test] pub fn test_tls_multitask() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_set(my_key, @~"parent data"); do task::spawn unsafe { assert local_data_get(my_key).is_none(); // TLS shouldn't carry over. @@ -95,7 +95,7 @@ pub fn test_tls_multitask() unsafe { #[test] pub fn test_tls_overwrite() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_set(my_key, @~"first data"); local_data_set(my_key, @~"next data"); // Shouldn't leak. assert *(local_data_get(my_key).get()) == ~"next data"; @@ -103,7 +103,7 @@ pub fn test_tls_overwrite() unsafe { #[test] pub fn test_tls_pop() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_set(my_key, @~"weasel"); assert *(local_data_pop(my_key).get()) == ~"weasel"; // Pop must remove the data from the map. @@ -112,7 +112,7 @@ pub fn test_tls_pop() unsafe { #[test] pub fn test_tls_modify() unsafe { - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } local_data_modify(my_key, |data| { match data { Some(@ref val) => fail ~"unwelcome value: " + *val, @@ -136,7 +136,7 @@ pub fn test_tls_crust_automorestack_memorial_bug() unsafe { // jump over to the rust stack, which causes next_c_sp to get recorded as // Something within a rust stack segment. Then a subsequent upcall (esp. // for logging, think vsnprintf) would run on a stack smaller than 1 MB. - fn my_key(+_x: @~str) { } + fn my_key(_x: @~str) { } do task::spawn { unsafe { local_data_set(my_key, @~"hax"); } } @@ -144,9 +144,9 @@ pub fn test_tls_crust_automorestack_memorial_bug() unsafe { #[test] pub fn test_tls_multiple_types() unsafe { - fn str_key(+_x: @~str) { } - fn box_key(+_x: @@()) { } - fn int_key(+_x: @int) { } + fn str_key(_x: @~str) { } + fn box_key(_x: @@()) { } + fn int_key(_x: @int) { } do task::spawn unsafe { local_data_set(str_key, @~"string data"); local_data_set(box_key, @@()); @@ -156,9 +156,9 @@ pub fn test_tls_multiple_types() unsafe { #[test] pub fn test_tls_overwrite_multiple_types() { - fn str_key(+_x: @~str) { } - fn box_key(+_x: @@()) { } - fn int_key(+_x: @int) { } + fn str_key(_x: @~str) { } + fn box_key(_x: @@()) { } + fn int_key(_x: @int) { } do task::spawn unsafe { local_data_set(str_key, @~"string data"); local_data_set(int_key, @42); @@ -172,9 +172,9 @@ pub fn test_tls_overwrite_multiple_types() { #[should_fail] #[ignore(cfg(windows))] pub fn test_tls_cleanup_on_failure() unsafe { - fn str_key(+_x: @~str) { } - fn box_key(+_x: @@()) { } - fn int_key(+_x: @int) { } + fn str_key(_x: @~str) { } + fn box_key(_x: @@()) { } + fn int_key(_x: @int) { } local_data_set(str_key, @~"parent data"); local_data_set(box_key, @@()); do task::spawn unsafe { // spawn_linked diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 0d3007286c5..499dd073060 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -117,7 +117,7 @@ unsafe fn local_get( } unsafe fn local_set( - task: *rust_task, key: LocalDataKey, +data: @T) { + task: *rust_task, key: LocalDataKey, data: @T) { let map = get_task_local_map(task); // Store key+data as *voids. Data is invisibly referenced once; key isn't. diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 982679f9398..786255fe7fa 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -82,7 +82,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); assert was_present; } -fn taskset_each(tasks: &TaskSet, blk: fn(+v: *rust_task) -> bool) { +fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) { tasks.each_key(|k| blk(*k)) } @@ -303,8 +303,8 @@ struct TCB { } } -fn TCB(me: *rust_task, +tasks: TaskGroupArc, +ancestors: AncestorList, - is_main: bool, +notifier: Option) -> TCB { +fn TCB(me: *rust_task, tasks: TaskGroupArc, ancestors: AncestorList, + is_main: bool, notifier: Option) -> TCB { let notifier = move notifier; notifier.iter(|x| { x.failed = false; }); @@ -327,7 +327,7 @@ struct AutoNotify { } } -fn AutoNotify(+chan: Chan) -> AutoNotify { +fn AutoNotify(chan: Chan) -> AutoNotify { AutoNotify { notify_chan: chan, failed: true // Un-set above when taskgroup successfully made. @@ -377,13 +377,13 @@ fn kill_taskgroup(state: TaskGroupInner, me: *rust_task, is_main: bool) { // see 'None' if Somebody already failed and we got a kill signal.) if newstate.is_some() { let group = option::unwrap(move newstate); - for taskset_each(&group.members) |+sibling| { + for taskset_each(&group.members) |sibling| { // Skip self - killing ourself won't do much good. if sibling != me { rt::rust_task_kill_other(sibling); } } - for taskset_each(&group.descendants) |+child| { + for taskset_each(&group.descendants) |child| { assert child != me; rt::rust_task_kill_other(child); } @@ -486,7 +486,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) } } -fn spawn_raw(+opts: TaskOpts, +f: fn~()) { +fn spawn_raw(opts: TaskOpts, +f: fn~()) { let (child_tg, ancestors, is_main) = gen_child_taskgroup(opts.linked, opts.supervised); @@ -528,9 +528,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) { // (3a) If any of those fails, it leaves all groups, and does nothing. // (3b) Otherwise it builds a task control structure and puts it in TLS, // (4) ...and runs the provided body function. - fn make_child_wrapper(child: *rust_task, +child_arc: TaskGroupArc, - +ancestors: AncestorList, is_main: bool, - +notify_chan: Option>, + fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc, + ancestors: AncestorList, is_main: bool, + notify_chan: Option>, +f: fn~()) -> fn~() { let child_data = ~mut Some((move child_arc, move ancestors)); return fn~(move notify_chan, move child_data, move f) { diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 9ba8b52f5da..aa1fe14ba88 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -5,25 +5,25 @@ Miscellaneous helpers for common patterns. */ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: re-forbid deprecated modes after snapshot #[forbid(deprecated_pattern)]; use cmp::Eq; /// The identity function. #[inline(always)] -pub pure fn id(+x: T) -> T { move x } +pub pure fn id(x: T) -> T { move x } /// Ignores a value. #[inline(always)] -pub pure fn ignore(+_x: T) { } +pub pure fn ignore(_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the /// original value of `*ptr`. #[inline(always)] pub fn with( ptr: &mut T, - +new_value: T, + new_value: T, op: &fn() -> R) -> R { // NDM: if swap operator were defined somewhat differently, @@ -50,7 +50,7 @@ pub fn swap(x: &mut T, y: &mut T) { * value, without deinitialising or copying either one. */ #[inline(always)] -pub fn replace(dest: &mut T, +src: T) -> T { +pub fn replace(dest: &mut T, src: T) -> T { let mut tmp <- src; swap(dest, &mut tmp); move tmp diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index ce82215a87c..0c822bd0a03 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -47,7 +47,7 @@ pub pure fn same_length(xs: &[const T], ys: &[const U]) -> bool { * * v - A vector * * n - The number of elements to reserve space for */ -pub fn reserve(+v: &mut ~[T], +n: uint) { +pub fn reserve(v: &mut ~[T], n: uint) { // Only make the (slow) call into the runtime if we have to if capacity(v) < n { unsafe { @@ -119,7 +119,7 @@ pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem(n_elts: uint, +t: T) -> ~[T] { +pub pure fn from_elem(n_elts: uint, t: T) -> ~[T] { from_fn(n_elts, |_i| copy t) } @@ -148,9 +148,9 @@ pub pure fn with_capacity(capacity: uint) -> ~[T] { */ #[inline(always)] pub pure fn build_sized(size: uint, - builder: fn(push: pure fn(+v: A))) -> ~[A] { + builder: fn(push: pure fn(v: A))) -> ~[A] { let mut vec = with_capacity(size); - builder(|+x| unsafe { vec.push(move x) }); + builder(|x| unsafe { vec.push(move x) }); move vec } @@ -165,7 +165,7 @@ pub pure fn build_sized(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build(builder: fn(push: pure fn(+v: A))) -> ~[A] { +pub pure fn build(builder: fn(push: pure fn(v: A))) -> ~[A] { build_sized(4, builder) } @@ -183,17 +183,17 @@ pub pure fn build(builder: fn(push: pure fn(+v: A))) -> ~[A] { */ #[inline(always)] pub pure fn build_sized_opt(size: Option, - builder: fn(push: pure fn(+v: A))) -> ~[A] { + builder: fn(push: pure fn(v: A))) -> ~[A] { build_sized(size.get_default(4), builder) } /// Produces a mut vector from an immutable vector. -pub pure fn to_mut(+v: ~[T]) -> ~[mut T] { +pub pure fn to_mut(v: ~[T]) -> ~[mut T] { unsafe { ::cast::transmute(move v) } } /// Produces an immutable vector from a mut vector. -pub pure fn from_mut(+v: ~[mut T]) -> ~[T] { +pub pure fn from_mut(v: ~[mut T]) -> ~[T] { unsafe { ::cast::transmute(move v) } } @@ -412,13 +412,13 @@ pub fn shift(v: &mut ~[T]) -> T { } /// Prepend an element to the vector -pub fn unshift(v: &mut ~[T], +x: T) { +pub fn unshift(v: &mut ~[T], x: T) { let mut vv = ~[move x]; *v <-> vv; v.push_all_move(vv); } -pub fn consume(+v: ~[T], f: fn(uint, +v: T)) unsafe { +pub fn consume(v: ~[T], f: fn(uint, v: T)) unsafe { let mut v = move v; // FIXME(#3488) do as_imm_buf(v) |p, ln| { @@ -431,7 +431,7 @@ pub fn consume(+v: ~[T], f: fn(uint, +v: T)) unsafe { raw::set_len(&mut v, 0); } -pub fn consume_mut(+v: ~[mut T], f: fn(uint, +v: T)) { +pub fn consume_mut(v: ~[mut T], f: fn(uint, v: T)) { consume(vec::from_mut(v), f) } @@ -468,7 +468,7 @@ pub fn swap_remove(v: &mut ~[T], index: uint) -> T { /// Append an element to a vector #[inline(always)] -pub fn push(v: &mut ~[T], +initval: T) { +pub fn push(v: &mut ~[T], initval: T) { unsafe { let repr: **raw::VecRepr = ::cast::transmute(copy v); let fill = (**repr).unboxed.fill; @@ -483,7 +483,7 @@ pub fn push(v: &mut ~[T], +initval: T) { // This doesn't bother to make sure we have space. #[inline(always)] // really pretty please -unsafe fn push_fast(+v: &mut ~[T], +initval: T) { +unsafe fn push_fast(v: &mut ~[T], initval: T) { let repr: **raw::VecRepr = ::cast::transmute(v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::(); @@ -493,13 +493,13 @@ unsafe fn push_fast(+v: &mut ~[T], +initval: T) { } #[inline(never)] -fn push_slow(+v: &mut ~[T], +initval: T) { +fn push_slow(v: &mut ~[T], initval: T) { reserve_at_least(v, v.len() + 1u); unsafe { push_fast(v, move initval) } } #[inline(always)] -pub fn push_all(+v: &mut ~[T], rhs: &[const T]) { +pub fn push_all(v: &mut ~[T], rhs: &[const T]) { reserve(v, v.len() + rhs.len()); for uint::range(0u, rhs.len()) |i| { @@ -508,7 +508,7 @@ pub fn push_all(+v: &mut ~[T], rhs: &[const T]) { } #[inline(always)] -pub fn push_all_move(v: &mut ~[T], +rhs: ~[T]) { +pub fn push_all_move(v: &mut ~[T], rhs: ~[T]) { let mut rhs = move rhs; // FIXME(#3488) reserve(v, v.len() + rhs.len()); unsafe { @@ -573,7 +573,7 @@ pub fn dedup(v: &mut ~[T]) unsafe { // Appending #[inline(always)] -pub pure fn append(+lhs: ~[T], rhs: &[const T]) -> ~[T] { +pub pure fn append(lhs: ~[T], rhs: &[const T]) -> ~[T] { let mut v <- lhs; unsafe { v.push_all(rhs); @@ -582,14 +582,14 @@ pub pure fn append(+lhs: ~[T], rhs: &[const T]) -> ~[T] { } #[inline(always)] -pub pure fn append_one(+lhs: ~[T], +x: T) -> ~[T] { +pub pure fn append_one(lhs: ~[T], x: T) -> ~[T] { let mut v <- lhs; unsafe { v.push(move x); } move v } #[inline(always)] -pure fn append_mut(+lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { +pure fn append_mut(lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] { to_mut(append(from_mut(lhs), rhs)) } @@ -642,7 +642,7 @@ pub fn grow_fn(v: &mut ~[T], n: uint, op: iter::InitOp) { * of the vector, expands the vector by replicating `initval` to fill the * intervening space. */ -pub fn grow_set(v: &mut ~[T], index: uint, initval: &T, +val: T) { +pub fn grow_set(v: &mut ~[T], index: uint, initval: &T, val: T) { let l = v.len(); if index >= l { grow(v, index - l + 1u, initval); } v[index] = move val; @@ -661,7 +661,7 @@ pub pure fn map(v: &[T], f: fn(t: &T) -> U) -> ~[U] { move result } -pub fn map_consume(+v: ~[T], f: fn(+v: T) -> U) -> ~[U] { +pub fn map_consume(v: ~[T], f: fn(v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(move v) |_i, x| { result.push(f(move x)); @@ -758,7 +758,7 @@ pub pure fn connect(v: &[~[T]], sep: &T) -> ~[T] { } /// Reduce a vector from left to right -pub pure fn foldl(+z: T, v: &[U], p: fn(+t: T, u: &U) -> T) -> T { +pub pure fn foldl(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T { let mut accum = z; for each(v) |elt| { // it should be possible to move accum in, but the liveness analysis @@ -769,7 +769,7 @@ pub pure fn foldl(+z: T, v: &[U], p: fn(+t: T, u: &U) -> T) -> T { } /// Reduce a vector from right to left -pub pure fn foldr(v: &[T], +z: U, p: fn(t: &T, +u: U) -> U) -> U { +pub pure fn foldr(v: &[T], z: U, p: fn(t: &T, u: U) -> U) -> U { let mut accum = z; for rev_each(v) |elt| { accum = p(elt, accum); @@ -992,7 +992,7 @@ pure fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { * and the i-th element of the second vector contains the second element * of the i-th tuple of the input vector. */ -pub pure fn unzip(+v: ~[(T, U)]) -> (~[T], ~[U]) { +pub pure fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[], us = ~[]; unsafe { do consume(move v) |_i, p| { @@ -1023,7 +1023,7 @@ pub pure fn zip_slice(v: &[const T], u: &[const U]) * Returns a vector of tuples, where the i-th tuple contains contains the * i-th elements from each of the input vectors. */ -pub pure fn zip(+v: ~[T], +u: ~[U]) -> ~[(T, U)] { +pub pure fn zip(v: ~[T], u: ~[U]) -> ~[(T, U)] { let mut v = move v, u = move u; // FIXME(#3488) let mut i = len(v); assert i == len(u); @@ -1190,7 +1190,7 @@ pub fn each2(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pure fn each_permutation(+v: &[T], put: fn(ts: &[T]) -> bool) { +pure fn each_permutation(v: &[T], put: fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -1435,7 +1435,7 @@ impl &[const T]: CopyableVector { pub trait ImmutableVector { pure fn view(start: uint, end: uint) -> &self/[T]; - pure fn foldr(+z: U, p: fn(t: &T, +u: U) -> U) -> U; + pure fn foldr(z: U, p: fn(t: &T, u: U) -> U) -> U; pure fn map(f: fn(t: &T) -> U) -> ~[U]; pure fn mapi(f: fn(uint, t: &T) -> U) -> ~[U]; fn map_r(f: fn(x: &T) -> U) -> ~[U]; @@ -1459,7 +1459,7 @@ impl &[T]: ImmutableVector { } /// Reduce a vector from right to left #[inline] - pure fn foldr(+z: U, p: fn(t: &T, +u: U) -> U) -> U { + pure fn foldr(z: U, p: fn(t: &T, u: U) -> U) -> U { foldr(self, z, p) } /// Apply a function to each element of a vector and return the results @@ -1582,11 +1582,11 @@ impl &[T]: ImmutableCopyableVector { } pub trait MutableVector { - fn push(&mut self, +t: T); - fn push_all_move(&mut self, +rhs: ~[T]); + fn push(&mut self, t: T); + fn push_all_move(&mut self, rhs: ~[T]); fn pop(&mut self) -> T; fn shift(&mut self) -> T; - fn unshift(&mut self, +x: T); + fn unshift(&mut self, x: T); fn swap_remove(&mut self, index: uint) -> T; fn truncate(&mut self, newlen: uint); } @@ -1595,7 +1595,7 @@ pub trait MutableCopyableVector { fn push_all(&mut self, rhs: &[const T]); fn grow(&mut self, n: uint, initval: &T); fn grow_fn(&mut self, n: uint, op: iter::InitOp); - fn grow_set(&mut self, index: uint, initval: &T, +val: T); + fn grow_set(&mut self, index: uint, initval: &T, val: T); } trait MutableEqVector { @@ -1603,11 +1603,11 @@ trait MutableEqVector { } impl ~[T]: MutableVector { - fn push(&mut self, +t: T) { + fn push(&mut self, t: T) { push(self, move t); } - fn push_all_move(&mut self, +rhs: ~[T]) { + fn push_all_move(&mut self, rhs: ~[T]) { push_all_move(self, move rhs); } @@ -1619,7 +1619,7 @@ impl ~[T]: MutableVector { shift(self) } - fn unshift(&mut self, +x: T) { + fn unshift(&mut self, x: T) { unshift(self, x) } @@ -1645,7 +1645,7 @@ impl ~[T]: MutableCopyableVector { grow_fn(self, n, op); } - fn grow_set(&mut self, index: uint, initval: &T, +val: T) { + fn grow_set(&mut self, index: uint, initval: &T, val: T) { grow_set(self, index, initval, val); } } @@ -1717,21 +1717,21 @@ pub mod raw { * would also make any pointers to it invalid. */ #[inline(always)] - pub unsafe fn to_ptr(+v: &[T]) -> *T { + pub unsafe fn to_ptr(v: &[T]) -> *T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_const_ptr(+v: &[const T]) -> *const T { + pub unsafe fn to_const_ptr(v: &[const T]) -> *const T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** see `to_ptr()` */ #[inline(always)] - pub unsafe fn to_mut_ptr(+v: &[mut T]) -> *mut T { + pub unsafe fn to_mut_ptr(v: &[mut T]) -> *mut T { let repr: **SliceRepr = ::cast::transmute(&v); return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } @@ -1764,7 +1764,7 @@ pub mod raw { * is newly allocated. */ #[inline(always)] - pub unsafe fn init_elem(v: &[mut T], i: uint, +val: T) { + pub unsafe fn init_elem(v: &[mut T], i: uint, val: T) { let mut box = Some(move val); do as_mut_buf(v) |p, _len| { let mut box2 = None; @@ -1896,7 +1896,7 @@ impl &[A]: iter::ExtendedIter { } pub pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) } pub pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) } - pub pure fn foldl(+b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl(b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(&self, move b0, blk) } pub pure fn position(f: fn(&A) -> bool) -> Option { @@ -1910,10 +1910,10 @@ impl &[A]: iter::EqIter { } impl &[A]: iter::CopyableIter { - pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A] { + pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] { iter::filter_to_vec(&self, pred) } - pure fn map_to_vec(op: fn(+v: A) -> B) -> ~[B] { + pure fn map_to_vec(op: fn(v: A) -> B) -> ~[B] { iter::map_to_vec(&self, op) } pure fn to_vec() -> ~[A] { iter::to_vec(&self) } @@ -1923,7 +1923,7 @@ impl &[A]: iter::CopyableIter { // iter::flat_map_to_vec(self, op) // } - pub pure fn find(p: fn(+a: A) -> bool) -> Option { + pub pure fn find(p: fn(a: A) -> bool) -> Option { iter::find(&self, p) } } @@ -1951,7 +1951,7 @@ mod tests { return if *n % 2u == 1u { Some(*n * *n) } else { None }; } - fn add(+x: uint, y: &uint) -> uint { return x + *y; } + fn add(x: uint, y: &uint) -> uint { return x + *y; } #[test] fn test_unsafe_ptrs() { @@ -2193,7 +2193,7 @@ mod tests { #[test] fn test_dedup() { - fn case(+a: ~[uint], +b: ~[uint]) { + fn case(a: ~[uint], b: ~[uint]) { let mut v = a; v.dedup(); assert(v == b); @@ -2323,7 +2323,7 @@ mod tests { #[test] fn test_foldl2() { - fn sub(+a: int, b: &int) -> int { + fn sub(a: int, b: &int) -> int { a - *b } let mut v = ~[1, 2, 3, 4]; @@ -2333,7 +2333,7 @@ mod tests { #[test] fn test_foldr() { - fn sub(a: &int, +b: int) -> int { + fn sub(a: &int, b: int) -> int { *a - b } let mut v = ~[1, 2, 3, 4]; diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index a04eadb7732..67bbff7fb6a 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -232,7 +232,7 @@ type Result = result::Result; */ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { let n_opts = vec::len::(opts); - fn f(_x: uint) -> ~[Optval] { return ~[]; } + fn f(+_x: uint) -> ~[Optval] { return ~[]; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); let mut free: ~[~str] = ~[]; let l = vec::len(args); diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index aedd53d41cc..59cb0d36f77 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -763,7 +763,7 @@ impl TcpSocket { /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` impl TcpSocketBuf: io::Reader { - fn read(buf: &[mut u8], len: uint) -> uint { + fn read(buf: &[mut u8], +len: uint) -> uint { // Loop until our buffer has enough data in it for us to read from. while self.data.buf.len() < len { let read_result = read(&self.data.sock, 0u); @@ -799,13 +799,13 @@ impl TcpSocketBuf: io::Reader { let mut bytes = ~[0]; if self.read(bytes, 1u) == 0 { fail } else { bytes[0] as int } } - fn unread_byte(amt: int) { + fn unread_byte(+amt: int) { self.data.buf.unshift(amt as u8); } fn eof() -> bool { false // noop } - fn seek(dist: int, seek: io::SeekStyle) { + fn seek(+dist: int, +seek: io::SeekStyle) { log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek)); // noop } @@ -827,7 +827,7 @@ impl TcpSocketBuf: io::Writer { err_data.err_name, err_data.err_msg)); } } - fn seek(dist: int, seek: io::SeekStyle) { + fn seek(+dist: int, +seek: io::SeekStyle) { log(debug, fmt!("tcp_socket_buf seek stub %? %?", dist, seek)); // noop } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 00226c4e81e..920751d690f 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -735,7 +735,7 @@ impl Url : Eq { } impl Url: IterBytes { - pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) { + pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) { unsafe { self.to_str() }.iter_bytes(lsb0, f) } } diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 647560099e9..d14a4854555 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -379,7 +379,7 @@ Section: Iterating * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_chars(rope: Rope, it: fn(char) -> bool) -> bool { +pub fn loop_chars(rope: Rope, it: fn(+c: char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) @@ -1037,7 +1037,7 @@ mod node { return result; } - pub fn loop_chars(node: @Node, it: fn(char) -> bool) -> bool { + pub fn loop_chars(node: @Node, it: fn(+c: char) -> bool) -> bool { return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, diff --git a/src/libstd/std.rc b/src/libstd/std.rc index aa26c4af29c..95af018e35a 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -18,6 +18,9 @@ not required in or otherwise suitable for the core library. #[no_core]; +// tjc: Added legacy_modes back in because it still uses + mode. +// Remove once + mode gets expunged from std. +#[legacy_modes]; #[legacy_exports]; #[allow(vecs_implicitly_copyable)]; diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index ebdc66156e3..0f31f2056a1 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -683,8 +683,12 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl, mode_to_str(arg_ast.mode)); match arg_ast.mode { ast::expl(ast::by_copy) => { - // This should warn, but we can't yet - // since it's still used. -- tjc + if !tcx.legacy_modes { + tcx.sess.span_lint( + deprecated_mode, id, id, span, + fmt!("argument %d uses by-copy mode", + counter)); + } } ast::expl(_) => { diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index a34fcc89c04..f35a3ce735f 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(+i: uint, +c: color) -> color { + fn~(i: uint, c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); -- cgit 1.4.1-3-g733a5 From fb83b401749a08d77d11b5865fbd1d15a1b9ffd0 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 3 Oct 2012 13:36:39 -0700 Subject: De-export std::{ebml, ebml2}. Part of #3583. --- src/libstd/ebml.rs | 69 +++++++++++++++++------------------------------------ src/libstd/ebml2.rs | 59 +++++++++++++++------------------------------ src/libstd/std.rc | 2 -- 3 files changed, 41 insertions(+), 89 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 7c5b7929f84..238e9d77a77 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -4,31 +4,6 @@ use core::Option; use option::{Some, None}; -export Doc; -export doc_at; -export maybe_get_doc; -export get_doc; -export docs; -export tagged_docs; -export doc_data; -export doc_as_str; -export doc_as_u8; -export doc_as_u16; -export doc_as_u32; -export doc_as_u64; -export doc_as_i8; -export doc_as_i16; -export doc_as_i32; -export doc_as_i64; -export Writer; -export serializer; -export ebml_deserializer; -export EbmlDeserializer; -export deserializer; -export with_doc_data; -export get_doc; -export extensions; - type EbmlTag = {id: uint, size: uint}; type EbmlState = {ebml_tag: EbmlTag, tag_pos: uint, data_pos: uint}; @@ -37,7 +12,7 @@ type EbmlState = {ebml_tag: EbmlTag, tag_pos: uint, data_pos: uint}; // separate modules within this file. // ebml reading -type Doc = {data: @~[u8], start: uint, end: uint}; +pub type Doc = {data: @~[u8], start: uint, end: uint}; type TaggedDoc = {tag: uint, doc: Doc}; @@ -72,11 +47,11 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { } else { error!("vint too big"); fail; } } -fn Doc(data: @~[u8]) -> Doc { +pub fn Doc(data: @~[u8]) -> Doc { return {data: data, start: 0u, end: vec::len::(*data)}; } -fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { +pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { let elt_tag = vuint_at(*data, start); let elt_size = vuint_at(*data, elt_tag.next); let end = elt_size.next + elt_size.val; @@ -84,7 +59,7 @@ fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { doc: {data: data, start: elt_size.next, end: end}}; } -fn maybe_get_doc(d: Doc, tg: uint) -> Option { +pub fn maybe_get_doc(d: Doc, tg: uint) -> Option { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -101,7 +76,7 @@ fn maybe_get_doc(d: Doc, tg: uint) -> Option { return None::; } -fn get_doc(d: Doc, tg: uint) -> Doc { +pub fn get_doc(d: Doc, tg: uint) -> Doc { match maybe_get_doc(d, tg) { Some(d) => return d, None => { @@ -111,7 +86,7 @@ fn get_doc(d: Doc, tg: uint) -> Doc { } } -fn docs(d: Doc, it: fn(uint, Doc) -> bool) { +pub fn docs(d: Doc, it: fn(uint, Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -123,7 +98,7 @@ fn docs(d: Doc, it: fn(uint, Doc) -> bool) { } } -fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { +pub fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -137,43 +112,43 @@ fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { } } -fn doc_data(d: Doc) -> ~[u8] { vec::slice::(*d.data, d.start, d.end) } +pub fn doc_data(d: Doc) -> ~[u8] { vec::slice::(*d.data, d.start, d.end) } -fn with_doc_data(d: Doc, f: fn(x: &[u8]) -> T) -> T { +pub fn with_doc_data(d: Doc, f: fn(x: &[u8]) -> T) -> T { return f(vec::view(*d.data, d.start, d.end)); } -fn doc_as_str(d: Doc) -> ~str { return str::from_bytes(doc_data(d)); } +pub fn doc_as_str(d: Doc) -> ~str { return str::from_bytes(doc_data(d)); } -fn doc_as_u8(d: Doc) -> u8 { +pub fn doc_as_u8(d: Doc) -> u8 { assert d.end == d.start + 1u; return (*d.data)[d.start]; } -fn doc_as_u16(d: Doc) -> u16 { +pub fn doc_as_u16(d: Doc) -> u16 { assert d.end == d.start + 2u; return io::u64_from_be_bytes(*d.data, d.start, 2u) as u16; } -fn doc_as_u32(d: Doc) -> u32 { +pub fn doc_as_u32(d: Doc) -> u32 { assert d.end == d.start + 4u; return io::u64_from_be_bytes(*d.data, d.start, 4u) as u32; } -fn doc_as_u64(d: Doc) -> u64 { +pub fn doc_as_u64(d: Doc) -> u64 { assert d.end == d.start + 8u; return io::u64_from_be_bytes(*d.data, d.start, 8u); } -fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 } -fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 } -fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } -fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } +pub fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 } +pub fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 } +pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } +pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } // ebml writing type Writer_ = {writer: io::Writer, mut size_positions: ~[uint]}; -enum Writer { +pub enum Writer { Writer_(Writer_) } @@ -197,7 +172,7 @@ fn write_vuint(w: io::Writer, n: uint) { fail fmt!("vint to write too big: %?", n); } -fn Writer(w: io::Writer) -> Writer { +pub fn Writer(w: io::Writer) -> Writer { let size_positions: ~[uint] = ~[]; return Writer_({writer: w, mut size_positions: size_positions}); } @@ -409,11 +384,11 @@ impl ebml::Writer: serialization::Serializer { type EbmlDeserializer_ = {mut parent: ebml::Doc, mut pos: uint}; -enum EbmlDeserializer { +pub enum EbmlDeserializer { EbmlDeserializer_(EbmlDeserializer_) } -fn ebml_deserializer(d: ebml::Doc) -> EbmlDeserializer { +pub fn ebml_deserializer(d: ebml::Doc) -> EbmlDeserializer { EbmlDeserializer_({mut parent: d, mut pos: d.start}) } diff --git a/src/libstd/ebml2.rs b/src/libstd/ebml2.rs index 3ed6426b829..30d68da06f5 100644 --- a/src/libstd/ebml2.rs +++ b/src/libstd/ebml2.rs @@ -3,27 +3,6 @@ use serialization2; // Simple Extensible Binary Markup Language (ebml) reader and writer on a // cursor model. See the specification here: // http://www.matroska.org/technical/specs/rfc/index.html -export Doc; -export doc_at; -export maybe_get_doc; -export get_doc; -export docs; -export tagged_docs; -export doc_data; -export doc_as_str; -export doc_as_u8; -export doc_as_u16; -export doc_as_u32; -export doc_as_u64; -export doc_as_i8; -export doc_as_i16; -export doc_as_i32; -export doc_as_i64; -export Serializer; -export Deserializer; -export with_doc_data; -export get_doc; -export extensions; struct EbmlTag { id: uint, @@ -82,11 +61,11 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { } else { error!("vint too big"); fail; } } -fn Doc(data: @~[u8]) -> Doc { +pub fn Doc(data: @~[u8]) -> Doc { Doc { data: data, start: 0u, end: vec::len::(*data) } } -fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { +pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { let elt_tag = vuint_at(*data, start); let elt_size = vuint_at(*data, elt_tag.next); let end = elt_size.next + elt_size.val; @@ -96,7 +75,7 @@ fn doc_at(data: @~[u8], start: uint) -> TaggedDoc { } } -fn maybe_get_doc(d: Doc, tg: uint) -> Option { +pub fn maybe_get_doc(d: Doc, tg: uint) -> Option { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -109,7 +88,7 @@ fn maybe_get_doc(d: Doc, tg: uint) -> Option { None } -fn get_doc(d: Doc, tg: uint) -> Doc { +pub fn get_doc(d: Doc, tg: uint) -> Doc { match maybe_get_doc(d, tg) { Some(d) => d, None => { @@ -119,7 +98,7 @@ fn get_doc(d: Doc, tg: uint) -> Doc { } } -fn docs(d: Doc, it: fn(uint, Doc) -> bool) { +pub fn docs(d: Doc, it: fn(uint, Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -132,7 +111,7 @@ fn docs(d: Doc, it: fn(uint, Doc) -> bool) { } } -fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { +pub fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { let mut pos = d.start; while pos < d.end { let elt_tag = vuint_at(*d.data, pos); @@ -147,38 +126,38 @@ fn tagged_docs(d: Doc, tg: uint, it: fn(Doc) -> bool) { } } -fn doc_data(d: Doc) -> ~[u8] { vec::slice::(*d.data, d.start, d.end) } +pub fn doc_data(d: Doc) -> ~[u8] { vec::slice::(*d.data, d.start, d.end) } -fn with_doc_data(d: Doc, f: fn(x: &[u8]) -> T) -> T { +pub fn with_doc_data(d: Doc, f: fn(x: &[u8]) -> T) -> T { f(vec::view(*d.data, d.start, d.end)) } -fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) } +pub fn doc_as_str(d: Doc) -> ~str { str::from_bytes(doc_data(d)) } -fn doc_as_u8(d: Doc) -> u8 { +pub fn doc_as_u8(d: Doc) -> u8 { assert d.end == d.start + 1u; (*d.data)[d.start] } -fn doc_as_u16(d: Doc) -> u16 { +pub fn doc_as_u16(d: Doc) -> u16 { assert d.end == d.start + 2u; io::u64_from_be_bytes(*d.data, d.start, 2u) as u16 } -fn doc_as_u32(d: Doc) -> u32 { +pub fn doc_as_u32(d: Doc) -> u32 { assert d.end == d.start + 4u; io::u64_from_be_bytes(*d.data, d.start, 4u) as u32 } -fn doc_as_u64(d: Doc) -> u64 { +pub fn doc_as_u64(d: Doc) -> u64 { assert d.end == d.start + 8u; io::u64_from_be_bytes(*d.data, d.start, 8u) } -fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 } -fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 } -fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } -fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } +pub fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 } +pub fn doc_as_i16(d: Doc) -> i16 { doc_as_u16(d) as i16 } +pub fn doc_as_i32(d: Doc) -> i32 { doc_as_u32(d) as i32 } +pub fn doc_as_i64(d: Doc) -> i64 { doc_as_u64(d) as i64 } // ebml writing struct Serializer { @@ -206,7 +185,7 @@ fn write_vuint(w: io::Writer, n: uint) { fail fmt!("vint to write too big: %?", n); } -fn Serializer(w: io::Writer) -> Serializer { +pub fn Serializer(w: io::Writer) -> Serializer { let size_positions: ~[uint] = ~[]; Serializer { writer: w, mut size_positions: size_positions } } @@ -450,7 +429,7 @@ struct Deserializer { priv mut pos: uint, } -fn Deserializer(d: Doc) -> Deserializer { +pub fn Deserializer(d: Doc) -> Deserializer { Deserializer { mut parent: d, mut pos: d.start } } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 95af018e35a..251a492bb5b 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -89,9 +89,7 @@ mod treemap; // And ... other stuff -#[legacy_exports] mod ebml; -#[legacy_exports] mod ebml2; mod dbg; #[legacy_exports] -- cgit 1.4.1-3-g733a5 From 654b4d6987223752155b58804255a373d3410a96 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 3 Oct 2012 13:37:51 -0700 Subject: De-export std::{json, getopts}. Part of #3583. --- src/libstd/getopts.rs | 54 +++++++++++++++++---------------------------------- src/libstd/std.rc | 2 -- 2 files changed, 18 insertions(+), 38 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 67bbff7fb6a..9d127f5db47 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -68,24 +68,6 @@ use core::cmp::Eq; use core::result::{Err, Ok}; use core::option; use core::option::{Some, None}; -export Opt; -export reqopt; -export optopt; -export optflag; -export optflagopt; -export optmulti; -export getopts; -export Matches; -export Fail_; -export fail_str; -export opt_present; -export opts_present; -export opt_str; -export opts_str; -export opt_strs; -export opt_maybe_str; -export opt_default; -export Result; //NDM enum Name { Long(~str), @@ -97,7 +79,7 @@ enum HasArg { Yes, No, Maybe, } enum Occur { Req, Optional, Multi, } /// A description of a possible option -type Opt = {name: Name, hasarg: HasArg, occur: Occur}; +pub type Opt = {name: Name, hasarg: HasArg, occur: Occur}; fn mkname(nm: &str) -> Name { let unm = str::from_slice(nm); @@ -134,22 +116,22 @@ impl Occur : Eq { } /// Create an option that is required and takes an argument -fn reqopt(name: &str) -> Opt { +pub fn reqopt(name: &str) -> Opt { return {name: mkname(name), hasarg: Yes, occur: Req}; } /// Create an option that is optional and takes an argument -fn optopt(name: &str) -> Opt { +pub fn optopt(name: &str) -> Opt { return {name: mkname(name), hasarg: Yes, occur: Optional}; } /// Create an option that is optional and does not take an argument -fn optflag(name: &str) -> Opt { +pub fn optflag(name: &str) -> Opt { return {name: mkname(name), hasarg: No, occur: Optional}; } /// Create an option that is optional and takes an optional argument -fn optflagopt(name: &str) -> Opt { +pub fn optflagopt(name: &str) -> Opt { return {name: mkname(name), hasarg: Maybe, occur: Optional}; } @@ -157,7 +139,7 @@ fn optflagopt(name: &str) -> Opt { * Create an option that is optional, takes an argument, and may occur * multiple times */ -fn optmulti(name: &str) -> Opt { +pub fn optmulti(name: &str) -> Opt { return {name: mkname(name), hasarg: Yes, occur: Multi}; } @@ -167,7 +149,7 @@ enum Optval { Val(~str), Given, } * The result of checking command line arguments. Contains a vector * of matches and a vector of free strings. */ -type Matches = {opts: ~[Opt], vals: ~[~[Optval]], free: ~[~str]}; +pub type Matches = {opts: ~[Opt], vals: ~[~[Optval]], free: ~[~str]}; fn is_arg(arg: &str) -> bool { return str::len(arg) > 1u && arg[0] == '-' as u8; @@ -188,7 +170,7 @@ fn find_opt(opts: &[Opt], +nm: Name) -> Option { * The type returned when the command line does not conform to the * expected format. Pass this value to to get an error message. */ -enum Fail_ { +pub enum Fail_ { ArgumentMissing(~str), UnrecognizedOption(~str), OptionMissing(~str), @@ -197,7 +179,7 @@ enum Fail_ { } /// Convert a `fail_` enum into an error string -fn fail_str(+f: Fail_) -> ~str { +pub fn fail_str(+f: Fail_) -> ~str { return match f { ArgumentMissing(ref nm) => { ~"Argument to option '" + *nm + ~"' missing." @@ -221,7 +203,7 @@ fn fail_str(+f: Fail_) -> ~str { * The result of parsing a command line with a set of options * (result::t) */ -type Result = result::Result; +pub type Result = result::Result; /** * Parse command line arguments according to the provided options @@ -230,7 +212,7 @@ type Result = result::Result; * `opt_str`, etc. to interrogate results. Returns `err(Fail_)` on failure. * Use to get an error message. */ -fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { +pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { let n_opts = vec::len::(opts); fn f(+_x: uint) -> ~[Optval] { return ~[]; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); @@ -366,12 +348,12 @@ fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] { fn opt_val(+mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; } /// Returns true if an option was matched -fn opt_present(+mm: Matches, nm: &str) -> bool { +pub fn opt_present(+mm: Matches, nm: &str) -> bool { return vec::len::(opt_vals(mm, nm)) > 0u; } /// Returns true if any of several options were matched -fn opts_present(+mm: Matches, names: &[~str]) -> bool { +pub fn opts_present(+mm: Matches, names: &[~str]) -> bool { for vec::each(names) |nm| { match find_opt(mm.opts, mkname(*nm)) { Some(_) => return true, @@ -388,7 +370,7 @@ fn opts_present(+mm: Matches, names: &[~str]) -> bool { * Fails if the option was not matched or if the match did not take an * argument */ -fn opt_str(+mm: Matches, nm: &str) -> ~str { +pub fn opt_str(+mm: Matches, nm: &str) -> ~str { return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; } @@ -398,7 +380,7 @@ fn opt_str(+mm: Matches, nm: &str) -> ~str { * Fails if the no option was provided from the given list, or if the no such * option took an argument */ -fn opts_str(+mm: Matches, names: &[~str]) -> ~str { +pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str { for vec::each(names) |nm| { match opt_val(mm, *nm) { Val(copy s) => return s, @@ -415,7 +397,7 @@ fn opts_str(+mm: Matches, names: &[~str]) -> ~str { * * Used when an option accepts multiple values. */ -fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { +pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(mm, nm)) |v| { match *v { Val(copy s) => acc.push(s), _ => () } @@ -424,7 +406,7 @@ fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { } /// Returns the string argument supplied to a matching option or none -fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { +pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } return match vals[0] { @@ -441,7 +423,7 @@ fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { * present but no argument was provided, and the argument if the option was * present and an argument was provided. */ -fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> { +pub fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } return match vals[0] { Val(copy s) => Some::<~str>(s), diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 251a492bb5b..202cb4932db 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -92,9 +92,7 @@ mod treemap; mod ebml; mod ebml2; mod dbg; -#[legacy_exports] mod getopts; -#[legacy_exports] mod json; mod sha1; mod md4; -- cgit 1.4.1-3-g733a5 From f33539e446d6f41d4a3296ed50a8f968e7950483 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Wed, 3 Oct 2012 12:21:48 -0700 Subject: Remove uses of + mode from libstd More or less the same as my analogous commit for libcore. Had to remove the forbid(deprecated_modes) pragma from some files -- will restore it after the snapshot. --- src/libstd/arc.rs | 22 +++++++++--------- src/libstd/bitv.rs | 4 ++-- src/libstd/cell.rs | 6 ++--- src/libstd/dbg.rs | 8 +++---- src/libstd/deque.rs | 14 ++++++------ src/libstd/getopts.rs | 25 ++++++++++---------- src/libstd/json.rs | 4 ++-- src/libstd/list.rs | 2 +- src/libstd/map.rs | 52 +++++++++++++++++++++--------------------- src/libstd/net_tcp.rs | 14 ++++++------ src/libstd/net_url.rs | 12 +++++----- src/libstd/rope.rs | 4 ++-- src/libstd/smallintmap.rs | 20 ++++++++-------- src/libstd/std.rc | 3 --- src/libstd/sync.rs | 14 ++++++------ src/libstd/test.rs | 4 ++-- src/libstd/time.rs | 4 ++-- src/libstd/timer.rs | 4 ++-- src/libstd/uv_iotask.rs | 4 ++-- src/libstd/uv_ll.rs | 6 ++--- src/test/bench/graph500-bfs.rs | 2 +- 21 files changed, 113 insertions(+), 115 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 9d15deab660..60db62ce01a 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap /** * Concurrency-enabled mechanisms for sharing mutable and/or immutable state * between tasks. @@ -66,7 +66,7 @@ impl &Condvar { struct ARC { x: SharedMutableState } /// Create an atomically reference counted wrapper. -pub fn ARC(+data: T) -> ARC { +pub fn ARC(data: T) -> ARC { ARC { x: unsafe { shared_mutable_state(move data) } } } @@ -98,7 +98,7 @@ pub fn clone(rc: &ARC) -> ARC { * unwrap from a task that holds another reference to the same ARC; it is * guaranteed to deadlock. */ -fn unwrap(+rc: ARC) -> T { +fn unwrap(rc: ARC) -> T { let ARC { x: x } <- rc; unsafe { unwrap_shared_mutable_state(move x) } } @@ -113,14 +113,14 @@ struct MutexARCInner { lock: Mutex, failed: bool, data: T } struct MutexARC { x: SharedMutableState> } /// Create a mutex-protected ARC with the supplied data. -pub fn MutexARC(+user_data: T) -> MutexARC { +pub fn MutexARC(user_data: T) -> MutexARC { mutex_arc_with_condvars(move user_data, 1) } /** * Create a mutex-protected ARC with the supplied data and a specified number * of condvars (as sync::mutex_with_condvars). */ -pub fn mutex_arc_with_condvars(+user_data: T, +pub fn mutex_arc_with_condvars(user_data: T, num_condvars: uint) -> MutexARC { let data = MutexARCInner { lock: mutex_with_condvars(num_condvars), @@ -191,7 +191,7 @@ impl &MutexARC { * Will additionally fail if another task has failed while accessing the arc. */ // FIXME(#2585) make this a by-move method on the arc -pub fn unwrap_mutex_arc(+arc: MutexARC) -> T { +pub fn unwrap_mutex_arc(arc: MutexARC) -> T { let MutexARC { x: x } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let MutexARCInner { failed: failed, data: data, _ } <- inner; @@ -247,14 +247,14 @@ struct RWARC { } /// Create a reader/writer ARC with the supplied data. -pub fn RWARC(+user_data: T) -> RWARC { +pub fn RWARC(user_data: T) -> RWARC { rw_arc_with_condvars(move user_data, 1) } /** * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -pub fn rw_arc_with_condvars(+user_data: T, +pub fn rw_arc_with_condvars(user_data: T, num_condvars: uint) -> RWARC { let data = RWARCInner { lock: rwlock_with_condvars(num_condvars), @@ -334,7 +334,7 @@ impl &RWARC { * } * ~~~ */ - fn write_downgrade(blk: fn(+v: RWWriteMode) -> U) -> U { + fn write_downgrade(blk: fn(v: RWWriteMode) -> U) -> U { let state = unsafe { get_shared_mutable_state(&self.x) }; do borrow_rwlock(state).write_downgrade |write_mode| { check_poison(false, state.failed); @@ -344,7 +344,7 @@ impl &RWARC { } /// To be called inside of the write_downgrade block. - fn downgrade(+token: RWWriteMode/&a) -> RWReadMode/&a { + fn downgrade(token: RWWriteMode/&a) -> RWReadMode/&a { // The rwlock should assert that the token belongs to us for us. let state = unsafe { get_shared_immutable_state(&self.x) }; let RWWriteMode((data, t, _poison)) <- token; @@ -369,7 +369,7 @@ impl &RWARC { * in write mode. */ // FIXME(#2585) make this a by-move method on the arc -pub fn unwrap_rw_arc(+arc: RWARC) -> T { +pub fn unwrap_rw_arc(arc: RWARC) -> T { let RWARC { x: x, _ } <- arc; let inner = unsafe { unwrap_shared_mutable_state(move x) }; let RWARCInner { failed: failed, data: data, _ } <- inner; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index bb556ed2ca3..77f0d39c338 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use vec::{to_mut, from_elem}; @@ -95,7 +95,7 @@ struct BigBitv { mut storage: ~[mut uint] } -fn BigBitv(+storage: ~[mut uint]) -> BigBitv { +fn BigBitv(storage: ~[mut uint]) -> BigBitv { BigBitv {storage: storage} } diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 43e47e1e1a9..866dbce1c08 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap /// A dynamic, mutable location. /// /// Similar to a mutable option type, but friendlier. @@ -8,7 +8,7 @@ pub struct Cell { } /// Creates a new full cell with the given value. -pub fn Cell(+value: T) -> Cell { +pub fn Cell(value: T) -> Cell { Cell { value: Some(move value) } } @@ -29,7 +29,7 @@ impl Cell { } /// Returns the value, failing if the cell is full. - fn put_back(+value: T) { + fn put_back(value: T) { if !self.is_empty() { fail ~"attempt to put a value back into a full cell"; } diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs index df97df51643..f85d4655ad1 100644 --- a/src/libstd/dbg.rs +++ b/src/libstd/dbg.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap //! Unsafe debugging functions for inspecting values. use cast::reinterpret_cast; @@ -20,7 +20,7 @@ pub fn debug_tydesc() { rustrt::debug_tydesc(sys::get_type_desc::()); } -pub fn debug_opaque(+x: T) { +pub fn debug_opaque(x: T) { rustrt::debug_opaque(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } @@ -28,11 +28,11 @@ pub fn debug_box(x: @T) { rustrt::debug_box(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } -pub fn debug_tag(+x: T) { +pub fn debug_tag(x: T) { rustrt::debug_tag(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } -pub fn debug_fn(+x: T) { +pub fn debug_fn(x: T) { rustrt::debug_fn(sys::get_type_desc::(), ptr::addr_of(&x) as *()); } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index da05174a6f5..f4fbc11c4f7 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -1,5 +1,5 @@ //! A deque. Untested as of yet. Likely buggy -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap #[forbid(non_camel_case_types)]; use option::{Some, None}; @@ -8,8 +8,8 @@ use core::cmp::{Eq}; pub trait Deque { fn size() -> uint; - fn add_front(+v: T); - fn add_back(+v: T); + fn add_front(v: T); + fn add_back(v: T); fn pop_front() -> T; fn pop_back() -> T; fn peek_front() -> T; @@ -27,7 +27,7 @@ pub fn create() -> Deque { * Grow is only called on full elts, so nelts is also len(elts), unlike * elsewhere. */ - fn grow(nelts: uint, lo: uint, +elts: ~[Cell]) + fn grow(nelts: uint, lo: uint, elts: ~[Cell]) -> ~[Cell] { let mut elts = move elts; assert (nelts == vec::len(elts)); @@ -55,7 +55,7 @@ pub fn create() -> Deque { impl Repr: Deque { fn size() -> uint { return self.nelts; } - fn add_front(+t: T) { + fn add_front(t: T) { let oldlo: uint = self.lo; if self.lo == 0u { self.lo = self.elts.len() - 1u; @@ -68,7 +68,7 @@ pub fn create() -> Deque { self.elts.set_elt(self.lo, Some(t)); self.nelts += 1u; } - fn add_back(+t: T) { + fn add_back(t: T) { if self.lo == self.hi && self.nelts != 0u { self.elts.swap(|v| grow(self.nelts, self.lo, move v)); self.lo = 0u; @@ -200,7 +200,7 @@ mod tests { assert (deq.get(3) == d); } - fn test_parameterized(+a: T, +b: T, +c: T, +d: T) { + fn test_parameterized(a: T, +b: T, +c: T, +d: T) { let deq: deque::Deque = deque::create::(); assert (deq.size() == 0u); deq.add_front(a); diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 9d127f5db47..8fd775c4773 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -62,7 +62,7 @@ * } */ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use core::cmp::Eq; use core::result::{Err, Ok}; @@ -179,7 +179,7 @@ pub enum Fail_ { } /// Convert a `fail_` enum into an error string -pub fn fail_str(+f: Fail_) -> ~str { +pub fn fail_str(f: Fail_) -> ~str { return match f { ArgumentMissing(ref nm) => { ~"Argument to option '" + *nm + ~"' missing." @@ -335,7 +335,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe { free: free}); } -fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] { +fn opt_vals(mm: Matches, nm: &str) -> ~[Optval] { return match find_opt(mm.opts, mkname(nm)) { Some(id) => mm.vals[id], None => { @@ -345,15 +345,15 @@ fn opt_vals(+mm: Matches, nm: &str) -> ~[Optval] { }; } -fn opt_val(+mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; } +fn opt_val(mm: Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; } /// Returns true if an option was matched -pub fn opt_present(+mm: Matches, nm: &str) -> bool { +pub fn opt_present(mm: Matches, nm: &str) -> bool { return vec::len::(opt_vals(mm, nm)) > 0u; } /// Returns true if any of several options were matched -pub fn opts_present(+mm: Matches, names: &[~str]) -> bool { +pub fn opts_present(mm: Matches, names: &[~str]) -> bool { for vec::each(names) |nm| { match find_opt(mm.opts, mkname(*nm)) { Some(_) => return true, @@ -370,7 +370,7 @@ pub fn opts_present(+mm: Matches, names: &[~str]) -> bool { * Fails if the option was not matched or if the match did not take an * argument */ -pub fn opt_str(+mm: Matches, nm: &str) -> ~str { +pub fn opt_str(mm: Matches, nm: &str) -> ~str { return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; } @@ -380,7 +380,8 @@ pub fn opt_str(+mm: Matches, nm: &str) -> ~str { * Fails if the no option was provided from the given list, or if the no such * option took an argument */ -pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str { +pub fn opts_str(mm: Matches, names: &[~str]) -> ~str { +>>>>>>> Remove uses of + mode from libstd for vec::each(names) |nm| { match opt_val(mm, *nm) { Val(copy s) => return s, @@ -397,7 +398,7 @@ pub fn opts_str(+mm: Matches, names: &[~str]) -> ~str { * * Used when an option accepts multiple values. */ -pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { +pub fn opt_strs(mm: Matches, nm: &str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(mm, nm)) |v| { match *v { Val(copy s) => acc.push(s), _ => () } @@ -406,7 +407,7 @@ pub fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] { } /// Returns the string argument supplied to a matching option or none -pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { +pub fn opt_maybe_str(mm: Matches, nm: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } return match vals[0] { @@ -423,7 +424,7 @@ pub fn opt_maybe_str(+mm: Matches, nm: &str) -> Option<~str> { * present but no argument was provided, and the argument if the option was * present and an argument was provided. */ -pub fn opt_default(+mm: Matches, nm: &str, def: &str) -> Option<~str> { +pub fn opt_default(mm: Matches, nm: &str, def: &str) -> Option<~str> { let vals = opt_vals(mm, nm); if vec::len::(vals) == 0u { return None::<~str>; } return match vals[0] { Val(copy s) => Some::<~str>(s), @@ -451,7 +452,7 @@ mod tests { use opt = getopts; use result::{Err, Ok}; - fn check_fail_type(+f: Fail_, ft: FailType) { + fn check_fail_type(f: Fail_, ft: FailType) { match f { ArgumentMissing(_) => assert ft == ArgumentMissing_, UnrecognizedOption(_) => assert ft == UnrecognizedOption_, diff --git a/src/libstd/json.rs b/src/libstd/json.rs index d3713bdb29d..f244f2869a6 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -1,6 +1,6 @@ // Rust JSON serialization library // Copyright (c) 2011 Google Inc. -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap #[forbid(non_camel_case_types)]; //! json serialization @@ -370,7 +370,7 @@ priv impl Parser { self.ch } - fn error(+msg: ~str) -> Result { + fn error(msg: ~str) -> Result { Err(Error { line: self.line, col: self.col, msg: @msg }) } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5b0931ebdee..4ff493f5ab9 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -29,7 +29,7 @@ pub fn from_vec(v: &[T]) -> @List { * * z - The initial value * * f - The function to apply */ -pub fn foldl(+z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { +pub fn foldl(z: T, ls: @List, f: fn((&T), (&U)) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 84fee092562..cc42c562376 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -1,6 +1,6 @@ //! A map type -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use io::WriterUtil; use to_str::ToStr; @@ -28,10 +28,10 @@ pub trait Map { * * Returns true if the key did not already exist in the map */ - fn insert(+v: K, +v: V) -> bool; + fn insert(v: K, +v: V) -> bool; /// Returns true if the map contains a value for the specified key - fn contains_key(+key: K) -> bool; + fn contains_key(key: K) -> bool; /// Returns true if the map contains a value for the specified /// key, taking the key by reference. @@ -41,31 +41,31 @@ pub trait Map { * Get the value for the specified key. Fails if the key does not exist in * the map. */ - fn get(+key: K) -> V; + fn get(key: K) -> V; /** * Get the value for the specified key. If the key does not exist in * the map then returns none. */ - pure fn find(+key: K) -> Option; + pure fn find(key: K) -> Option; /** * Remove and return a value from the map. Returns true if the * key was present in the map, otherwise false. */ - fn remove(+key: K) -> bool; + fn remove(key: K) -> bool; /// Clear the map, removing all key/value pairs. fn clear(); /// Iterate over all the key/value pairs in the map by value - pure fn each(fn(+key: K, +value: V) -> bool); + pure fn each(fn(key: K, +value: V) -> bool); /// Iterate over all the keys in the map by value - pure fn each_key(fn(+key: K) -> bool); + pure fn each_key(fn(key: K) -> bool); /// Iterate over all the values in the map by value - pure fn each_value(fn(+value: V) -> bool); + pure fn each_value(fn(value: V) -> bool); /// Iterate over all the key/value pairs in the map by reference pure fn each_ref(fn(key: &K, value: &V) -> bool); @@ -201,7 +201,7 @@ pub mod chained { impl T: Map { pure fn size() -> uint { self.count } - fn contains_key(+k: K) -> bool { + fn contains_key(k: K) -> bool { self.contains_key_ref(&k) } @@ -213,7 +213,7 @@ pub mod chained { } } - fn insert(+k: K, +v: V) -> bool { + fn insert(k: K, +v: V) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(&k, hash) { NotFound => { @@ -255,7 +255,7 @@ pub mod chained { } } - pure fn find(+k: K) -> Option { + pure fn find(k: K) -> Option { unsafe { match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { NotFound => None, @@ -265,7 +265,7 @@ pub mod chained { } } - fn get(+k: K) -> V { + fn get(k: K) -> V { let opt_v = self.find(k); if opt_v.is_none() { fail fmt!("Key not found in table: %?", k); @@ -273,7 +273,7 @@ pub mod chained { option::unwrap(move opt_v) } - fn remove(+k: K) -> bool { + fn remove(k: K) -> bool { match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { NotFound => false, FoundFirst(idx, entry) => { @@ -294,15 +294,15 @@ pub mod chained { self.chains = chains(initial_capacity); } - pure fn each(blk: fn(+key: K, +value: V) -> bool) { + pure fn each(blk: fn(key: K, +value: V) -> bool) { self.each_ref(|k, v| blk(*k, *v)) } - pure fn each_key(blk: fn(+key: K) -> bool) { + pure fn each_key(blk: fn(key: K) -> bool) { self.each_key_ref(|p| blk(*p)) } - pure fn each_value(blk: fn(+value: V) -> bool) { + pure fn each_value(blk: fn(value: V) -> bool) { self.each_value_ref(|p| blk(*p)) } @@ -377,7 +377,7 @@ pub fn HashMap() } /// Convenience function for adding keys to a hashmap with nil type keys -pub fn set_add(set: Set, +key: K) -> bool { +pub fn set_add(set: Set, key: K) -> bool { set.insert(key, ()) } @@ -415,13 +415,13 @@ impl @Mut>: } } - fn insert(+key: K, +value: V) -> bool { + fn insert(key: K, value: V) -> bool { do self.borrow_mut |p| { p.insert(key, value) } } - fn contains_key(+key: K) -> bool { + fn contains_key(key: K) -> bool { do self.borrow_const |p| { p.contains_key(&key) } @@ -433,13 +433,13 @@ impl @Mut>: } } - fn get(+key: K) -> V { + fn get(key: K) -> V { do self.borrow_const |p| { p.get(&key) } } - pure fn find(+key: K) -> Option { + pure fn find(key: K) -> Option { unsafe { do self.borrow_const |p| { p.find(&key) @@ -447,7 +447,7 @@ impl @Mut>: } } - fn remove(+key: K) -> bool { + fn remove(key: K) -> bool { do self.borrow_mut |p| { p.remove(&key) } @@ -459,7 +459,7 @@ impl @Mut>: } } - pure fn each(op: fn(+key: K, +value: V) -> bool) { + pure fn each(op: fn(key: K, +value: V) -> bool) { unsafe { do self.borrow_imm |p| { p.each(|k, v| op(*k, *v)) @@ -467,7 +467,7 @@ impl @Mut>: } } - pure fn each_key(op: fn(+key: K) -> bool) { + pure fn each_key(op: fn(key: K) -> bool) { unsafe { do self.borrow_imm |p| { p.each_key(|k| op(*k)) @@ -475,7 +475,7 @@ impl @Mut>: } } - pure fn each_value(op: fn(+value: V) -> bool) { + pure fn each_value(op: fn(value: V) -> bool) { unsafe { do self.borrow_imm |p| { p.each_value(|v| op(*v)) diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 59cb0d36f77..be38f16aff7 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -129,7 +129,7 @@ enum TcpConnectErrData { * the remote host. In the event of failure, a * `net::tcp::tcp_connect_err_data` instance will be returned */ -fn connect(+input_ip: ip::IpAddr, port: uint, +fn connect(input_ip: ip::IpAddr, port: uint, iotask: IoTask) -> result::Result unsafe { let result_po = core::comm::Port::(); @@ -570,7 +570,7 @@ fn accept(new_conn: TcpNewConnection) * successful/normal shutdown, and a `tcp_listen_err_data` enum in the event * of listen exiting because of an error */ -fn listen(+host_ip: ip::IpAddr, port: uint, backlog: uint, +fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: IoTask, +on_establish_cb: fn~(comm::Chan>), +new_connect_cb: fn~(TcpNewConnection, @@ -587,7 +587,7 @@ fn listen(+host_ip: ip::IpAddr, port: uint, backlog: uint, } } -fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, +fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: IoTask, +on_establish_cb: fn~(comm::Chan>), +on_connect_cb: fn~(*uv::ll::uv_tcp_t)) @@ -728,7 +728,7 @@ fn listen_common(+host_ip: ip::IpAddr, port: uint, backlog: uint, * * A buffered wrapper that you can cast as an `io::reader` or `io::writer` */ -fn socket_buf(+sock: TcpSocket) -> TcpSocketBuf { +fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { TcpSocketBuf(@{ sock: move sock, mut buf: ~[] }) } @@ -738,7 +738,7 @@ impl TcpSocket { result::Result<~[u8], TcpErrData>>, TcpErrData> { read_start(&self) } - fn read_stop(+read_port: + fn read_stop(read_port: comm::Port>) -> result::Result<(), TcpErrData> { read_stop(&self, move read_port) @@ -1476,7 +1476,7 @@ mod test { */ } - fn buf_write(+w: &W, val: &str) { + fn buf_write(w: &W, val: &str) { log(debug, fmt!("BUF_WRITE: val len %?", str::len(val))); do str::byte_slice(val) |b_slice| { log(debug, fmt!("BUF_WRITE: b_slice len %?", @@ -1485,7 +1485,7 @@ mod test { } } - fn buf_read(+r: &R, len: uint) -> ~str { + fn buf_read(r: &R, len: uint) -> ~str { let new_bytes = (*r).read_bytes(len); log(debug, fmt!("in buf_read.. new_bytes len: %?", vec::len(new_bytes))); diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 920751d690f..6dca075405b 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -1,5 +1,5 @@ //! Types/fns concerning URLs (see RFC 3986) -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after a snapshot use core::cmp::Eq; use map::HashMap; @@ -36,7 +36,7 @@ type UserInfo = { type Query = ~[(~str, ~str)]; -fn Url(+scheme: ~str, +user: Option, +host: ~str, +fn Url(scheme: ~str, +user: Option, +host: ~str, +port: Option<~str>, +path: ~str, +query: Query, +fragment: Option<~str>) -> Url { Url { scheme: move scheme, user: move user, host: move host, @@ -44,7 +44,7 @@ fn Url(+scheme: ~str, +user: Option, +host: ~str, fragment: move fragment } } -fn UserInfo(+user: ~str, +pass: Option<~str>) -> UserInfo { +fn UserInfo(user: ~str, +pass: Option<~str>) -> UserInfo { {user: move user, pass: move pass} } @@ -306,7 +306,7 @@ fn userinfo_from_str(uinfo: &str) -> UserInfo { return UserInfo(user, pass); } -fn userinfo_to_str(+userinfo: UserInfo) -> ~str { +fn userinfo_to_str(userinfo: UserInfo) -> ~str { if option::is_some(&userinfo.pass) { return str::concat(~[copy userinfo.user, ~":", option::unwrap(copy userinfo.pass), @@ -334,7 +334,7 @@ fn query_from_str(rawquery: &str) -> Query { return query; } -fn query_to_str(+query: Query) -> ~str { +fn query_to_str(query: Query) -> ~str { let mut strvec = ~[]; for query.each |kv| { let (k, v) = copy *kv; @@ -681,7 +681,7 @@ impl Url : FromStr { * result in just "http://somehost.com". * */ -fn to_str(+url: Url) -> ~str { +fn to_str(url: Url) -> ~str { let user = if url.user.is_some() { userinfo_to_str(option::unwrap(copy url.user)) } else { diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index d14a4854555..5df4fc10a03 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -379,7 +379,7 @@ Section: Iterating * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub fn loop_chars(rope: Rope, it: fn(+c: char) -> bool) -> bool { +pub fn loop_chars(rope: Rope, it: fn(c: char) -> bool) -> bool { match (rope) { node::Empty => return true, node::Content(x) => return node::loop_chars(x, it) @@ -1037,7 +1037,7 @@ mod node { return result; } - pub fn loop_chars(node: @Node, it: fn(+c: char) -> bool) -> bool { + pub fn loop_chars(node: @Node, it: fn(c: char) -> bool) -> bool { return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 2e7f47e0af0..58ecbb0d6c3 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -2,7 +2,7 @@ * A simple map based on a vector for small integer keys. Space requirements * are O(highest integer key). */ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use core::option; use core::option::{Some, None}; @@ -28,7 +28,7 @@ pub fn mk() -> SmallIntMap { * the specified key then the original value is replaced. */ #[inline(always)] -pub fn insert(self: SmallIntMap, key: uint, +val: T) { +pub fn insert(self: SmallIntMap, key: uint, val: T) { //io::println(fmt!("%?", key)); self.v.grow_set_elt(key, &None, Some(val)); } @@ -77,12 +77,12 @@ impl SmallIntMap: map::Map { sz } #[inline(always)] - fn insert(+key: uint, +value: V) -> bool { + fn insert(key: uint, value: V) -> bool { let exists = contains_key(self, key); insert(self, key, value); return !exists; } - fn remove(+key: uint) -> bool { + fn remove(key: uint) -> bool { if key >= self.v.len() { return false; } @@ -93,23 +93,23 @@ impl SmallIntMap: map::Map { fn clear() { self.v.set(~[]); } - fn contains_key(+key: uint) -> bool { + fn contains_key(key: uint) -> bool { contains_key(self, key) } fn contains_key_ref(key: &uint) -> bool { contains_key(self, *key) } - fn get(+key: uint) -> V { get(self, key) } - pure fn find(+key: uint) -> Option { find(self, key) } + fn get(key: uint) -> V { get(self, key) } + pure fn find(key: uint) -> Option { find(self, key) } fn rehash() { fail } - pure fn each(it: fn(+key: uint, +value: V) -> bool) { + pure fn each(it: fn(key: uint, +value: V) -> bool) { self.each_ref(|k, v| it(*k, *v)) } - pure fn each_key(it: fn(+key: uint) -> bool) { + pure fn each_key(it: fn(key: uint) -> bool) { self.each_ref(|k, _v| it(*k)) } - pure fn each_value(it: fn(+value: V) -> bool) { + pure fn each_value(it: fn(value: V) -> bool) { self.each_ref(|_k, v| it(*v)) } pure fn each_ref(it: fn(key: &uint, value: &V) -> bool) { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 202cb4932db..683ea589b91 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -18,9 +18,6 @@ not required in or otherwise suitable for the core library. #[no_core]; -// tjc: Added legacy_modes back in because it still uses + mode. -// Remove once + mode gets expunged from std. -#[legacy_modes]; #[legacy_exports]; #[allow(vecs_implicitly_copyable)]; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index f66f2f5b5d3..f66134d3892 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -1,5 +1,5 @@ // NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap /** * The concurrency primitives you know and love. * @@ -69,7 +69,7 @@ struct SemInner { enum Sem = Exclusive>; #[doc(hidden)] -fn new_sem(count: int, +q: Q) -> Sem { +fn new_sem(count: int, q: Q) -> Sem { Sem(exclusive(SemInner { mut count: count, waiters: new_waitqueue(), blocked: q })) } @@ -535,7 +535,7 @@ impl &RWlock { * } * ~~~ */ - fn write_downgrade(blk: fn(+v: RWlockWriteMode) -> U) -> U { + fn write_downgrade(blk: fn(v: RWlockWriteMode) -> U) -> U { // Implementation slightly different from the slicker 'write's above. // The exit path is conditional on whether the caller downgrades. let mut _release = None; @@ -551,7 +551,7 @@ impl &RWlock { } /// To be called inside of the write_downgrade block. - fn downgrade(+token: RWlockWriteMode/&a) -> RWlockReadMode/&a { + fn downgrade(token: RWlockWriteMode/&a) -> RWlockReadMode/&a { if !ptr::ref_eq(self, token.lock) { fail ~"Can't downgrade() with a different rwlock's write_mode!"; } @@ -957,7 +957,7 @@ mod tests { drop { self.c.send(()); } } - fn SendOnFailure(+c: pipes::Chan<()>) -> SendOnFailure { + fn SendOnFailure(c: pipes::Chan<()>) -> SendOnFailure { SendOnFailure { c: c } @@ -1038,7 +1038,7 @@ mod tests { } } #[cfg(test)] - fn test_rwlock_exclusion(+x: ~RWlock, mode1: RWlockMode, + fn test_rwlock_exclusion(x: ~RWlock, mode1: RWlockMode, mode2: RWlockMode) { // Test mutual exclusion between readers and writers. Just like the // mutex mutual exclusion test, a ways above. @@ -1083,7 +1083,7 @@ mod tests { test_rwlock_exclusion(~RWlock(), Downgrade, Downgrade); } #[cfg(test)] - fn test_rwlock_handshake(+x: ~RWlock, mode1: RWlockMode, + fn test_rwlock_handshake(x: ~RWlock, mode1: RWlockMode, mode2: RWlockMode, make_mode2_go_first: bool) { // Much like sem_multi_resource. let x2 = ~x.clone(); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 1df10a4d799..c5d9dd343fa 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -270,7 +270,7 @@ enum TestEvent { type MonitorMsg = (TestDesc, TestResult); fn run_tests(opts: &TestOpts, tests: &[TestDesc], - callback: fn@(+e: TestEvent)) { + callback: fn@(e: TestEvent)) { let mut filtered_tests = filter_tests(opts, tests); callback(TeFiltered(copy filtered_tests)); @@ -379,7 +379,7 @@ fn filter_tests(opts: &TestOpts, type TestFuture = {test: TestDesc, wait: fn@() -> TestResult}; -fn run_test(+test: TestDesc, monitor_ch: comm::Chan) { +fn run_test(test: TestDesc, monitor_ch: comm::Chan) { if test.ignore { core::comm::send(monitor_ch, (copy test, TrIgnored)); return; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 43cbc6da9bd..aef3bb2ac0a 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -1,4 +1,4 @@ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use core::cmp::Eq; use libc::{c_char, c_int, c_long, size_t, time_t}; @@ -589,7 +589,7 @@ pub fn strptime(s: &str, format: &str) -> Result { } } -fn strftime(format: &str, +tm: Tm) -> ~str { +fn strftime(format: &str, tm: Tm) -> ~str { fn parse_type(ch: char, tm: &Tm) -> ~str { //FIXME (#2350): Implement missing types. let die = || #fmt("strftime: can't understand this format %c ", diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 8aaf7d3fd87..2aca87b942e 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -1,6 +1,6 @@ //! Utilities that leverage libuv's `uv_timer_*` API -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after snap use uv = uv; use uv::iotask; @@ -24,7 +24,7 @@ use comm = core::comm; * * val - a value of type T to send over the provided `ch` */ pub fn delayed_send(iotask: IoTask, - msecs: uint, ch: comm::Chan, +val: T) { + msecs: uint, ch: comm::Chan, val: T) { unsafe { let timer_done_po = core::comm::Port::<()>(); let timer_done_ch = core::comm::Chan(timer_done_po); diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 876aa6f4af0..4a4a34704be 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -5,7 +5,7 @@ * `interact` function you can execute code in a uv callback. */ -#[forbid(deprecated_mode)]; +// tjc: forbid deprecated modes again after a snapshot use libc::c_void; use ptr::p2::addr_of; @@ -22,7 +22,7 @@ pub enum IoTask { }) } -pub fn spawn_iotask(+task: task::TaskBuilder) -> IoTask { +pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask { do listen |iotask_ch| { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index f0594475d04..50636054821 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -642,7 +642,7 @@ extern mod rustrt { fn rust_uv_addrinfo_as_sockaddr_in(input: *addrinfo) -> *sockaddr_in; fn rust_uv_addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6; fn rust_uv_malloc_buf_base_of(sug_size: libc::size_t) -> *u8; - fn rust_uv_free_base_of_buf(++buf: uv_buf_t); + fn rust_uv_free_base_of_buf(+buf: uv_buf_t); fn rust_uv_get_stream_handle_from_connect_req( connect_req: *uv_connect_t) -> *uv_stream_t; @@ -661,8 +661,8 @@ extern mod rustrt { fn rust_uv_get_data_for_req(req: *libc::c_void) -> *libc::c_void; fn rust_uv_set_data_for_req(req: *libc::c_void, data: *libc::c_void); - fn rust_uv_get_base_from_buf(++buf: uv_buf_t) -> *u8; - fn rust_uv_get_len_from_buf(++buf: uv_buf_t) -> libc::size_t; + fn rust_uv_get_base_from_buf(+buf: uv_buf_t) -> *u8; + fn rust_uv_get_len_from_buf(+buf: uv_buf_t) -> libc::size_t; // sizeof testing helpers fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint; diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index f35a3ce735f..a34fcc89c04 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -251,7 +251,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { colors = do par::mapi_factory(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(i: uint, c: color) -> color { + fn~(+i: uint, +c: color) -> color { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); -- cgit 1.4.1-3-g733a5 From 35598b4595ec6b7ae4ea6c0244f775651366fe9e Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 3 Oct 2012 16:43:56 -0700 Subject: De-export net::*. Part of #3583. --- src/libstd/net.rs | 11 +++-------- src/libstd/net_ip.rs | 35 +++++++++++++--------------------- src/libstd/net_tcp.rs | 52 +++++++++++++++++---------------------------------- src/libstd/net_url.rs | 35 +++++++++++++--------------------- src/libstd/std.rc | 4 ---- 5 files changed, 46 insertions(+), 91 deletions(-) (limited to 'src/libstd/std.rc') diff --git a/src/libstd/net.rs b/src/libstd/net.rs index 8665ea2e9cf..76a5955c3e1 100644 --- a/src/libstd/net.rs +++ b/src/libstd/net.rs @@ -1,10 +1,5 @@ //! Top-level module for network-related functionality -use tcp = net_tcp; -export tcp; - -use ip = net_ip; -export ip; - -use url = net_url; -export url; \ No newline at end of file +pub use tcp = net_tcp; +pub use ip = net_ip; +pub use url = net_url; diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 9aa29df4a62..2d9dd5bdf4e 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -20,14 +20,8 @@ use get_data_for_req = uv::ll::get_data_for_req; use ll = uv::ll; use comm = core::comm; -export IpAddr, parse_addr_err; -export format_addr; -export v4, v6; -export get_addr; -export Ipv4, Ipv6; - /// An IP address -enum IpAddr { +pub enum IpAddr { /// An IPv4 address Ipv4(sockaddr_in), Ipv6(sockaddr_in6) @@ -45,7 +39,7 @@ type ParseAddrErr = { * * * ip - a `std::net::ip::ip_addr` */ -fn format_addr(ip: &IpAddr) -> ~str { +pub fn format_addr(ip: &IpAddr) -> ~str { match *ip { Ipv4(ref addr) => unsafe { let result = uv_ip4_name(addr); @@ -83,7 +77,7 @@ enum IpGetAddrErr { * a vector of `ip_addr` results, in the case of success, or an error * object in the case of failure */ -fn get_addr(node: &str, iotask: iotask) +pub fn get_addr(node: &str, iotask: iotask) -> result::Result<~[IpAddr], IpGetAddrErr> { do core::comm::listen |output_ch| { do str::as_buf(node) |node_ptr, len| unsafe { @@ -116,8 +110,7 @@ fn get_addr(node: &str, iotask: iotask) } } -mod v4 { - #[legacy_exports]; +pub mod v4 { /** * Convert a str to `ip_addr` * @@ -133,7 +126,7 @@ mod v4 { * * * an `ip_addr` of the `ipv4` variant */ - fn parse_addr(ip: &str) -> IpAddr { + pub fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { result::Ok(copy addr) => addr, result::Err(ref err_data) => fail err_data.err_msg @@ -141,9 +134,9 @@ mod v4 { } // the simple, old style numberic representation of // ipv4 - type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 }; + pub type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 }; - trait AsUnsafeU32 { + pub trait AsUnsafeU32 { unsafe fn as_u32() -> u32; } @@ -153,7 +146,7 @@ mod v4 { *((ptr::addr_of(&self)) as *u32) } } - fn parse_to_ipv4_rep(ip: &str) -> result::Result { + pub fn parse_to_ipv4_rep(ip: &str) -> result::Result { let parts = vec::map(str::split_char(ip, '.'), |s| { match uint::from_str(*s) { Some(n) if n <= 255 => n, @@ -171,7 +164,7 @@ mod v4 { c: parts[2] as u8, d: parts[3] as u8}) } } - fn try_parse_addr(ip: &str) -> result::Result { + pub fn try_parse_addr(ip: &str) -> result::Result { unsafe { let INADDR_NONE = ll::get_INADDR_NONE(); let ip_rep_result = parse_to_ipv4_rep(ip); @@ -203,8 +196,7 @@ mod v4 { } } } -mod v6 { - #[legacy_exports]; +pub mod v6 { /** * Convert a str to `ip_addr` * @@ -220,13 +212,13 @@ mod v6 { * * * an `ip_addr` of the `ipv6` variant */ - fn parse_addr(ip: &str) -> IpAddr { + pub fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { result::Ok(copy addr) => addr, result::Err(copy err_data) => fail err_data.err_msg } } - fn try_parse_addr(ip: &str) -> result::Result { + pub fn try_parse_addr(ip: &str) -> result::Result { unsafe { // need to figure out how to establish a parse failure.. let new_addr = uv_ip6_addr(str::from_slice(ip), 22); @@ -251,7 +243,7 @@ type GetAddrData = { }; extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int, - res: *addrinfo) unsafe { + res: *addrinfo) unsafe { log(debug, ~"in get_addr_cb"); let handle_data = get_data_for_req(handle) as *GetAddrData; @@ -311,7 +303,6 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int, #[cfg(test)] mod test { - #[legacy_exports]; #[test] fn test_ip_ipv4_parse_and_format_ip() { let localhost_str = ~"127.0.0.1"; diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index be38f16aff7..546231da633 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -11,22 +11,8 @@ use libc::size_t; use io::{Reader, ReaderUtil, Writer}; use comm = core::comm; -// tcp interfaces -export TcpSocket; -// buffered socket -export TcpSocketBuf, socket_buf; -// errors -export TcpErrData, TcpConnectErrData; -// operations on a tcp_socket -export write, write_future, read_start, read_stop; -// tcp server stuff -export listen, accept; -// tcp client stuff -export connect; - #[nolink] extern mod rustrt { - #[legacy_exports]; fn rust_uv_current_kernel_malloc(size: libc::c_uint) -> *libc::c_void; fn rust_uv_current_kernel_free(mem: *libc::c_void); fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint; @@ -48,7 +34,7 @@ struct TcpSocket { } } -fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket { +pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket { TcpSocket { socket_data: socket_data } @@ -64,14 +50,14 @@ struct TcpSocketBuf { data: @TcpBufferedSocketData, } -fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf { +pub fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf { TcpSocketBuf { data: data } } /// Contains raw, string-based, error information returned from libuv -type TcpErrData = { +pub type TcpErrData = { err_name: ~str, err_msg: ~str }; @@ -103,7 +89,7 @@ enum TcpListenErrData { AccessDenied } /// Details returned as part of a `result::err` result from `tcp::connect` -enum TcpConnectErrData { +pub enum TcpConnectErrData { /** * Some unplanned-for error. The first and second fields correspond * to libuv's `err_name` and `err_msg` fields, respectively. @@ -129,7 +115,7 @@ enum TcpConnectErrData { * the remote host. In the event of failure, a * `net::tcp::tcp_connect_err_data` instance will be returned */ -fn connect(input_ip: ip::IpAddr, port: uint, +pub fn connect(input_ip: ip::IpAddr, port: uint, iotask: IoTask) -> result::Result unsafe { let result_po = core::comm::Port::(); @@ -262,7 +248,7 @@ fn connect(input_ip: ip::IpAddr, port: uint, * A `result` object with a `nil` value as the `ok` variant, or a * `tcp_err_data` value as the `err` variant */ -fn write(sock: &TcpSocket, raw_write_data: ~[u8]) +pub fn write(sock: &TcpSocket, raw_write_data: ~[u8]) -> result::Result<(), TcpErrData> unsafe { let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data))); write_common_impl(socket_data_ptr, raw_write_data) @@ -299,7 +285,7 @@ fn write(sock: &TcpSocket, raw_write_data: ~[u8]) * `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data` * value as the `err` variant */ -fn write_future(sock: &TcpSocket, raw_write_data: ~[u8]) +pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8]) -> future::Future> unsafe { let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data))); do future_spawn { @@ -323,7 +309,7 @@ fn write_future(sock: &TcpSocket, raw_write_data: ~[u8]) * optionally, loop on) from until `read_stop` is called, or a * `tcp_err_data` record */ -fn read_start(sock: &TcpSocket) +pub fn read_start(sock: &TcpSocket) -> result::Result>, TcpErrData> unsafe { let socket_data = ptr::addr_of(&(*(sock.socket_data))); @@ -337,7 +323,7 @@ fn read_start(sock: &TcpSocket) * * * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on */ -fn read_stop(sock: &TcpSocket, +pub fn read_stop(sock: &TcpSocket, +read_port: comm::Port>) -> result::Result<(), TcpErrData> unsafe { log(debug, fmt!("taking the read_port out of commission %?", read_port)); @@ -472,7 +458,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint) * this function will return a `net::tcp::tcp_err_data` record * as the `err` variant of a `result`. */ -fn accept(new_conn: TcpNewConnection) +pub fn accept(new_conn: TcpNewConnection) -> result::Result unsafe { match new_conn{ @@ -570,7 +556,7 @@ fn accept(new_conn: TcpNewConnection) * successful/normal shutdown, and a `tcp_listen_err_data` enum in the event * of listen exiting because of an error */ -fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, +pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: IoTask, +on_establish_cb: fn~(comm::Chan>), +new_connect_cb: fn~(TcpNewConnection, @@ -728,17 +714,17 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint, * * A buffered wrapper that you can cast as an `io::reader` or `io::writer` */ -fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { +pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf { TcpSocketBuf(@{ sock: move sock, mut buf: ~[] }) } /// Convenience methods extending `net::tcp::tcp_socket` impl TcpSocket { - fn read_start() -> result::Result result::Result>, TcpErrData> { read_start(&self) } - fn read_stop(read_port: + pub fn read_stop(read_port: comm::Port>) -> result::Result<(), TcpErrData> { read_stop(&self, move read_port) @@ -751,11 +737,11 @@ impl TcpSocket { future::Future> { read_future(&self, timeout_msecs) } - fn write(raw_write_data: ~[u8]) + pub fn write(raw_write_data: ~[u8]) -> result::Result<(), TcpErrData> { write(&self, raw_write_data) } - fn write_future(raw_write_data: ~[u8]) + pub fn write_future(raw_write_data: ~[u8]) -> future::Future> { write_future(&self, raw_write_data) } @@ -816,7 +802,7 @@ impl TcpSocketBuf: io::Reader { /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` impl TcpSocketBuf: io::Writer { - fn write(data: &[const u8]) unsafe { + pub fn write(data: &[const u8]) unsafe { let socket_data_ptr = ptr::addr_of(&(*((*(self.data)).sock).socket_data)); let w_result = write_common_impl(socket_data_ptr, @@ -1224,16 +1210,13 @@ type TcpBufferedSocketData = { //#[cfg(test)] mod test { - #[legacy_exports]; // FIXME don't run on fbsd or linux 32 bit (#2064) #[cfg(target_os="win32")] #[cfg(target_os="darwin")] #[cfg(target_os="linux")] mod tcp_ipv4_server_and_client_test { - #[legacy_exports]; #[cfg(target_arch="x86_64")] mod impl64 { - #[legacy_exports]; #[test] fn test_gl_tcp_server_and_client_ipv4() unsafe { impl_gl_tcp_ipv4_server_and_client(); @@ -1258,7 +1241,6 @@ mod test { } #[cfg(target_arch="x86")] mod impl32 { - #[legacy_exports]; #[test] #[ignore(cfg(target_os = "linux"))] fn test_gl_tcp_server_and_client_ipv4() unsafe { diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 6dca075405b..40c9f96f5e8 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -10,15 +10,6 @@ use result::{Err, Ok}; use to_str::ToStr; use to_bytes::IterBytes; -export Url, Query; -export from_str, to_str; -export get_scheme; -export query_to_str; - -export encode, decode; -export encode_component, decode_component; -export encode_form_urlencoded, decode_form_urlencoded; - struct Url { scheme: ~str, user: Option, @@ -34,9 +25,9 @@ type UserInfo = { pass: Option<~str> }; -type Query = ~[(~str, ~str)]; +pub type Query = ~[(~str, ~str)]; -fn Url(scheme: ~str, +user: Option, +host: ~str, +pub fn Url(scheme: ~str, +user: Option, +host: ~str, +port: Option<~str>, +path: ~str, +query: Query, +fragment: Option<~str>) -> Url { Url { scheme: move scheme, user: move user, host: move host, @@ -93,7 +84,7 @@ fn encode_inner(s: &str, full_url: bool) -> ~str { * * This function is compliant with RFC 3986. */ -fn encode(s: &str) -> ~str { +pub fn encode(s: &str) -> ~str { encode_inner(s, true) } @@ -103,7 +94,7 @@ fn encode(s: &str) -> ~str { * * This function is compliant with RFC 3986. */ -fn encode_component(s: &str) -> ~str { +pub fn encode_component(s: &str) -> ~str { encode_inner(s, false) } @@ -150,14 +141,14 @@ fn decode_inner(s: &str, full_url: bool) -> ~str { * * This will only decode escape sequences generated by encode_uri. */ -fn decode(s: &str) -> ~str { +pub fn decode(s: &str) -> ~str { decode_inner(s, true) } /** * Decode a string encoded with percent encoding. */ -fn decode_component(s: &str) -> ~str { +pub fn decode_component(s: &str) -> ~str { decode_inner(s, false) } @@ -183,7 +174,7 @@ fn encode_plus(s: &str) -> ~str { /** * Encode a hashmap to the 'application/x-www-form-urlencoded' media type. */ -fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str { +pub fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str { let mut out = ~""; let mut first = true; @@ -209,7 +200,7 @@ fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str { * Decode a string encoded with the 'application/x-www-form-urlencoded' media * type into a hashmap. */ -fn decode_form_urlencoded(s: ~[u8]) -> +pub fn decode_form_urlencoded(s: ~[u8]) -> map::HashMap<~str, @dvec::DVec<@~str>> { do io::with_bytes_reader(s) |rdr| { let m = HashMap(); @@ -334,7 +325,7 @@ fn query_from_str(rawquery: &str) -> Query { return query; } -fn query_to_str(query: Query) -> ~str { +pub fn query_to_str(query: Query) -> ~str { let mut strvec = ~[]; for query.each |kv| { let (k, v) = copy *kv; @@ -344,7 +335,7 @@ fn query_to_str(query: Query) -> ~str { } // returns the scheme and the rest of the url, or a parsing error -fn get_scheme(rawurl: &str) -> result::Result<(~str, ~str), @~str> { +pub fn get_scheme(rawurl: &str) -> result::Result<(~str, ~str), @~str> { for str::each_chari(rawurl) |i,c| { match c { 'A' .. 'Z' | 'a' .. 'z' => loop, @@ -623,7 +614,7 @@ fn get_query_fragment(rawurl: &str) -> * */ -fn from_str(rawurl: &str) -> result::Result { +pub fn from_str(rawurl: &str) -> result::Result { // scheme let mut schm = get_scheme(rawurl); if result::is_err(&schm) { @@ -681,7 +672,7 @@ impl Url : FromStr { * result in just "http://somehost.com". * */ -fn to_str(url: Url) -> ~str { +pub fn to_str(url: Url) -> ~str { let user = if url.user.is_some() { userinfo_to_str(option::unwrap(copy url.user)) } else { @@ -713,7 +704,7 @@ fn to_str(url: Url) -> ~str { } impl Url: to_str::ToStr { - fn to_str() -> ~str { + pub fn to_str() -> ~str { to_str(self) } } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 683ea589b91..6a5658d24eb 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -44,13 +44,9 @@ export cell; // General io and system-services modules -#[legacy_exports] mod net; -#[legacy_exports] mod net_ip; -#[legacy_exports] mod net_tcp; -#[legacy_exports] mod net_url; // libuv modules -- cgit 1.4.1-3-g733a5