Skip to content

Commit 9c7dc8b

Browse files
committed
---
yaml --- r: 16070 b: refs/heads/try c: bf129bd h: refs/heads/master v: v3
1 parent dc951ab commit 9c7dc8b

File tree

96 files changed

+1235
-1484
lines changed

Some content is hidden

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

96 files changed

+1235
-1484
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 0fa7858d1e8d4ebf6e881780ec9a37cf22f4c0b0
5+
refs/heads/try: bf129bd35f129e03ad36dae492d52cbf50d9b7c9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/cargo/cargo.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ fn install_uuid(c: cargo, wd: str, uuid: str) {
603603
for_each_package(c, { |s, p|
604604
info(#fmt["%s ? %s", p.uuid, uuid]);
605605
if p.uuid == uuid {
606-
vec::grow(ps, 1u, (s, p));
606+
vec::grow(ps, 1u, (s.name, p));
607607
}
608608
});
609609
if vec::len(ps) == 1u {
@@ -616,16 +616,16 @@ fn install_uuid(c: cargo, wd: str, uuid: str) {
616616
}
617617
error("Found multiple packages:");
618618
for ps.each {|elt|
619-
let (s,p) = elt;
620-
info(" " + s.name + "/" + p.uuid + " (" + p.name + ")");
619+
let (sname,p) = elt;
620+
info(" " + sname + "/" + p.uuid + " (" + p.name + ")");
621621
}
622622
}
623623

624624
fn install_named(c: cargo, wd: str, name: str) {
625625
let mut ps = [];
626626
for_each_package(c, { |s, p|
627627
if p.name == name {
628-
vec::grow(ps, 1u, (s, p));
628+
vec::grow(ps, 1u, (s.name, p));
629629
}
630630
});
631631
if vec::len(ps) == 1u {
@@ -638,8 +638,8 @@ fn install_named(c: cargo, wd: str, name: str) {
638638
}
639639
error("Found multiple packages:");
640640
for ps.each {|elt|
641-
let (s,p) = elt;
642-
info(" " + s.name + "/" + p.uuid + " (" + p.name + ")");
641+
let (sname,p) = elt;
642+
info(" " + sname + "/" + p.uuid + " (" + p.name + ")");
643643
}
644644
}
645645

branches/try/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
277277
}
278278
}
279279

280-
uint::range(0u, vec::len(found_flags)) {|i|
280+
for uint::range(0u, vec::len(found_flags)) {|i|
281281
if !found_flags[i] {
282282
let ee = expected_errors[i];
283283
fatal_procres(#fmt["expected %s on line %u not found: %s",

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ built-in types and runtime services, or that is used in nearly every
1313
non-trivial program.
1414

1515
`core` includes modules corresponding to each of the integer types, each of
16-
THE floating point types, the `bool` type, tuples, characters, strings,
16+
the floating point types, the `bool` type, tuples, characters, strings,
1717
vectors (`vec`), shared boxes (`box`), and unsafe pointers (`ptr`).
1818
Additionally, `core` provides very commonly used built-in types and
1919
operations, concurrency primitives, platform abstractions, I/O, and complete

branches/try/src/libcore/int-template.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ pure fn is_nonpositive(x: T) -> bool { x <= 0 as T }
3636
pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
3737

3838
#[doc = "Iterate over the range [`lo`..`hi`)"]
39-
fn range(lo: T, hi: T, it: fn(T)) {
39+
fn range(lo: T, hi: T, it: fn(T) -> bool) {
4040
let mut i = lo;
41-
while i < hi { it(i); i += 1 as T; }
41+
while i < hi {
42+
if !it(i) { break }
43+
i += 1 as T;
44+
}
4245
}
4346

4447
#[doc = "Computes the bitwise complement"]

branches/try/src/libcore/priv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ task to receive from it.
2424
unsafe fn chan_from_global_ptr<T: send>(
2525
global: global_ptr,
2626
builder: fn() -> task::builder,
27-
f: fn~(comm::port<T>)
27+
+f: fn~(comm::port<T>)
2828
) -> comm::chan<T> {
2929

3030
enum msg {
@@ -127,12 +127,12 @@ fn test_from_global_chan2() unsafe {
127127

128128
// Spawn a bunch of tasks that all want to compete to
129129
// create the global channel
130-
uint::range(0u, 10u) {|i|
130+
for uint::range(0u, 10u) {|i|
131131
task::spawn() {||
132132
let ch = chan_from_global_ptr(
133133
globchanp, task::builder) {|po|
134134

135-
uint::range(0u, 10u) {|_j|
135+
for uint::range(0u, 10u) {|_j|
136136
let ch = comm::recv(po);
137137
comm::send(ch, {i});
138138
}
@@ -147,7 +147,7 @@ fn test_from_global_chan2() unsafe {
147147
}
148148
// There should be only one winner
149149
let mut winners = 0u;
150-
uint::range(0u, 10u) {|_i|
150+
for uint::range(0u, 10u) {|_i|
151151
let res = comm::recv(resultpo);
152152
if res { winners += 1u };
153153
}
@@ -233,4 +233,4 @@ fn test_weaken_task_fail() unsafe {
233233
}
234234
};
235235
assert result::is_failure(res);
236-
}
236+
}

branches/try/src/libcore/rand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl extensions for rng {
202202
fn weighted_vec<T:copy>(v: [weighted<T>]) -> [T] {
203203
let mut r = [];
204204
for v.each {|item|
205-
uint::range(0u, item.weight) {|_i|
205+
for uint::range(0u, item.weight) {|_i|
206206
r += [item.item];
207207
}
208208
}

branches/try/src/libcore/to_str.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
iface to_str { fn to_str() -> str; }
22

3-
impl of to_str for int {
4-
fn to_str() -> str { int::str(self) }
3+
impl of to_str for i8 {
4+
fn to_str() -> str { i8::str(self) }
55
}
6-
impl of to_str for uint {
7-
fn to_str() -> str { uint::str(self) }
6+
impl of to_str for i16 {
7+
fn to_str() -> str { i16::str(self) }
8+
}
9+
impl of to_str for i32 {
10+
fn to_str() -> str { i32::str(self) }
11+
}
12+
impl of to_str for i64 {
13+
fn to_str() -> str { i64::str(self) }
814
}
915
impl of to_str for u8 {
10-
fn to_str() -> str { uint::str(self as uint) }
16+
fn to_str() -> str { u8::str(self) }
17+
}
18+
impl of to_str for u16 {
19+
fn to_str() -> str { u16::str(self) }
20+
}
21+
impl of to_str for u32 {
22+
fn to_str() -> str { u32::str(self) }
23+
}
24+
impl of to_str for u64 {
25+
fn to_str() -> str { u64::str(self) }
1126
}
1227
impl of to_str for float {
1328
fn to_str() -> str { float::to_str(self, 4u) }

branches/try/src/libcore/uint-template.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ pure fn is_nonpositive(x: T) -> bool { x <= 0 as T }
3535
pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
3636

3737
#[doc = "Iterate over the range [`lo`..`hi`)"]
38-
fn range(lo: T, hi: T, it: fn(T)) {
38+
fn range(lo: T, hi: T, it: fn(T) -> bool) {
3939
let mut i = lo;
40-
while i < hi { it(i); i += 1 as T; }
40+
while i < hi {
41+
if !it(i) { break }
42+
i += 1 as T;
43+
}
4144
}
4245

4346
#[doc = "Computes the bitwise complement"]

branches/try/src/libcore/vec.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,6 @@ fn from_mut<T>(+v: [mut T]) -> [T] unsafe {
199199
r
200200
}
201201

202-
// This function only exists to work around bugs in the type checker.
203-
fn from_const<T>(+v: [const T]) -> [T] unsafe {
204-
let r = ::unsafe::reinterpret_cast(v);
205-
::unsafe::forget(v);
206-
r
207-
}
208-
209202
// Accessors
210203

211204
#[doc = "Returns the first element of a vector"]
@@ -534,7 +527,7 @@ Flattens a vector of vectors of T into a single vector of T.
534527
"]
535528
fn concat<T: copy>(v: [const [const T]]) -> [T] {
536529
let mut r = [];
537-
for each(v) {|inner| r += from_const(inner); }
530+
for each(v) {|inner| r += inner; }
538531
ret r;
539532
}
540533

@@ -546,7 +539,7 @@ fn connect<T: copy>(v: [const [const T]], sep: T) -> [T] {
546539
let mut first = true;
547540
for each(v) {|inner|
548541
if first { first = false; } else { push(r, sep); }
549-
r += from_const(inner);
542+
r += inner;
550543
}
551544
ret r;
552545
}
@@ -899,7 +892,7 @@ Both vectors must have the same length
899892
#[inline]
900893
fn iter2<U, T>(v1: [const U], v2: [const T], f: fn(U, T)) {
901894
assert len(v1) == len(v2);
902-
uint::range(0u, len(v1)) {|i|
895+
for uint::range(0u, len(v1)) {|i|
903896
f(v1[i], v2[i])
904897
}
905898
}

branches/try/src/librustsyntax/codemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
183183
let lo = lookup_char_pos(cm, sp.lo);
184184
let hi = lookup_char_pos(cm, sp.hi);
185185
let mut lines = [];
186-
uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
186+
for uint::range(lo.line - 1u, hi.line as uint) {|i| lines += [i]; };
187187
ret @{file: lo.file, lines: lines};
188188
}
189189

branches/try/src/librustsyntax/ext/qquote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn finish<T: qq_helper>
193193
let qcx = gather_anti_quotes(sp.lo, node);
194194
let cx = qcx;
195195

196-
uint::range(1u, cx.gather.len()) {|i|
196+
for uint::range(1u, cx.gather.len()) {|i|
197197
assert cx.gather[i-1u].lo < cx.gather[i].lo;
198198
// ^^ check that the vector is sorted
199199
assert cx.gather[i-1u].hi <= cx.gather[i].lo;

branches/try/src/libstd/arc.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ type arc_data<T> = {
1919
data: T
2020
};
2121

22-
resource arc_destruct<T>(data: *arc_data<T>) {
22+
resource arc_destruct<T>(data: *libc::c_void) {
2323
unsafe {
24-
let ptr = &mut (*data).count;
24+
let data: ~arc_data<T> = unsafe::reinterpret_cast(data);
25+
let ref_ptr = &mut data.count;
2526

26-
let new_count = rustrt::rust_atomic_decrement(ptr);
27+
let new_count = rustrt::rust_atomic_decrement(ref_ptr);
2728
assert new_count >= 0;
2829
if new_count == 0 {
29-
let _ptr : ~arc_data<T> = unsafe::reinterpret_cast(data);
3030
// drop glue takes over.
31+
} else {
32+
unsafe::forget(data);
3133
}
3234
}
3335
}
@@ -48,7 +50,11 @@ fn arc<T>(-data: T) -> arc<T> {
4850
wrapper."]
4951
fn get<T>(rc: &a.arc<T>) -> &a.T {
5052
unsafe {
51-
&(***rc).data
53+
let ptr: ~arc_data<T> = unsafe::reinterpret_cast(**rc);
54+
// Cast us back into the correct region
55+
let r = unsafe::reinterpret_cast(&ptr.data);
56+
unsafe::forget(ptr);
57+
ret r;
5258
}
5359
}
5460

@@ -58,9 +64,10 @@ The resulting two `arc` objects will point to the same underlying data
5864
object. However, one of the `arc` objects can be sent to another task,
5965
allowing them to share the underlying data."]
6066
fn clone<T>(rc: &arc<T>) -> arc<T> {
61-
let data = **rc;
6267
unsafe {
63-
rustrt::rust_atomic_increment(&mut (*data).count);
68+
let ptr: ~arc_data<T> = unsafe::reinterpret_cast(**rc);
69+
rustrt::rust_atomic_increment(&mut ptr.count);
70+
unsafe::forget(ptr);
6471
}
6572
arc_destruct(**rc)
6673
}

branches/try/src/libstd/bitv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn process(v0: bitv, v1: bitv, op: fn(uint, uint) -> uint) -> bool {
4646
assert (vec::len(v0.storage) == len);
4747
assert (v0.nbits == v1.nbits);
4848
let mut changed = false;
49-
uint::range(0u, len) {|i|
49+
for uint::range(0u, len) {|i|
5050
let w0 = v0.storage[i];
5151
let w1 = v1.storage[i];
5252
let w = op(w0, w1);
@@ -90,7 +90,7 @@ fn assign(v0: bitv, v1: bitv) -> bool {
9090
fn clone(v: bitv) -> bitv {
9191
let storage = vec::to_mut(vec::from_elem(v.nbits / uint_bits + 1u, 0u));
9292
let len = vec::len(v.storage);
93-
uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
93+
for uint::range(0u, len) {|i| storage[i] = v.storage[i]; };
9494
ret @{storage: storage, nbits: v.nbits};
9595
}
9696

@@ -121,17 +121,17 @@ fn equal(v0: bitv, v1: bitv) -> bool {
121121

122122
#[doc = "Set all bits to 0"]
123123
fn clear(v: bitv) {
124-
uint::range(0u, vec::len(v.storage)) {|i| v.storage[i] = 0u; };
124+
for uint::range(0u, vec::len(v.storage)) {|i| v.storage[i] = 0u; };
125125
}
126126

127127
#[doc = "Set all bits to 1"]
128128
fn set_all(v: bitv) {
129-
uint::range(0u, v.nbits) {|i| set(v, i, true); };
129+
for uint::range(0u, v.nbits) {|i| set(v, i, true); };
130130
}
131131

132132
#[doc = "Invert all bits"]
133133
fn invert(v: bitv) {
134-
uint::range(0u, vec::len(v.storage)) {|i|
134+
for uint::range(0u, vec::len(v.storage)) {|i|
135135
v.storage[i] = !v.storage[i];
136136
};
137137
}

branches/try/src/libstd/getopts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ enum optval { val(str), given, }
132132
The result of checking command line arguments. Contains a vector
133133
of matches and a vector of free strings.
134134
"]
135-
type match = {opts: [opt], vals: [mut [optval]], free: [str]};
135+
type match = {opts: [opt], vals: [[optval]], free: [str]};
136136

137137
fn is_arg(arg: str) -> bool {
138138
ret str::len(arg) > 1u && arg[0] == '-' as u8;
@@ -275,7 +275,7 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe {
275275
}
276276
i += 1u;
277277
}
278-
ret ok({opts: opts, vals: vals, free: free});
278+
ret ok({opts: opts, vals: vec::from_mut(vals), free: free});
279279
}
280280

281281
fn opt_vals(m: match, nm: str) -> [optval] {

0 commit comments

Comments
 (0)