Skip to content

Commit d1cd426

Browse files
committed
---
yaml --- r: 195230 b: refs/heads/tmp c: 13e4270 h: refs/heads/master v: v3
1 parent 5f21404 commit d1cd426

Some content is hidden

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

50 files changed

+1361
-74
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: d8be84eb4499e21bd98a3500c8760540996df23b
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: b24a3b82011c3b78573ace4ade3f99d7c4701a11
37+
refs/heads/tmp: 13e4270bf9468e9213b6cc16ca217062791599a0
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3939
refs/tags/homu-tmp: 53a183f0274316596bf9405944d4f0468d8c93e4
4040
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ extern crate pcre;
980980
981981
extern crate std; // equivalent to: extern crate std as std;
982982
983-
extern crate "std" as ruststd; // linking to 'std' under another name
983+
extern crate std as ruststd; // linking to 'std' under another name
984984
```
985985

986986
##### Use declarations

branches/tmp/src/libcollections/bit.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ pub struct BitVec {
171171
impl Index<usize> for BitVec {
172172
type Output = bool;
173173

174+
175+
#[cfg(stage0)]
176+
#[inline]
177+
fn index(&self, i: &usize) -> &bool {
178+
if self.get(*i).expect("index out of bounds") {
179+
&TRUE
180+
} else {
181+
&FALSE
182+
}
183+
}
184+
185+
#[cfg(not(stage0))]
174186
#[inline]
175187
fn index(&self, i: usize) -> &bool {
176188
if self.get(i).expect("index out of bounds") {

branches/tmp/src/libcollections/btree/map.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,20 @@ impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> {
915915
}
916916
}
917917

918+
#[cfg(stage0)]
919+
#[stable(feature = "rust1", since = "1.0.0")]
920+
impl<K: Ord, Q: ?Sized, V> Index<Q> for BTreeMap<K, V>
921+
where K: Borrow<Q>, Q: Ord
922+
{
923+
type Output = V;
924+
925+
#[inline]
926+
fn index(&self, key: &Q) -> &V {
927+
self.get(key).expect("no entry found for key")
928+
}
929+
}
930+
931+
#[cfg(not(stage0))]
918932
#[stable(feature = "rust1", since = "1.0.0")]
919933
impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap<K, V>
920934
where K: Borrow<Q>, Q: Ord

branches/tmp/src/libcollections/btree/node.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,36 @@ macro_rules! node_slice_impl {
15241524
}
15251525

15261526
/// Returns a sub-slice with elements starting with `min_key`.
1527+
#[cfg(stage0)]
1528+
pub fn slice_from(self, min_key: &K) -> $NodeSlice<'a, K, V> {
1529+
// _______________
1530+
// |_1_|_3_|_5_|_7_|
1531+
// | | | | |
1532+
// 0 0 1 1 2 2 3 3 4 index
1533+
// | | | | |
1534+
// \___|___|___|___/ slice_from(&0); pos = 0
1535+
// \___|___|___/ slice_from(&2); pos = 1
1536+
// |___|___|___/ slice_from(&3); pos = 1; result.head_is_edge = false
1537+
// \___|___/ slice_from(&4); pos = 2
1538+
// \___/ slice_from(&6); pos = 3
1539+
// \|/ slice_from(&999); pos = 4
1540+
let (pos, pos_is_kv) = self.search_linear(min_key);
1541+
$NodeSlice {
1542+
has_edges: self.has_edges,
1543+
edges: if !self.has_edges {
1544+
self.edges
1545+
} else {
1546+
self.edges.$index(&(pos ..))
1547+
},
1548+
keys: &self.keys[pos ..],
1549+
vals: self.vals.$index(&(pos ..)),
1550+
head_is_edge: !pos_is_kv,
1551+
tail_is_edge: self.tail_is_edge,
1552+
}
1553+
}
1554+
1555+
/// Returns a sub-slice with elements starting with `min_key`.
1556+
#[cfg(not(stage0))]
15271557
pub fn slice_from(self, min_key: &K) -> $NodeSlice<'a, K, V> {
15281558
// _______________
15291559
// |_1_|_3_|_5_|_7_|
@@ -1552,6 +1582,37 @@ macro_rules! node_slice_impl {
15521582
}
15531583

15541584
/// Returns a sub-slice with elements up to and including `max_key`.
1585+
#[cfg(stage0)]
1586+
pub fn slice_to(self, max_key: &K) -> $NodeSlice<'a, K, V> {
1587+
// _______________
1588+
// |_1_|_3_|_5_|_7_|
1589+
// | | | | |
1590+
// 0 0 1 1 2 2 3 3 4 index
1591+
// | | | | |
1592+
//\|/ | | | | slice_to(&0); pos = 0
1593+
// \___/ | | | slice_to(&2); pos = 1
1594+
// \___|___| | | slice_to(&3); pos = 1; result.tail_is_edge = false
1595+
// \___|___/ | | slice_to(&4); pos = 2
1596+
// \___|___|___/ | slice_to(&6); pos = 3
1597+
// \___|___|___|___/ slice_to(&999); pos = 4
1598+
let (pos, pos_is_kv) = self.search_linear(max_key);
1599+
let pos = pos + if pos_is_kv { 1 } else { 0 };
1600+
$NodeSlice {
1601+
has_edges: self.has_edges,
1602+
edges: if !self.has_edges {
1603+
self.edges
1604+
} else {
1605+
self.edges.$index(&(.. (pos + 1)))
1606+
},
1607+
keys: &self.keys[..pos],
1608+
vals: self.vals.$index(&(.. pos)),
1609+
head_is_edge: self.head_is_edge,
1610+
tail_is_edge: !pos_is_kv,
1611+
}
1612+
}
1613+
1614+
/// Returns a sub-slice with elements up to and including `max_key`.
1615+
#[cfg(not(stage0))]
15551616
pub fn slice_to(self, max_key: &K) -> $NodeSlice<'a, K, V> {
15561617
// _______________
15571618
// |_1_|_3_|_5_|_7_|

branches/tmp/src/libcollections/string.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,13 @@ impl<'a> Add<&'a str> for String {
903903
impl ops::Index<ops::Range<usize>> for String {
904904
type Output = str;
905905

906+
#[cfg(stage0)]
907+
#[inline]
908+
fn index(&self, index: &ops::Range<usize>) -> &str {
909+
&self[..][*index]
910+
}
911+
912+
#[cfg(not(stage0))]
906913
#[inline]
907914
fn index(&self, index: ops::Range<usize>) -> &str {
908915
&self[..][index]
@@ -912,6 +919,13 @@ impl ops::Index<ops::Range<usize>> for String {
912919
impl ops::Index<ops::RangeTo<usize>> for String {
913920
type Output = str;
914921

922+
#[cfg(stage0)]
923+
#[inline]
924+
fn index(&self, index: &ops::RangeTo<usize>) -> &str {
925+
&self[..][*index]
926+
}
927+
928+
#[cfg(not(stage0))]
915929
#[inline]
916930
fn index(&self, index: ops::RangeTo<usize>) -> &str {
917931
&self[..][index]
@@ -921,6 +935,13 @@ impl ops::Index<ops::RangeTo<usize>> for String {
921935
impl ops::Index<ops::RangeFrom<usize>> for String {
922936
type Output = str;
923937

938+
#[cfg(stage0)]
939+
#[inline]
940+
fn index(&self, index: &ops::RangeFrom<usize>) -> &str {
941+
&self[..][*index]
942+
}
943+
944+
#[cfg(not(stage0))]
924945
#[inline]
925946
fn index(&self, index: ops::RangeFrom<usize>) -> &str {
926947
&self[..][index]
@@ -930,6 +951,13 @@ impl ops::Index<ops::RangeFrom<usize>> for String {
930951
impl ops::Index<ops::RangeFull> for String {
931952
type Output = str;
932953

954+
#[cfg(stage0)]
955+
#[inline]
956+
fn index(&self, _index: &ops::RangeFull) -> &str {
957+
unsafe { mem::transmute(&*self.vec) }
958+
}
959+
960+
#[cfg(not(stage0))]
933961
#[inline]
934962
fn index(&self, _index: ops::RangeFull) -> &str {
935963
unsafe { mem::transmute(&*self.vec) }

branches/tmp/src/libcollections/vec.rs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,15 @@ impl<T: Hash> Hash for Vec<T> {
13431343
impl<T> Index<usize> for Vec<T> {
13441344
type Output = T;
13451345

1346+
1347+
#[cfg(stage0)]
1348+
#[inline]
1349+
fn index(&self, index: &usize) -> &T {
1350+
// NB built-in indexing via `&[T]`
1351+
&(**self)[*index]
1352+
}
1353+
1354+
#[cfg(not(stage0))]
13461355
#[inline]
13471356
fn index(&self, index: usize) -> &T {
13481357
// NB built-in indexing via `&[T]`
@@ -1352,6 +1361,15 @@ impl<T> Index<usize> for Vec<T> {
13521361

13531362
#[stable(feature = "rust1", since = "1.0.0")]
13541363
impl<T> IndexMut<usize> for Vec<T> {
1364+
1365+
#[cfg(stage0)]
1366+
#[inline]
1367+
fn index_mut(&mut self, index: &usize) -> &mut T {
1368+
// NB built-in indexing via `&mut [T]`
1369+
&mut (**self)[*index]
1370+
}
1371+
1372+
#[cfg(not(stage0))]
13551373
#[inline]
13561374
fn index_mut(&mut self, index: usize) -> &mut T {
13571375
// NB built-in indexing via `&mut [T]`
@@ -1364,6 +1382,13 @@ impl<T> IndexMut<usize> for Vec<T> {
13641382
impl<T> ops::Index<ops::Range<usize>> for Vec<T> {
13651383
type Output = [T];
13661384

1385+
#[cfg(stage0)]
1386+
#[inline]
1387+
fn index(&self, index: &ops::Range<usize>) -> &[T] {
1388+
Index::index(&**self, index)
1389+
}
1390+
1391+
#[cfg(not(stage0))]
13671392
#[inline]
13681393
fn index(&self, index: ops::Range<usize>) -> &[T] {
13691394
Index::index(&**self, index)
@@ -1373,6 +1398,13 @@ impl<T> ops::Index<ops::Range<usize>> for Vec<T> {
13731398
impl<T> ops::Index<ops::RangeTo<usize>> for Vec<T> {
13741399
type Output = [T];
13751400

1401+
#[cfg(stage0)]
1402+
#[inline]
1403+
fn index(&self, index: &ops::RangeTo<usize>) -> &[T] {
1404+
Index::index(&**self, index)
1405+
}
1406+
1407+
#[cfg(not(stage0))]
13761408
#[inline]
13771409
fn index(&self, index: ops::RangeTo<usize>) -> &[T] {
13781410
Index::index(&**self, index)
@@ -1382,6 +1414,13 @@ impl<T> ops::Index<ops::RangeTo<usize>> for Vec<T> {
13821414
impl<T> ops::Index<ops::RangeFrom<usize>> for Vec<T> {
13831415
type Output = [T];
13841416

1417+
#[cfg(stage0)]
1418+
#[inline]
1419+
fn index(&self, index: &ops::RangeFrom<usize>) -> &[T] {
1420+
Index::index(&**self, index)
1421+
}
1422+
1423+
#[cfg(not(stage0))]
13851424
#[inline]
13861425
fn index(&self, index: ops::RangeFrom<usize>) -> &[T] {
13871426
Index::index(&**self, index)
@@ -1391,6 +1430,13 @@ impl<T> ops::Index<ops::RangeFrom<usize>> for Vec<T> {
13911430
impl<T> ops::Index<ops::RangeFull> for Vec<T> {
13921431
type Output = [T];
13931432

1433+
#[cfg(stage0)]
1434+
#[inline]
1435+
fn index(&self, _index: &ops::RangeFull) -> &[T] {
1436+
self
1437+
}
1438+
1439+
#[cfg(not(stage0))]
13941440
#[inline]
13951441
fn index(&self, _index: ops::RangeFull) -> &[T] {
13961442
self
@@ -1400,6 +1446,13 @@ impl<T> ops::Index<ops::RangeFull> for Vec<T> {
14001446
#[stable(feature = "rust1", since = "1.0.0")]
14011447
impl<T> ops::IndexMut<ops::Range<usize>> for Vec<T> {
14021448

1449+
#[cfg(stage0)]
1450+
#[inline]
1451+
fn index_mut(&mut self, index: &ops::Range<usize>) -> &mut [T] {
1452+
IndexMut::index_mut(&mut **self, index)
1453+
}
1454+
1455+
#[cfg(not(stage0))]
14031456
#[inline]
14041457
fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
14051458
IndexMut::index_mut(&mut **self, index)
@@ -1408,6 +1461,13 @@ impl<T> ops::IndexMut<ops::Range<usize>> for Vec<T> {
14081461
#[stable(feature = "rust1", since = "1.0.0")]
14091462
impl<T> ops::IndexMut<ops::RangeTo<usize>> for Vec<T> {
14101463

1464+
#[cfg(stage0)]
1465+
#[inline]
1466+
fn index_mut(&mut self, index: &ops::RangeTo<usize>) -> &mut [T] {
1467+
IndexMut::index_mut(&mut **self, index)
1468+
}
1469+
1470+
#[cfg(not(stage0))]
14111471
#[inline]
14121472
fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
14131473
IndexMut::index_mut(&mut **self, index)
@@ -1416,6 +1476,13 @@ impl<T> ops::IndexMut<ops::RangeTo<usize>> for Vec<T> {
14161476
#[stable(feature = "rust1", since = "1.0.0")]
14171477
impl<T> ops::IndexMut<ops::RangeFrom<usize>> for Vec<T> {
14181478

1479+
#[cfg(stage0)]
1480+
#[inline]
1481+
fn index_mut(&mut self, index: &ops::RangeFrom<usize>) -> &mut [T] {
1482+
IndexMut::index_mut(&mut **self, index)
1483+
}
1484+
1485+
#[cfg(not(stage0))]
14191486
#[inline]
14201487
fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
14211488
IndexMut::index_mut(&mut **self, index)
@@ -1424,6 +1491,13 @@ impl<T> ops::IndexMut<ops::RangeFrom<usize>> for Vec<T> {
14241491
#[stable(feature = "rust1", since = "1.0.0")]
14251492
impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
14261493

1494+
#[cfg(stage0)]
1495+
#[inline]
1496+
fn index_mut(&mut self, _index: &ops::RangeFull) -> &mut [T] {
1497+
self.as_mut_slice()
1498+
}
1499+
1500+
#[cfg(not(stage0))]
14271501
#[inline]
14281502
fn index_mut(&mut self, _index: ops::RangeFull) -> &mut [T] {
14291503
self.as_mut_slice()

branches/tmp/src/libcollections/vec_deque.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,13 @@ impl<A: Hash> Hash for VecDeque<A> {
17051705
impl<A> Index<usize> for VecDeque<A> {
17061706
type Output = A;
17071707

1708+
#[cfg(stage0)]
1709+
#[inline]
1710+
fn index(&self, i: &usize) -> &A {
1711+
self.get(*i).expect("Out of bounds access")
1712+
}
1713+
1714+
#[cfg(not(stage0))]
17081715
#[inline]
17091716
fn index(&self, i: usize) -> &A {
17101717
self.get(i).expect("Out of bounds access")
@@ -1713,6 +1720,13 @@ impl<A> Index<usize> for VecDeque<A> {
17131720

17141721
#[stable(feature = "rust1", since = "1.0.0")]
17151722
impl<A> IndexMut<usize> for VecDeque<A> {
1723+
#[cfg(stage0)]
1724+
#[inline]
1725+
fn index_mut(&mut self, i: &usize) -> &mut A {
1726+
self.get_mut(*i).expect("Out of bounds access")
1727+
}
1728+
1729+
#[cfg(not(stage0))]
17161730
#[inline]
17171731
fn index_mut(&mut self, i: usize) -> &mut A {
17181732
self.get_mut(i).expect("Out of bounds access")

0 commit comments

Comments
 (0)