Skip to content

Commit 40b0e2f

Browse files
committed
---
yaml --- r: 139014 b: refs/heads/try2 c: 19bb166 h: refs/heads/master v: v3
1 parent 02d0541 commit 40b0e2f

23 files changed

+206
-39
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: 387aa3668a4ff865c5554a9f3dac2d339f8ef7aa
8+
refs/heads/try2: 19bb16650f385755312e7d2399ce14e8253d92fa
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/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/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/core.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Implicitly, all crates behave as if they included the following prologue:
5656

5757
// On Linux, link to the runtime with -lrt.
5858
#[cfg(target_os = "linux")]
59+
#[doc(hidden)]
5960
pub mod linkhack {
6061
#[link_args="-lrustrt -lrt"]
6162
#[link_args = "-lpthread"]
@@ -252,7 +253,7 @@ pub mod rt;
252253
// A curious inner-module that's not exported that contains the binding
253254
// 'core' so that macro-expanded references to core::error and such
254255
// can be resolved within libcore.
255-
#[doc(hidden)] // FIXME #3538
256+
#[doc(hidden)]
256257
pub mod core {
257258
#[cfg(stage0)]
258259
pub const error : u32 = 1_u32;

branches/try2/src/libcore/hashmap.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@ pub mod linear {
325325
self.each(|&(_, v)| blk(v))
326326
}
327327
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+
328341
/// Return the value corresponding to the key in the map
329342
pure fn find(&self, k: &K) -> Option<&self/V> {
330343
match self.bucket_for_key(k) {

branches/try2/src/libcore/iter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pub trait ReverseIter<A>: BaseIter<A> {
3131
pure fn each_reverse(&self, blk: &fn(&A) -> bool);
3232
}
3333

34+
pub trait MutableIter<A>: BaseIter<A> {
35+
fn each_mut(&mut self, blk: &fn(&mut A) -> bool);
36+
}
37+
3438
pub trait ExtendedIter<A> {
3539
pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool);
3640
pure fn all(&self, blk: &fn(&A) -> bool) -> bool;

branches/try2/src/libcore/prelude.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ pub use clone::Clone;
2727
pub use cmp::{Eq, Ord, TotalOrd, Ordering, Less, Equal, Greater};
2828
pub use container::{Container, Mutable, Map, Set};
2929
pub use hash::Hash;
30-
pub use iter::{BaseIter, ReverseIter, ExtendedIter, EqIter, CopyableIter};
31-
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
30+
pub use iter::{BaseIter, ReverseIter, MutableIter, ExtendedIter, EqIter};
31+
pub use iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter};
32+
pub use iter::Times;
3233
pub use num::NumCast;
3334
pub use path::GenericPath;
3435
pub use path::Path;
@@ -43,6 +44,10 @@ pub use vec::{CopyableVector, ImmutableVector};
4344
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
4445
pub use vec::{OwnedVector, OwnedCopyableVector};
4546

47+
/* Reexported runtime types */
48+
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};
49+
pub use task::spawn;
50+
4651
/* Reexported modules */
4752

4853
pub use at_vec;

branches/try2/src/libcore/trie.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,16 @@ impl<T> Map<uint, T> for TrieMap<T> {
8181

8282
/// Visit all values in order
8383
#[inline(always)]
84-
pure fn each_value(&self,
85-
f: &fn(&T) -> bool) {
84+
pure fn each_value(&self, f: &fn(&T) -> bool) {
8685
self.each(|&(_, v)| f(v))
8786
}
8887

88+
/// Iterate over the map and mutate the contained values
89+
#[inline(always)]
90+
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) {
91+
self.root.mutate_values(f);
92+
}
93+
8994
/// Return the value corresponding to the key in the map
9095
#[inline(hint)]
9196
pure fn find(&self, key: &uint) -> Option<&self/T> {
@@ -150,11 +155,6 @@ impl<T> TrieMap<T> {
150155
pure fn each_value_reverse(&self, f: &fn(&T) -> bool) {
151156
self.each_reverse(|&(_, v)| f(v))
152157
}
153-
154-
/// Iterate over the map and mutate the contained values
155-
fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) {
156-
self.root.mutate_values(f);
157-
}
158158
}
159159

160160
pub struct TrieSet {
@@ -248,13 +248,13 @@ impl<T> TrieNode<T> {
248248
true
249249
}
250250

251-
fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) -> bool {
251+
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
252252
for vec::each_mut(self.children) |child| {
253253
match *child {
254254
Internal(ref mut x) => if !x.mutate_values(f) {
255255
return false
256256
},
257-
External(k, ref mut v) => if !f(k, v) { return false },
257+
External(k, ref mut v) => if !f(&k, v) { return false },
258258
Nothing => ()
259259
}
260260
}
@@ -269,8 +269,8 @@ pure fn chunk(n: uint, idx: uint) -> uint {
269269
(n >> (SHIFT * real_idx)) & MASK
270270
}
271271

272-
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint,
273-
value: T, idx: uint) -> bool {
272+
fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
273+
idx: uint) -> bool {
274274
let mut tmp = Nothing;
275275
tmp <-> *child;
276276
let mut added = false;

branches/try2/src/libcore/vec.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ pub pure fn each<T>(v: &r/[T], f: &fn(&r/T) -> bool) {
13571357
/// a vector with mutable contents and you would like
13581358
/// to mutate the contents as you iterate.
13591359
#[inline(always)]
1360-
pub fn each_mut<T>(v: &mut [T], f: &fn(elem: &mut T) -> bool) {
1360+
pub fn each_mut<T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) {
13611361
let mut i = 0;
13621362
let n = v.len();
13631363
while i < n {
@@ -2280,11 +2280,9 @@ pub mod bytes {
22802280
// ___________________________________________________________________________
22812281
// ITERATION TRAIT METHODS
22822282

2283-
impl<A> iter::BaseIter<A> for &self/[A] {
2283+
impl<A> iter::BaseIter<A> for &'self [A] {
22842284
#[inline(always)]
2285-
pub pure fn each(&self, blk: &fn(v: &'self A) -> bool) {
2286-
each(*self, blk)
2287-
}
2285+
pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) }
22882286
#[inline(always)]
22892287
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
22902288
}
@@ -2305,6 +2303,29 @@ impl<A> iter::BaseIter<A> for @[A] {
23052303
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
23062304
}
23072305

2306+
impl<A> iter::MutableIter<A> for &'self mut [A] {
2307+
#[inline(always)]
2308+
fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) {
2309+
each_mut(*self, blk)
2310+
}
2311+
}
2312+
2313+
// FIXME(#4148): This should be redundant
2314+
impl<A> iter::MutableIter<A> for ~[A] {
2315+
#[inline(always)]
2316+
fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) {
2317+
each_mut(*self, blk)
2318+
}
2319+
}
2320+
2321+
// FIXME(#4148): This should be redundant
2322+
impl<A> iter::MutableIter<A> for @mut [A] {
2323+
#[inline(always)]
2324+
fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) {
2325+
each_mut(*self, blk)
2326+
}
2327+
}
2328+
23082329
impl<A> iter::ExtendedIter<A> for &self/[A] {
23092330
pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
23102331
iter::eachi(self, blk)

branches/try2/src/librustc/middle/astencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,8 @@ impl fake_ext_ctxt for fake_session {
12031203
}
12041204
12051205
#[cfg(test)]
1206-
fn mk_ctxt() -> fake_ext_ctxt {
1207-
@parse::new_parse_sess(None) as fake_ext_ctxt
1206+
fn mk_ctxt() -> @fake_ext_ctxt {
1207+
@parse::new_parse_sess(None) as @fake_ext_ctxt
12081208
}
12091209
12101210
#[cfg(test)]

branches/try2/src/libstd/smallintmap.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,17 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
8585
self.each(|&(_, v)| blk(v))
8686
}
8787

88-
/// Return the value corresponding to the key in the map
88+
/// Visit all key-value pairs in order
89+
fn mutate_values(&mut self, it: &fn(&uint, &'self mut V) -> bool) {
90+
for uint::range(0, self.v.len()) |i| {
91+
match self.v[i] {
92+
Some(ref mut elt) => if !it(&i, elt) { break },
93+
None => ()
94+
}
95+
}
96+
}
97+
98+
/// Iterate over the map and mutate the contained values
8999
pure fn find(&self, key: &uint) -> Option<&self/V> {
90100
if *key < self.v.len() {
91101
match self.v[*key] {

branches/try2/src/libstd/treemap.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
134134
self.each(|&(_, v)| f(v))
135135
}
136136

137+
/// Iterate over the map and mutate the contained values
138+
fn mutate_values(&mut self, f: &fn(&'self K, &'self mut V) -> bool) {
139+
mutate_values(&mut self.root, f);
140+
}
141+
137142
/// Return the value corresponding to the key in the map
138143
pure fn find(&self, key: &K) -> Option<&self/V> {
139144
let mut current: &self/Option<~TreeNode<K, V>> = &self.root;
@@ -558,6 +563,20 @@ pure fn each_reverse<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
558563
}
559564
}
560565

566+
fn mutate_values<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>,
567+
f: &fn(&'r K, &'r mut V) -> bool) -> bool {
568+
match *node {
569+
Some(~TreeNode{key: ref key, value: ref mut value, left: ref mut left,
570+
right: ref mut right, _}) => {
571+
if !mutate_values(left, f) { return false }
572+
if !f(key, value) { return false }
573+
if !mutate_values(right, f) { return false }
574+
}
575+
None => return false
576+
}
577+
true
578+
}
579+
561580
// Remove left horizontal link by rotating right
562581
fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
563582
if node.left.map_default(false, |x| x.level == node.level) {

branches/try2/src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ mod test {
300300
use core::str;
301301
use util::testing::*;
302302

303-
#[test] fn to_json_str (val: Encodable<std::json::Encoder>) -> ~str {
303+
#[test] fn to_json_str (val: @Encodable<std::json::Encoder>) -> ~str {
304304
do io::with_str_writer |writer| {
305305
val.encode(~std::json::Encoder(writer));
306306
}

branches/try2/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ get_time(int64_t *sec, int32_t *nsec) {
321321
ul.HighPart = fileTime.dwHighDateTime;
322322
uint64_t ns_since_1601 = ul.QuadPart / 10;
323323

324-
const uint64_t NANOSECONDS_FROM_1601_TO_1970 = 11644473600000000u;
324+
const uint64_t NANOSECONDS_FROM_1601_TO_1970 = 11644473600000000ull;
325325
uint64_t ns_since_1970 = ns_since_1601 - NANOSECONDS_FROM_1601_TO_1970;
326326
*sec = ns_since_1970 / 1000000;
327327
*nsec = (ns_since_1970 % 1000000) * 1000;

branches/try2/src/test/bench/core-std.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::oldmap;
1717
use std::oldmap::{Map, HashMap};
1818

1919
use core::io::{Reader, ReaderUtil};
20+
use core::rand::RngUtil;
2021

2122
macro_rules! bench (
2223
($id:ident) => (maybe_run_test(argv, stringify!($id).to_owned(), $id))

branches/try2/src/test/bench/graph500-bfs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use std::deque::Deque;
2929
use std::par;
3030
use core::io::WriterUtil;
3131
use core::int::abs;
32+
use core::rand::RngUtil;
3233

3334
type node_id = i64;
3435
type graph = ~[~[node_id]];
@@ -37,7 +38,7 @@ type bfs_result = ~[node_id];
3738
fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] {
3839
let r = rand::xorshift();
3940

40-
fn choose_edge(i: node_id, j: node_id, scale: uint, r: rand::Rng)
41+
fn choose_edge(i: node_id, j: node_id, scale: uint, r: @rand::Rng)
4142
-> (node_id, node_id) {
4243

4344
let A = 0.57;

branches/try2/src/test/bench/noise.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Perlin noise benchmark from https://gist.github.com/1170424
22

3+
use core::rand::RngUtil;
4+
35
struct Vec2 {
46
x: f32,
57
y: f32,
@@ -8,7 +10,7 @@ struct Vec2 {
810
fn lerp(a: f32, b: f32, v: f32) -> f32 { a * (1.0 - v) + b * v }
911
fn smooth(v: f32) -> f32 { v * v * (3.0 - 2.0 * v) }
1012

11-
fn random_gradient(r: rand::Rng) -> Vec2 {
13+
fn random_gradient(r: @rand::Rng) -> Vec2 {
1214
let v = r.gen_float() * float::consts::pi * 2.0;
1315
Vec2{
1416
x: float::cos(v) as f32,

branches/try2/src/test/bench/shootout-fasta.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ fn select_random(r: u32, genelist: ~[AminoAcids]) -> char {
5757
return bisect(copy genelist, 0, vec::len::<AminoAcids>(genelist) - 1, r);
5858
}
5959

60-
fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[AminoAcids], n: int) {
60+
fn make_random_fasta(wr: @io::Writer,
61+
id: ~str,
62+
desc: ~str,
63+
genelist: ~[AminoAcids],
64+
n: int) {
6165
wr.write_line(~">" + id + ~" " + desc);
6266
let rng = @mut MyRandom {last: rand::Rng().next()};
6367
let mut op: ~str = ~"";
@@ -72,7 +76,7 @@ fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[AminoAcid
7276
if str::len(op) > 0u { wr.write_line(op); }
7377
}
7478

75-
fn make_repeat_fasta(wr: io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
79+
fn make_repeat_fasta(wr: @io::Writer, id: ~str, desc: ~str, s: ~str, n: int) {
7680
unsafe {
7781
wr.write_line(~">" + id + ~" " + desc);
7882
let mut op: ~str = ~"";

0 commit comments

Comments
 (0)