Skip to content

Commit 546f8e3

Browse files
committed
---
yaml --- r: 16322 b: refs/heads/try c: 8ebbf46 h: refs/heads/master v: v3
1 parent 8097ac6 commit 546f8e3

File tree

7 files changed

+25
-21
lines changed

7 files changed

+25
-21
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: e8dfe179da7ff0c679d6020fe658c8edd076a602
5+
refs/heads/try: 8ebbf464f59f3a400de91d7afac0c254e3346c72
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
type alist<A,B> = { eq_fn: fn@(A,A) -> bool, mut data: [(A,B)] };
1+
import dvec::{dvec,extensions};
2+
3+
type entry<A,B> = {key: A, value: B};
4+
type alist<A,B> = { eq_fn: fn@(A,A) -> bool, data: dvec<entry<A,B>> };
25

36
fn alist_add<A: copy, B: copy>(lst: alist<A,B>, k: A, v: B) {
4-
lst.data += [(k, v)];
7+
lst.data.push({key:k, value:v});
58
}
69

710
fn alist_get<A: copy, B: copy>(lst: alist<A,B>, k: A) -> B {
811
let eq_fn = lst.eq_fn;
9-
for lst.data.each {|pair|
10-
let (ki, vi) = pair; // copy req'd for alias analysis
11-
if eq_fn(k, ki) { ret vi; }
12+
for lst.data.each {|entry|
13+
if eq_fn(entry.key, k) { ret entry.value; }
1214
}
1315
fail;
1416
}
1517

1618
#[inline]
1719
fn new_int_alist<B: copy>() -> alist<int, B> {
1820
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
19-
ret {eq_fn: eq_int,
20-
mut data: []};
21+
ret {eq_fn: eq_int, data: dvec()};
2122
}
2223

2324
#[inline]
2425
fn new_int_alist_2<B: copy>() -> alist<int, B> {
2526
#[inline]
2627
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
27-
ret {eq_fn: eq_int,
28-
mut data: []};
28+
ret {eq_fn: eq_int, data: dvec()};
2929
}

branches/try/src/test/compile-fail/issue-511.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ fn f<T>(&o: option<T>) {
88
fn main() {
99
f::<int>(option::none);
1010
//!^ ERROR taking mut reference to static item
11+
//!^^ ERROR illegal borrow unless pure: creating mutable alias to aliasable, immutable memory
12+
//!^^^ NOTE impure due to access to impure function
1113
}

branches/try/src/test/run-pass/alt-pattern-drop.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ fn foo(s: @int) {
2525
fn main() {
2626
let s: @int = @0; // ref up
2727

28+
let count = dbg::refcount(s);
29+
2830
foo(s); // ref up then down
2931

3032
log(debug, dbg::refcount(s));
31-
assert (dbg::refcount(s) == 1u);
33+
assert (dbg::refcount(s) == count);
3234
}

branches/try/src/test/run-pass/class-implements-multiple-ifaces.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std;
22
import std::map::*;
33
import vec::*;
4+
import dvec::{dvec, extensions};
45

56
enum furniture { chair, couch, bed }
67
enum body_part { finger, toe, nose, ear }
@@ -26,7 +27,7 @@ fn vec_includes<T>(xs: [T], x: T) -> bool {
2627
class cat implements noisy, scratchy, bitey {
2728
priv {
2829
let meows : @mut uint;
29-
let scratched : @mut [furniture];
30+
let scratched : dvec<furniture>;
3031
let bite_counts : hashmap<body_part, uint>;
3132

3233
fn meow() -> uint {
@@ -44,7 +45,7 @@ class cat implements noisy, scratchy, bitey {
4445

4546
new(in_x : uint, in_y : int, in_name: str)
4647
{ self.meows = @mut in_x; self.how_hungry = @mut in_y;
47-
self.name = in_name; self.scratched = @mut [];
48+
self.name = in_name; self.scratched = dvec();
4849
let hsher: hashfn<body_part> =
4950
fn@(p: body_part) -> uint { int::hash(p as int) };
5051
let eqer : eqfn<body_part> =
@@ -61,10 +62,10 @@ class cat implements noisy, scratchy, bitey {
6162
fn meow_count() -> uint { *self.meows }
6263
fn scratch() -> option<furniture> {
6364
let all = [chair, couch, bed];
64-
log(error, *(self.scratched));
65+
log(error, self.scratched);
6566
let mut rslt = none;
66-
for each(all) {|thing| if !vec_includes(*(self.scratched), thing) {
67-
*self.scratched += [thing];
67+
for each(all) {|thing| if !self.scratched.contains(thing) {
68+
self.scratched.push(thing);
6869
ret some(thing); }}
6970
rslt
7071
}

branches/try/src/test/run-pass/iface-cast.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ impl of to_str for int {
2626

2727
impl of to_str for Tree {
2828
fn to_str() -> str {
29-
#fmt["[%s, %s, %s]",
30-
self.val.to_str(),
31-
self.left.to_str(),
32-
self.right.to_str()]
29+
let l = self.left, r = self.right;
30+
#fmt["[%s, %s, %s]", self.val.to_str(),
31+
l.to_str(), r.to_str()]
3332
}
3433
}
3534

branches/try/src/test/run-pass/maybe-mutable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// -*- rust -*-
55
fn len(v: [const int]) -> uint {
66
let mut i = 0u;
7-
for v.each {|x| i += 1u; }
7+
while i < vec::len(v) { i += 1u; }
88
ret i;
99
}
1010

0 commit comments

Comments
 (0)