Skip to content

Commit ddc07fc

Browse files
author
Philipp Gesang
committed
---
yaml --- r: 128764 b: refs/heads/try c: b8f512d h: refs/heads/master v: v3
1 parent 76ff858 commit ddc07fc

Some content is hidden

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

59 files changed

+226
-894
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 86ecfa491fcaf3dfbc8275fbda5c6e31841a1866
5+
refs/heads/try: b8f512d22044fe9d311c392eb1f96faff28b7f5d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/guide-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ itself, yet again implying that they are not defined in the standard library.
128128
The full complement of runtime features is defined by the [`Runtime`
129129
trait](std/rt/trait.Runtime.html) and the [`Task`
130130
struct](std/rt/task/struct.Task.html). A `Task` is constant among all runtime
131-
implementations, but each runtime implements has its own implementation of the
131+
implementations, but each runtime has its own implementation of the
132132
`Runtime` trait.
133133

134134
The local `Task` stores the runtime value inside of itself, and then ownership

branches/try/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ This is not the same as this, which won't compile:
666666
```{ignore}
667667
let x = 5i;
668668
669-
let y: int = if x == 5i { 10i; } else { 15i; };
669+
let y: int = if x == 5 { 10i; } else { 15i; };
670670
```
671671

672672
Note the semicolons after the 10 and 15. Rust will give us the following error:

branches/try/src/doc/rust.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,9 +1356,6 @@ A *static item* is a named _constant value_ stored in the global data section of
13561356
Immutable static items are stored in the read-only data section.
13571357
The constant value bound to a static item is, like all constant values, evaluated at compile time.
13581358
Static items have the `static` lifetime, which outlives all other lifetimes in a Rust program.
1359-
Only values stored in the global data section (such as string constants
1360-
and static items) can have the `static` lifetime;
1361-
dynamically constructed values cannot safely be assigned the `static` lifetime.
13621359
Static items are declared with the `static` keyword.
13631360
A static item must have a _constant expression_ giving its definition.
13641361

@@ -3624,10 +3621,7 @@ There are four varieties of pointer in Rust:
36243621
References arise by (automatic) conversion from owning pointers, managed pointers,
36253622
or by applying the borrowing operator `&` to some other value,
36263623
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3627-
A borrow expression is written `&content`.
3628-
3629-
A reference type is written `&'f type` for some lifetime-variable `f`,
3630-
or just `&type` when the lifetime can be elided;
3624+
References are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
36313625
for example `&int` means a reference to an integer.
36323626
Copying a reference is a "shallow" operation:
36333627
it involves only copying the pointer itself.

branches/try/src/libcollections/bitv.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl Bitv {
264264
assert!(i < self.nbits);
265265
let w = i / uint::BITS;
266266
let b = i % uint::BITS;
267-
let x = self.storage[w] & (1 << b);
267+
let x = self.storage.get(w) & (1 << b);
268268
x != 0
269269
}
270270

@@ -289,8 +289,8 @@ impl Bitv {
289289
let w = i / uint::BITS;
290290
let b = i % uint::BITS;
291291
let flag = 1 << b;
292-
*self.storage.get_mut(w) = if x { self.storage[w] | flag }
293-
else { self.storage[w] & !flag };
292+
*self.storage.get_mut(w) = if x { *self.storage.get(w) | flag }
293+
else { *self.storage.get(w) & !flag };
294294
}
295295

296296
/// Set all bits to 1.
@@ -827,7 +827,7 @@ impl Clone for Bitv {
827827
fn clone_from(&mut self, source: &Bitv) {
828828
self.nbits = source.nbits;
829829
self.storage.reserve(source.storage.len());
830-
for (i, w) in self.storage.mut_iter().enumerate() { *w = source.storage[i]; }
830+
for (i, w) in self.storage.mut_iter().enumerate() { *w = *source.storage.get(i); }
831831
}
832832
}
833833

@@ -1146,7 +1146,7 @@ impl BitvSet {
11461146
self_bitv.reserve(other_bitv.capacity());
11471147
// Apply values
11481148
for (i, w) in other_bitv.mask_words(0) {
1149-
let old = self_bitv.storage[i];
1149+
let old = *self_bitv.storage.get(i);
11501150
let new = f(old, w);
11511151
*self_bitv.storage.get_mut(i) = new;
11521152
}
@@ -1573,10 +1573,10 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
15731573
// one Bitv might be longer than the other
15741574
let word_idx = self.next_idx / uint::BITS;
15751575
let w1 = if word_idx < s_bitv.storage.len() {
1576-
s_bitv.storage[word_idx]
1576+
*s_bitv.storage.get(word_idx)
15771577
} else { 0 };
15781578
let w2 = if word_idx < o_bitv.storage.len() {
1579-
o_bitv.storage[word_idx]
1579+
*o_bitv.storage.get(word_idx)
15801580
} else { 0 };
15811581
self.current_word = (self.merge)(w1, w2);
15821582
}

branches/try/src/libcollections/btree.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,14 @@ impl<K: Ord, V> Leaf<K, V> {
299299
midpoint = 0;
300300
}
301301
loop {
302-
let order = self.elts[midpoint].key.cmp(&k);
302+
let order = self.elts.get(midpoint).key.cmp(&k);
303303
match order {
304304
Equal => {
305305
return None;
306306
}
307307
Greater => {
308308
if midpoint > 0 {
309-
if self.elts[midpoint - 1].key.cmp(&k) == Less {
309+
if self.elts.get(midpoint - 1).key.cmp(&k) == Less {
310310
return Some(midpoint);
311311
}
312312
else {
@@ -322,7 +322,7 @@ impl<K: Ord, V> Leaf<K, V> {
322322
}
323323
Less => {
324324
if midpoint + 1 < self.elts.len() {
325-
if self.elts[midpoint + 1].key.cmp(&k) == Greater {
325+
if self.elts.get(midpoint + 1).key.cmp(&k) == Greater {
326326
return Some(midpoint);
327327
}
328328
else {
@@ -422,7 +422,7 @@ impl<K: Ord, V: Eq> Ord for Leaf<K, V> {
422422
if self.elts.len() < other.elts.len() {
423423
return Less;
424424
}
425-
self.elts[0].cmp(&other.elts[0])
425+
self.elts.get(0).cmp(other.elts.get(0))
426426
}
427427
}
428428

@@ -457,14 +457,14 @@ impl<K: Ord, V> Branch<K, V> {
457457
midpoint = 0u;
458458
}
459459
loop {
460-
let order = self.elts[midpoint].key.cmp(&k);
460+
let order = self.elts.get(midpoint).key.cmp(&k);
461461
match order {
462462
Equal => {
463463
return None;
464464
}
465465
Greater => {
466466
if midpoint > 0 {
467-
if self.elts[midpoint - 1].key.cmp(&k) == Less {
467+
if self.elts.get(midpoint - 1).key.cmp(&k) == Less {
468468
return Some(midpoint);
469469
}
470470
else {
@@ -480,7 +480,7 @@ impl<K: Ord, V> Branch<K, V> {
480480
}
481481
Less => {
482482
if midpoint + 1 < self.elts.len() {
483-
if self.elts[midpoint + 1].key.cmp(&k) == Greater {
483+
if self.elts.get(midpoint + 1).key.cmp(&k) == Greater {
484484
return Some(midpoint);
485485
}
486486
else {
@@ -529,15 +529,15 @@ impl<K: Clone + Ord, V: Clone> Branch<K, V> {
529529
Some(i) => {
530530
if i == self.elts.len() {
531531
let new_outcome = self.clone().rightmost_child.insert(k.clone(),
532-
v.clone(),
533-
ub.clone());
532+
v.clone(),
533+
ub.clone());
534534
new_branch = new_outcome.clone().val0();
535535
outcome = new_outcome.val1();
536536
}
537537
else {
538-
let new_outcome = self.elts[i].left.clone().insert(k.clone(),
539-
v.clone(),
540-
ub.clone());
538+
let new_outcome = self.elts.get(i).left.clone().insert(k.clone(),
539+
v.clone(),
540+
ub.clone());
541541
new_branch = new_outcome.clone().val0();
542542
outcome = new_outcome.val1();
543543
}
@@ -581,7 +581,7 @@ impl<K: Clone + Ord, V: Clone> Branch<K, V> {
581581
//If we have a new branch node, attempt to insert it into the tree
582582
//as with the key-value pair, then check to see if the node is overfull.
583583
BranchNode(branch) => {
584-
let new_elt = branch.elts[0].clone();
584+
let new_elt = branch.elts.get(0).clone();
585585
let new_elt_index = self.bsearch_branch(new_elt.clone().key);
586586
match new_elt_index {
587587
None => {
@@ -652,7 +652,7 @@ impl<K: Ord, V: Eq> Ord for Branch<K, V> {
652652
if self.elts.len() < other.elts.len() {
653653
return Less;
654654
}
655-
self.elts[0].cmp(&other.elts[0])
655+
self.elts.get(0).cmp(other.elts.get(0))
656656
}
657657
}
658658

branches/try/src/libcollections/dlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ impl<A> Iterator<A> for MoveItems<A> {
654654

655655
impl<A> DoubleEndedIterator<A> for MoveItems<A> {
656656
#[inline]
657-
fn next_back(&mut self) -> Option<A> { self.list.pop() }
657+
fn next_back(&mut self) -> Option<A> { self.list.pop_back() }
658658
}
659659

660660
impl<A> FromIterator<A> for DList<A> {
@@ -667,7 +667,7 @@ impl<A> FromIterator<A> for DList<A> {
667667

668668
impl<A> Extendable<A> for DList<A> {
669669
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
670-
for elt in iterator { self.push(elt); }
670+
for elt in iterator { self.push_back(elt); }
671671
}
672672
}
673673

branches/try/src/libcollections/priority_queue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<T: Ord> PriorityQueue<T> {
261261
///
262262
/// ```
263263
pub fn top<'a>(&'a self) -> Option<&'a T> {
264-
if self.is_empty() { None } else { Some(&self.data[0]) }
264+
if self.is_empty() { None } else { Some(self.data.get(0)) }
265265
}
266266

267267
#[deprecated="renamed to `top`"]
@@ -473,7 +473,7 @@ impl<T: Ord> PriorityQueue<T> {
473473

474474
while pos > start {
475475
let parent = (pos - 1) >> 1;
476-
if new > self.data[parent] {
476+
if new > *self.data.get(parent) {
477477
let x = replace(self.data.get_mut(parent), zeroed());
478478
ptr::write(self.data.get_mut(pos), x);
479479
pos = parent;
@@ -493,7 +493,7 @@ impl<T: Ord> PriorityQueue<T> {
493493
let mut child = 2 * pos + 1;
494494
while child < end {
495495
let right = child + 1;
496-
if right < end && !(self.data[child] > self.data[right]) {
496+
if right < end && !(*self.data.get(child) > *self.data.get(right)) {
497497
child = right;
498498
}
499499
let x = replace(self.data.get_mut(child), zeroed());

branches/try/src/libcollections/ringbuf.rs

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<T> Mutable for RingBuf<T> {
5353
impl<T> Deque<T> for RingBuf<T> {
5454
/// Return a reference to the first element in the RingBuf
5555
fn front<'a>(&'a self) -> Option<&'a T> {
56-
if self.nelts > 0 { Some(&self[0]) } else { None }
56+
if self.nelts > 0 { Some(self.get(0)) } else { None }
5757
}
5858

5959
/// Return a mutable reference to the first element in the RingBuf
@@ -63,7 +63,7 @@ impl<T> Deque<T> for RingBuf<T> {
6363

6464
/// Return a reference to the last element in the RingBuf
6565
fn back<'a>(&'a self) -> Option<&'a T> {
66-
if self.nelts > 0 { Some(&self[self.nelts - 1]) } else { None }
66+
if self.nelts > 0 { Some(self.get(self.nelts - 1)) } else { None }
6767
}
6868

6969
/// Return a mutable reference to the last element in the RingBuf
@@ -139,8 +139,6 @@ impl<T> RingBuf<T> {
139139
/// # Example
140140
///
141141
/// ```rust
142-
/// #![allow(deprecated)]
143-
///
144142
/// use std::collections::RingBuf;
145143
///
146144
/// let mut buf = RingBuf::new();
@@ -149,10 +147,9 @@ impl<T> RingBuf<T> {
149147
/// buf.push(5);
150148
/// assert_eq!(buf.get(1), &4);
151149
/// ```
152-
#[deprecated = "prefer using indexing, e.g., ringbuf[0]"]
153150
pub fn get<'a>(&'a self, i: uint) -> &'a T {
154151
let idx = self.raw_index(i);
155-
match self.elts[idx] {
152+
match *self.elts.get(idx) {
156153
None => fail!(),
157154
Some(ref v) => v
158155
}
@@ -172,7 +169,7 @@ impl<T> RingBuf<T> {
172169
/// buf.push(4);
173170
/// buf.push(5);
174171
/// *buf.get_mut(1) = 7;
175-
/// assert_eq!(buf[1], 7);
172+
/// assert_eq!(buf.get(1), &7);
176173
/// ```
177174
pub fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T {
178175
let idx = self.raw_index(i);
@@ -198,8 +195,8 @@ impl<T> RingBuf<T> {
198195
/// buf.push(4);
199196
/// buf.push(5);
200197
/// buf.swap(0, 2);
201-
/// assert_eq!(buf[0], 5);
202-
/// assert_eq!(buf[2], 3);
198+
/// assert_eq!(buf.get(0), &5);
199+
/// assert_eq!(buf.get(2), &3);
203200
/// ```
204201
pub fn swap(&mut self, i: uint, j: uint) {
205202
assert!(i < self.len());
@@ -479,22 +476,6 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
479476
}
480477
}
481478

482-
impl<A> Index<uint, A> for RingBuf<A> {
483-
#[inline]
484-
#[allow(deprecated)]
485-
fn index<'a>(&'a self, i: &uint) -> &'a A {
486-
self.get(*i)
487-
}
488-
}
489-
490-
// FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
491-
/*impl<A> IndexMut<uint, A> for RingBuf<A> {
492-
#[inline]
493-
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut A {
494-
self.get_mut(*index)
495-
}
496-
}*/
497-
498479
impl<A> FromIterator<A> for RingBuf<A> {
499480
fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
500481
let (lower, _) = iterator.size_hint();
@@ -507,7 +488,7 @@ impl<A> FromIterator<A> for RingBuf<A> {
507488
impl<A> Extendable<A> for RingBuf<A> {
508489
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
509490
for elt in iterator {
510-
self.push(elt);
491+
self.push_back(elt);
511492
}
512493
}
513494
}
@@ -672,25 +653,6 @@ mod tests {
672653
}
673654
}
674655

675-
#[test]
676-
fn test_index() {
677-
let mut deq = RingBuf::new();
678-
for i in range(1u, 4) {
679-
deq.push_front(i);
680-
}
681-
assert_eq!(deq[1], 2);
682-
}
683-
684-
#[test]
685-
#[should_fail]
686-
fn test_index_out_of_bounds() {
687-
let mut deq = RingBuf::new();
688-
for i in range(1u, 4) {
689-
deq.push_front(i);
690-
}
691-
deq[3];
692-
}
693-
694656
#[bench]
695657
fn bench_new(b: &mut test::Bencher) {
696658
b.iter(|| {

branches/try/src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Iterator<(uint, uint)> for ElementSwaps {
190190
let max = self.sdir.iter().map(|&x| x).enumerate()
191191
.filter(|&(i, sd)|
192192
new_pos(i, sd.dir) < self.sdir.len() &&
193-
self.sdir[new_pos(i, sd.dir)].size < sd.size)
193+
self.sdir.get(new_pos(i, sd.dir)).size < sd.size)
194194
.max_by(|&(_, sd)| sd.size);
195195
match max {
196196
Some((i, sd)) => {

0 commit comments

Comments
 (0)