Skip to content

Commit 48ba648

Browse files
committed
---
yaml --- r: 127863 b: refs/heads/auto c: 0f09f51 h: refs/heads/master i: 127861: edbfa6e 127859: cd2f21c 127855: 0c1ac94 v: v3
1 parent 02a1de1 commit 48ba648

Some content is hidden

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

58 files changed

+893
-225
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 061cdec5dfefc91ce2ad00cef1435ce9b7b1db74
16+
refs/heads/auto: 0f09f51c61f1671caa75e9797f081ab4e312b634
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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 == 5 { 10i; } else { 15i; };
669+
let y: int = if x == 5i { 10i; } else { 15i; };
670670
```
671671

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

branches/auto/src/doc/rust.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ 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.
13591362
Static items are declared with the `static` keyword.
13601363
A static item must have a _constant expression_ giving its definition.
13611364

@@ -3621,7 +3624,10 @@ There are four varieties of pointer in Rust:
36213624
References arise by (automatic) conversion from owning pointers, managed pointers,
36223625
or by applying the borrowing operator `&` to some other value,
36233626
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3624-
References are written `&content`, or in some cases `&'f content` for some lifetime-variable `f`,
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;
36253631
for example `&int` means a reference to an integer.
36263632
Copying a reference is a "shallow" operation:
36273633
it involves only copying the pointer itself.

branches/auto/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.get(w) & (1 << b);
267+
let x = self.storage[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.get(w) | flag }
293-
else { *self.storage.get(w) & !flag };
292+
*self.storage.get_mut(w) = if x { self.storage[w] | flag }
293+
else { self.storage[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.get(i); }
830+
for (i, w) in self.storage.mut_iter().enumerate() { *w = source.storage[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.get(i);
1149+
let old = self_bitv.storage[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.get(word_idx)
1576+
s_bitv.storage[word_idx]
15771577
} else { 0 };
15781578
let w2 = if word_idx < o_bitv.storage.len() {
1579-
*o_bitv.storage.get(word_idx)
1579+
o_bitv.storage[word_idx]
15801580
} else { 0 };
15811581
self.current_word = (self.merge)(w1, w2);
15821582
}

branches/auto/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.get(midpoint).key.cmp(&k);
302+
let order = self.elts[midpoint].key.cmp(&k);
303303
match order {
304304
Equal => {
305305
return None;
306306
}
307307
Greater => {
308308
if midpoint > 0 {
309-
if self.elts.get(midpoint - 1).key.cmp(&k) == Less {
309+
if self.elts[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.get(midpoint + 1).key.cmp(&k) == Greater {
325+
if self.elts[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.get(0).cmp(other.elts.get(0))
425+
self.elts[0].cmp(&other.elts[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.get(midpoint).key.cmp(&k);
460+
let order = self.elts[midpoint].key.cmp(&k);
461461
match order {
462462
Equal => {
463463
return None;
464464
}
465465
Greater => {
466466
if midpoint > 0 {
467-
if self.elts.get(midpoint - 1).key.cmp(&k) == Less {
467+
if self.elts[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.get(midpoint + 1).key.cmp(&k) == Greater {
483+
if self.elts[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.get(i).left.clone().insert(k.clone(),
539-
v.clone(),
540-
ub.clone());
538+
let new_outcome = self.elts[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.get(0).clone();
584+
let new_elt = branch.elts[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.get(0).cmp(other.elts.get(0))
655+
self.elts[0].cmp(&other.elts[0])
656656
}
657657
}
658658

branches/auto/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_back() }
657+
fn next_back(&mut self) -> Option<A> { self.list.pop() }
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_back(elt); }
670+
for elt in iterator { self.push(elt); }
671671
}
672672
}
673673

branches/auto/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.get(0)) }
264+
if self.is_empty() { None } else { Some(&self.data[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.get(parent) {
476+
if new > self.data[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.get(child) > *self.data.get(right)) {
496+
if right < end && !(self.data[child] > self.data[right]) {
497497
child = right;
498498
}
499499
let x = replace(self.data.get_mut(child), zeroed());

branches/auto/src/libcollections/ringbuf.rs

Lines changed: 45 additions & 7 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.get(0)) } else { None }
56+
if self.nelts > 0 { Some(&self[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.get(self.nelts - 1)) } else { None }
66+
if self.nelts > 0 { Some(&self[self.nelts - 1]) } else { None }
6767
}
6868

6969
/// Return a mutable reference to the last element in the RingBuf
@@ -139,6 +139,8 @@ impl<T> RingBuf<T> {
139139
/// # Example
140140
///
141141
/// ```rust
142+
/// #![allow(deprecated)]
143+
///
142144
/// use std::collections::RingBuf;
143145
///
144146
/// let mut buf = RingBuf::new();
@@ -147,9 +149,10 @@ impl<T> RingBuf<T> {
147149
/// buf.push(5);
148150
/// assert_eq!(buf.get(1), &4);
149151
/// ```
152+
#[deprecated = "prefer using indexing, e.g., ringbuf[0]"]
150153
pub fn get<'a>(&'a self, i: uint) -> &'a T {
151154
let idx = self.raw_index(i);
152-
match *self.elts.get(idx) {
155+
match self.elts[idx] {
153156
None => fail!(),
154157
Some(ref v) => v
155158
}
@@ -169,7 +172,7 @@ impl<T> RingBuf<T> {
169172
/// buf.push(4);
170173
/// buf.push(5);
171174
/// *buf.get_mut(1) = 7;
172-
/// assert_eq!(buf.get(1), &7);
175+
/// assert_eq!(buf[1], 7);
173176
/// ```
174177
pub fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T {
175178
let idx = self.raw_index(i);
@@ -195,8 +198,8 @@ impl<T> RingBuf<T> {
195198
/// buf.push(4);
196199
/// buf.push(5);
197200
/// buf.swap(0, 2);
198-
/// assert_eq!(buf.get(0), &5);
199-
/// assert_eq!(buf.get(2), &3);
201+
/// assert_eq!(buf[0], 5);
202+
/// assert_eq!(buf[2], 3);
200203
/// ```
201204
pub fn swap(&mut self, i: uint, j: uint) {
202205
assert!(i < self.len());
@@ -476,6 +479,22 @@ impl<S: Writer, A: Hash<S>> Hash<S> for RingBuf<A> {
476479
}
477480
}
478481

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+
479498
impl<A> FromIterator<A> for RingBuf<A> {
480499
fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
481500
let (lower, _) = iterator.size_hint();
@@ -488,7 +507,7 @@ impl<A> FromIterator<A> for RingBuf<A> {
488507
impl<A> Extendable<A> for RingBuf<A> {
489508
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
490509
for elt in iterator {
491-
self.push_back(elt);
510+
self.push(elt);
492511
}
493512
}
494513
}
@@ -653,6 +672,25 @@ mod tests {
653672
}
654673
}
655674

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+
656694
#[bench]
657695
fn bench_new(b: &mut test::Bencher) {
658696
b.iter(|| {

branches/auto/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.get(new_pos(i, sd.dir)).size < sd.size)
193+
self.sdir[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)