Skip to content

Commit ec0376a

Browse files
committed
---
yaml --- r: 139007 b: refs/heads/try2 c: 4bf5ad6 h: refs/heads/master i: 139005: 352d463 139003: 8a11520 138999: 8fbe7a9 138991: 6a9a792 138975: 75acddc 138943: d2b88e2 138879: 5a7c234 138751: 378c66c v: v3
1 parent f4bb7a8 commit ec0376a

File tree

263 files changed

+1780
-1368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+1780
-1368
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 34113dcf6a45d445bf557e6aa85dbc35bfd1f12a
8+
refs/heads/try2: 4bf5ad63f023320864dad323262364a476354d15
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/RELEASES.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Version 0.6 (March 2013)
1010
* Remove `static` keyword
1111
* Static method syntax
1212
* `as Trait`
13-
* `copy` removed?
13+
* `copy` removed, replaced with `Clone`?
14+
* `std::map` removed, replaced with `core::hashmap`
1415

1516
* Syntax changes
1617
* The self type parameter in traits is now spelled `Self`
@@ -38,7 +39,8 @@ Version 0.6 (March 2013)
3839
* Trait implementations no longer support visibility modifiers
3940

4041
* Semantic changes
41-
* Linear types move by default, eliminating the `move` keyword
42+
* Types with owned pointers or custom destructors move by default,
43+
eliminating the `move` keyword
4244
* All foreign functions are considered unsafe
4345
* &mut is now unaliasable
4446
* Writes to borrowed @mut pointers are prevented dynamically
@@ -57,16 +59,19 @@ Version 0.6 (March 2013)
5759
improve inference and eliminate unsoundness
5860

5961
* Libraries
60-
* Lots of effort to organize the container API's around `core::container`
61-
* `core::send_map` renamed to `core::hashmap`
6262
* Added big integers to `std::bigint`
6363
* Removed `core::oldcomm` module
6464
* Added pipe-based `core::comm` module
65-
* Reimplemented `std::treemap`
6665
* Numeric traits have been reorganized under `core::num`
67-
* `core::dvec` removed. Use `@mut ~[T]` or other language types
6866
* `vec::slice` finally returns a slice
6967
* `debug!` and friends don't require a format string, e.g. `debug!(Foo)`
68+
* Containers reorganized around traits in `core::container`
69+
* `core::dvec` removed, `~[T]` is a drop-in replacement
70+
* `core::send_map` renamed to `core::hashmap`
71+
* `std::treemap` reimplemented as an owned balanced tree
72+
* `std::deque` and `std::smallintmap` reimplemented as owned containers
73+
* `core::trie` added as a fast ordered map for integer keys
74+
* Set types added to `core::hashmap`, `core::trie` and `std::treemap`
7075

7176
* Tools
7277
* Replaced the 'cargo' package manager with 'rustpkg'

branches/try2/doc/rust.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,8 @@ Traits are implemented for specific types through separate [implementations](#im
11811181
# type BoundingBox = int;
11821182
11831183
trait Shape {
1184-
fn draw(Surface);
1185-
fn bounding_box() -> BoundingBox;
1184+
fn draw(&self, Surface);
1185+
fn bounding_box(&self) -> BoundingBox;
11861186
}
11871187
~~~~
11881188

@@ -1195,9 +1195,9 @@ These appear after the trait name, using the same syntax used in [generic functi
11951195

11961196
~~~~
11971197
trait Seq<T> {
1198-
fn len() -> uint;
1199-
fn elt_at(n: uint) -> T;
1200-
fn iter(&fn(T));
1198+
fn len(&self) -> uint;
1199+
fn elt_at(&self, n: uint) -> T;
1200+
fn iter(&self, &fn(T));
12011201
}
12021202
~~~~
12031203

@@ -1209,7 +1209,7 @@ For example:
12091209

12101210
~~~~
12111211
# type Surface = int;
1212-
# trait Shape { fn draw(Surface); }
1212+
# trait Shape { fn draw(&self, Surface); }
12131213
12141214
fn draw_twice<T: Shape>(surface: Surface, sh: T) {
12151215
sh.draw(surface);
@@ -1227,7 +1227,7 @@ to pointers to the trait name, used as a type.
12271227
# impl Shape for int { }
12281228
# let mycircle = 0;
12291229
1230-
let myshape: Shape = @mycircle as @Shape;
1230+
let myshape: @Shape = @mycircle as @Shape;
12311231
~~~~
12321232

12331233
The resulting value is a managed box containing the value that was cast,
@@ -1271,8 +1271,8 @@ methods of the supertrait may be called on values of subtrait-bound type paramet
12711271
Refering to the previous example of `trait Circle : Shape`:
12721272

12731273
~~~
1274-
# trait Shape { fn area() -> float; }
1275-
# trait Circle : Shape { fn radius() -> float; }
1274+
# trait Shape { fn area(&self) -> float; }
1275+
# trait Circle : Shape { fn radius(&self) -> float; }
12761276
fn radius_times_area<T: Circle>(c: T) -> float {
12771277
// `c` is both a Circle and a Shape
12781278
c.radius() * c.area()
@@ -1282,10 +1282,10 @@ fn radius_times_area<T: Circle>(c: T) -> float {
12821282
Likewise, supertrait methods may also be called on trait objects.
12831283

12841284
~~~ {.xfail-test}
1285-
# trait Shape { fn area() -> float; }
1286-
# trait Circle : Shape { fn radius() -> float; }
1287-
# impl Shape for int { fn area() -> float { 0.0 } }
1288-
# impl Circle for int { fn radius() -> float { 0.0 } }
1285+
# trait Shape { fn area(&self) -> float; }
1286+
# trait Circle : Shape { fn radius(&self) -> float; }
1287+
# impl Shape for int { fn area(&self) -> float { 0.0 } }
1288+
# impl Circle for int { fn radius(&self) -> float { 0.0 } }
12891289
# let mycircle = 0;
12901290
12911291
let mycircle: Circle = @mycircle as @Circle;
@@ -1302,7 +1302,7 @@ Implementations are defined with the keyword `impl`.
13021302
# struct Point {x: float, y: float};
13031303
# type Surface = int;
13041304
# struct BoundingBox {x: float, y: float, width: float, height: float};
1305-
# trait Shape { fn draw(Surface); fn bounding_box() -> BoundingBox; }
1305+
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
13061306
# fn do_draw_circle(s: Surface, c: Circle) { }
13071307
13081308
struct Circle {
@@ -1311,8 +1311,8 @@ struct Circle {
13111311
}
13121312
13131313
impl Shape for Circle {
1314-
fn draw(s: Surface) { do_draw_circle(s, self); }
1315-
fn bounding_box() -> BoundingBox {
1314+
fn draw(&self, s: Surface) { do_draw_circle(s, *self); }
1315+
fn bounding_box(&self) -> BoundingBox {
13161316
let r = self.radius;
13171317
BoundingBox{x: self.center.x - r, y: self.center.y - r,
13181318
width: 2.0 * r, height: 2.0 * r}
@@ -2678,11 +2678,11 @@ An example of an object type:
26782678

26792679
~~~~~~~~
26802680
trait Printable {
2681-
fn to_str() -> ~str;
2681+
fn to_str(&self) -> ~str;
26822682
}
26832683
26842684
impl Printable for int {
2685-
fn to_str() -> ~str { int::to_str(self) }
2685+
fn to_str(&self) -> ~str { int::to_str(*self) }
26862686
}
26872687
26882688
fn print(a: @Printable) {
@@ -2721,11 +2721,11 @@ example, in:
27212721

27222722
~~~~~~~~
27232723
trait Printable {
2724-
fn make_string() -> ~str;
2724+
fn make_string(&self) -> ~str;
27252725
}
27262726
27272727
impl Printable for ~str {
2728-
fn make_string() -> ~str { copy self }
2728+
fn make_string(&self) -> ~str { copy *self }
27292729
}
27302730
~~~~~~~~
27312731

branches/try2/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ can sometimes make code awkward and parenthesis-filled.
11351135
~~~
11361136
# struct Point { x: float, y: float }
11371137
# enum Shape { Rectangle(Point, Point) }
1138-
# impl Shape { fn area() -> int { 0 } }
1138+
# impl Shape { fn area(&self) -> int { 0 } }
11391139
let start = @Point { x: 10f, y: 20f };
11401140
let end = ~Point { x: (*start).x + 100f, y: (*start).y + 100f };
11411141
let rect = &Rectangle(*start, *end);
@@ -1149,7 +1149,7 @@ dot), so in most cases, explicitly dereferencing the receiver is not necessary.
11491149
~~~
11501150
# struct Point { x: float, y: float }
11511151
# enum Shape { Rectangle(Point, Point) }
1152-
# impl Shape { fn area() -> int { 0 } }
1152+
# impl Shape { fn area(&self) -> int { 0 } }
11531153
let start = @Point { x: 10f, y: 20f };
11541154
let end = ~Point { x: start.x + 100f, y: start.y + 100f };
11551155
let rect = &Rectangle(*start, *end);

branches/try2/mk/rt.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ rt/$(1)/%.o: rt/%.S $$(MKFILE_DEPS) \
132132

133133
rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a: $$(MORESTACK_OBJ_$(1))
134134
@$$(call E, link: $$@)
135-
$$(Q)ar rcs $$@ $$<
135+
$$(Q)$(AR_$(1)) rcs $$@ $$<
136136

137137
rt/$(1)/$(CFG_RUNTIME_$(1)): $$(RUNTIME_OBJS_$(1)) $$(MKFILE_DEPS) \
138138
$$(RUNTIME_DEF_$(1)) \

branches/try2/src/etc/tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from licenseck import *
66

77
err=0
8-
cols=78
8+
cols=100
99

1010
# Be careful to support Python 2.4, 2.6, and 3.x here!
1111
config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ],

branches/try2/src/libcore/at_vec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use cast::transmute;
1414
use kinds::Copy;
1515
use iter;
16-
use libc;
1716
use option::Option;
1817
use ptr::addr_of;
1918
use sys;

branches/try2/src/libcore/container.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pub trait Map<K, V>: Mutable {
3535
/// Visit all values
3636
pure fn each_value(&self, f: &fn(&V) -> bool);
3737

38+
/// Iterate over the map and mutate the contained values
39+
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
40+
3841
/// Return the value corresponding to the key in the map
3942
pure fn find(&self, key: &K) -> Option<&self/V>;
4043

branches/try2/src/libcore/flate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Simple compression
1717
use libc;
1818
use libc::{c_void, size_t, c_int};
1919
use ptr;
20+
use rand::RngUtil;
2021
use vec;
2122

2223
#[cfg(test)] use rand;

branches/try2/src/libcore/hashmap.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub mod linear {
2020
use hash::Hash;
2121
use iter;
2222
use option::{None, Option, Some};
23+
use rand::RngUtil;
2324
use rand;
2425
use uint;
2526
use vec;
@@ -324,6 +325,19 @@ pub mod linear {
324325
self.each(|&(_, v)| blk(v))
325326
}
326327
328+
/// Iterate over the map and mutate the contained values
329+
fn mutate_values(&mut self, blk: &fn(&'self K,
330+
&'self mut V) -> bool) {
331+
for uint::range(0, self.buckets.len()) |i| {
332+
match self.buckets[i] {
333+
Some(Bucket{key: ref key, value: ref mut value, _}) => {
334+
if !blk(key, value) { return }
335+
}
336+
None => ()
337+
}
338+
}
339+
}
340+
327341
/// Return the value corresponding to the key in the map
328342
pure fn find(&self, k: &K) -> Option<&self/V> {
329343
match self.bucket_for_key(k) {

branches/try2/src/libcore/io.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,7 @@ pub fn fd_writer(fd: fd_t, cleanup: bool) -> @Writer {
785785

786786

787787
pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
788-
-> Result<Writer, ~str> {
789-
788+
-> Result<@Writer, ~str> {
790789
#[cfg(windows)]
791790
fn wb() -> c_int {
792791
(O_WRONLY | libc::consts::os::extra::O_BINARY) as c_int
@@ -1079,22 +1078,24 @@ impl<T:Writer> WriterUtil for T {
10791078
}
10801079

10811080
#[allow(non_implicitly_copyable_typarams)]
1082-
pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<Writer, ~str> {
1081+
pub fn file_writer(path: &Path, flags: &[FileFlag]) -> Result<@Writer, ~str> {
10831082
mk_file_writer(path, flags).chain(|w| result::Ok(w))
10841083
}
10851084

10861085

10871086
// FIXME: fileflags // #2004
1088-
pub fn buffered_file_writer(path: &Path) -> Result<Writer, ~str> {
1087+
pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
10891088
unsafe {
10901089
let f = do os::as_c_charp(path.to_str()) |pathbuf| {
10911090
do os::as_c_charp("w") |modebuf| {
10921091
libc::fopen(pathbuf, modebuf)
10931092
}
10941093
};
1095-
return if f as uint == 0u { result::Err(~"error opening "
1096-
+ path.to_str()) }
1097-
else { result::Ok(FILE_writer(f, true)) }
1094+
return if f as uint == 0u {
1095+
result::Err(~"error opening " + path.to_str())
1096+
} else {
1097+
result::Ok(FILE_writer(f, true))
1098+
}
10981099
}
10991100
}
11001101
@@ -1142,14 +1143,14 @@ pub pure fn BytesWriter() -> BytesWriter {
11421143
BytesWriter { bytes: ~[], mut pos: 0u }
11431144
}
11441145
1145-
pub pure fn with_bytes_writer(f: &fn(Writer)) -> ~[u8] {
1146+
pub pure fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] {
11461147
let wr = @BytesWriter();
1147-
f(wr as Writer);
1148+
f(wr as @Writer);
11481149
let @BytesWriter{bytes, _} = wr;
11491150
return bytes;
11501151
}
11511152
1152-
pub pure fn with_str_writer(f: &fn(Writer)) -> ~str {
1153+
pub pure fn with_str_writer(f: &fn(@Writer)) -> ~str {
11531154
let mut v = with_bytes_writer(f);
11541155
11551156
// FIXME (#3758): This should not be needed.
@@ -1277,8 +1278,8 @@ pub mod fsync {
12771278
pub trait FSyncable { fn fsync(&self, l: Level) -> int; }
12781279

12791280
// Call o.fsync after executing blk
1280-
pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
1281-
blk: &fn(v: Res<FSyncable>)) {
1281+
pub fn obj_sync(o: @FSyncable, opt_level: Option<Level>,
1282+
blk: &fn(v: Res<@FSyncable>)) {
12821283
blk(Res(Arg {
12831284
val: o, opt_level: opt_level,
12841285
fsync_fn: |o, l| o.fsync(l)
@@ -1305,12 +1306,12 @@ mod tests {
13051306
~"A hoopy frood who really knows where his towel is.";
13061307
debug!(copy frood);
13071308
{
1308-
let out: io::Writer =
1309+
let out: @io::Writer =
13091310
result::get(
13101311
&io::file_writer(tmpfile, ~[io::Create, io::Truncate]));
13111312
out.write_str(frood);
13121313
}
1313-
let inp: io::Reader = result::get(&io::file_reader(tmpfile));
1314+
let inp: @io::Reader = result::get(&io::file_reader(tmpfile));
13141315
let frood2: ~str = inp.read_c_str();
13151316
debug!(copy frood2);
13161317
fail_unless!(frood == frood2);

branches/try2/src/libcore/num/cmath.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
#[doc(hidden)]; // FIXME #3538
1212

13-
use libc::c_int;
14-
use libc::c_float;
15-
use libc::c_double;
16-
1713
// function names are almost identical to C's libmath, a few have been
1814
// renamed, grep for "rename:"
1915

branches/try2/src/libcore/os.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ mod tests {
12651265
use os::{remove_file, setenv};
12661266
use os;
12671267
use path::Path;
1268+
use rand::RngUtil;
12681269
use rand;
12691270
use run;
12701271
use str;
@@ -1282,7 +1283,7 @@ mod tests {
12821283
}
12831284
12841285
fn make_rand_name() -> ~str {
1285-
let rng: rand::Rng = rand::Rng();
1286+
let rng: @rand::Rng = rand::Rng();
12861287
let n = ~"TEST" + rng.gen_str(10u);
12871288
fail_unless!(getenv(n).is_none());
12881289
n

0 commit comments

Comments
 (0)