Skip to content

Commit de7d0a7

Browse files
author
Jakub Bukaj
committed
---
yaml --- r: 159709 b: refs/heads/auto c: 54c76e6 h: refs/heads/master i: 159707: 291d09a v: v3
1 parent 7081ca1 commit de7d0a7

File tree

55 files changed

+331
-587
lines changed

Some content is hidden

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

55 files changed

+331
-587
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: bcd3a4f42bd7076725768b13a1948784bdcb02d5
13+
refs/heads/auto: 54c76e6e8193e96b2ca15542f916a7520cfaa75f
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/grammar/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn parse_antlr_token(s: &str, tokens: &HashMap<String, Token>) -> TokenAndSpan {
178178
let toknum = m.name("toknum");
179179
let content = m.name("content");
180180

181-
let proto_tok = tokens.get(&toknum).expect(format!("didn't find token {} in the map",
181+
let proto_tok = tokens.find_equiv(&toknum).expect(format!("didn't find token {} in the map",
182182
toknum).as_slice());
183183

184184
let nm = parse::token::intern(content);

branches/auto/src/libcollections/bit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl Bitv {
283283
x != 0
284284
}
285285

286-
/// Sets the value of a bit at an index `i`.
286+
/// Sets the value of a bit at a index `i`.
287287
///
288288
/// # Panics
289289
///
@@ -582,7 +582,7 @@ impl Bitv {
582582
///
583583
/// # Panics
584584
///
585-
/// Panics if the `Bitv` and slice are of different length.
585+
/// Panics if the the `Bitv` and slice are of different length.
586586
///
587587
/// # Example
588588
///

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

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use core::prelude::*;
2121

2222
use self::StackOp::*;
2323
use super::node::*;
24-
use core::borrow::BorrowFrom;
2524
use std::hash::{Writer, Hash};
2625
use core::default::Default;
2726
use core::{iter, fmt, mem};
@@ -57,7 +56,7 @@ use ring_buf::RingBuf;
5756
/// and possibly other factors. Using linear search, searching for a random element is expected
5857
/// to take O(B log<sub>B</sub>n) comparisons, which is generally worse than a BST. In practice,
5958
/// however, performance is excellent. `BTreeMap` is able to readily outperform `TreeMap` under
60-
/// many workloads, and is competitive where it doesn't. BTreeMap also generally *scales* better
59+
/// many workloads, and is competetive where it doesn't. BTreeMap also generally *scales* better
6160
/// than TreeMap, making it more appropriate for large datasets.
6261
///
6362
/// However, `TreeMap` may still be more appropriate to use in many contexts. If elements are very
@@ -185,9 +184,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
185184

186185
/// Returns a reference to the value corresponding to the key.
187186
///
188-
/// The key may be any borrowed form of the map's key type, but the ordering
189-
/// on the borrowed form *must* match the ordering on the key type.
190-
///
191187
/// # Example
192188
///
193189
/// ```
@@ -199,7 +195,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
199195
/// assert_eq!(map.get(&2), None);
200196
/// ```
201197
#[unstable = "matches collection reform specification, waiting for dust to settle"]
202-
pub fn get<Sized? Q>(&self, key: &Q) -> Option<&V> where Q: BorrowFrom<K> + Ord {
198+
pub fn get(&self, key: &K) -> Option<&V> {
203199
let mut cur_node = &self.root;
204200
loop {
205201
match cur_node.search(key) {
@@ -217,9 +213,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
217213

218214
/// Returns true if the map contains a value for the specified key.
219215
///
220-
/// The key may be any borrowed form of the map's key type, but the ordering
221-
/// on the borrowed form *must* match the ordering on the key type.
222-
///
223216
/// # Example
224217
///
225218
/// ```
@@ -231,7 +224,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
231224
/// assert_eq!(map.contains_key(&2), false);
232225
/// ```
233226
#[unstable = "matches collection reform specification, waiting for dust to settle"]
234-
pub fn contains_key<Sized? Q>(&self, key: &Q) -> bool where Q: BorrowFrom<K> + Ord {
227+
pub fn contains_key(&self, key: &K) -> bool {
235228
self.get(key).is_some()
236229
}
237230

@@ -243,9 +236,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
243236

244237
/// Returns a mutable reference to the value corresponding to the key.
245238
///
246-
/// The key may be any borrowed form of the map's key type, but the ordering
247-
/// on the borrowed form *must* match the ordering on the key type.
248-
///
249239
/// # Example
250240
///
251241
/// ```
@@ -261,7 +251,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
261251
/// ```
262252
// See `get` for implementation notes, this is basically a copy-paste with mut's added
263253
#[unstable = "matches collection reform specification, waiting for dust to settle"]
264-
pub fn get_mut<Sized? Q>(&mut self, key: &Q) -> Option<&mut V> where Q: BorrowFrom<K> + Ord {
254+
pub fn get_mut(&mut self, key: &K) -> Option<&mut V> {
265255
// temp_node is a Borrowck hack for having a mutable value outlive a loop iteration
266256
let mut temp_node = &mut self.root;
267257
loop {
@@ -420,9 +410,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
420410
/// Removes a key from the map, returning the value at the key if the key
421411
/// was previously in the map.
422412
///
423-
/// The key may be any borrowed form of the map's key type, but the ordering
424-
/// on the borrowed form *must* match the ordering on the key type.
425-
///
426413
/// # Example
427414
///
428415
/// ```
@@ -434,7 +421,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
434421
/// assert_eq!(map.remove(&1), None);
435422
/// ```
436423
#[unstable = "matches collection reform specification, waiting for dust to settle"]
437-
pub fn remove<Sized? Q>(&mut self, key: &Q) -> Option<V> where Q: BorrowFrom<K> + Ord {
424+
pub fn remove(&mut self, key: &K) -> Option<V> {
438425
// See `swap` for a more thorough description of the stuff going on in here
439426
let mut stack = stack::PartialSearchStack::new(self);
440427
loop {
@@ -803,18 +790,14 @@ impl<K: Show, V: Show> Show for BTreeMap<K, V> {
803790
}
804791
}
805792

806-
impl<K: Ord, Sized? Q, V> Index<Q, V> for BTreeMap<K, V>
807-
where Q: BorrowFrom<K> + Ord
808-
{
809-
fn index(&self, key: &Q) -> &V {
793+
impl<K: Ord, V> Index<K, V> for BTreeMap<K, V> {
794+
fn index(&self, key: &K) -> &V {
810795
self.get(key).expect("no entry found for key")
811796
}
812797
}
813798

814-
impl<K: Ord, Sized? Q, V> IndexMut<Q, V> for BTreeMap<K, V>
815-
where Q: BorrowFrom<K> + Ord
816-
{
817-
fn index_mut(&mut self, key: &Q) -> &mut V {
799+
impl<K: Ord, V> IndexMut<K, V> for BTreeMap<K, V> {
800+
fn index_mut(&mut self, key: &K) -> &mut V {
818801
self.get_mut(key).expect("no entry found for key")
819802
}
820803
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use core::prelude::*;
1919

2020
use core::{slice, mem, ptr};
2121
use core::iter::Zip;
22-
use core::borrow::BorrowFrom;
2322

2423
use vec;
2524
use vec::Vec;
@@ -48,7 +47,7 @@ pub struct Node<K, V> {
4847
// theory, if we take full control of allocation like HashMap's RawTable does,
4948
// and restrict leaves to max size 256 (not unreasonable for a btree node) we can cut
5049
// this down to just (ptr, cap: u8, size: u8, is_leaf: bool). With generic
51-
// integer arguments, cap can even move into the type, reducing this just to
50+
// integer arguments, cap can even move into the the type, reducing this just to
5251
// (ptr, size, is_leaf). This could also have cache benefits for very small nodes, as keys
5352
// could bleed into edges and vals.
5453
//
@@ -74,19 +73,19 @@ impl<K: Ord, V> Node<K, V> {
7473
/// Searches for the given key in the node. If it finds an exact match,
7574
/// `Found` will be yielded with the matching index. If it doesn't find an exact match,
7675
/// `GoDown` will be yielded with the index of the subtree the key must lie in.
77-
pub fn search<Sized? Q>(&self, key: &Q) -> SearchResult where Q: BorrowFrom<K> + Ord {
76+
pub fn search(&self, key: &K) -> SearchResult {
7877
// FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
7978
// For the B configured as of this writing (B = 6), binary search was *significantly*
8079
// worse for uints.
8180
self.search_linear(key)
8281
}
8382

84-
fn search_linear<Sized? Q>(&self, key: &Q) -> SearchResult where Q: BorrowFrom<K> + Ord {
83+
fn search_linear(&self, key: &K) -> SearchResult {
8584
for (i, k) in self.keys.iter().enumerate() {
86-
match key.cmp(BorrowFrom::borrow_from(k)) {
87-
Greater => {},
85+
match k.cmp(key) {
86+
Less => {},
8887
Equal => return Found(i),
89-
Less => return GoDown(i),
88+
Greater => return GoDown(i),
9089
}
9190
}
9291
GoDown(self.len())

branches/auto/src/libcollections/btree/set.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use core::prelude::*;
1515

1616
use btree_map::{BTreeMap, Keys, MoveEntries};
1717
use std::hash::Hash;
18-
use core::borrow::BorrowFrom;
1918
use core::default::Default;
2019
use core::{iter, fmt};
2120
use core::iter::Peekable;
@@ -168,10 +167,6 @@ impl<T: Ord> BTreeSet<T> {
168167

169168
/// Returns `true` if the set contains a value.
170169
///
171-
/// The value may be any borrowed form of the set's value type,
172-
/// but the ordering on the borrowed form *must* match the
173-
/// ordering on the value type.
174-
///
175170
/// # Example
176171
///
177172
/// ```
@@ -182,7 +177,7 @@ impl<T: Ord> BTreeSet<T> {
182177
/// assert_eq!(set.contains(&4), false);
183178
/// ```
184179
#[unstable = "matches collection reform specification, waiting for dust to settle"]
185-
pub fn contains<Sized? Q>(&self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
180+
pub fn contains(&self, value: &T) -> bool {
186181
self.map.contains_key(value)
187182
}
188183

@@ -296,10 +291,6 @@ impl<T: Ord> BTreeSet<T> {
296291
/// Removes a value from the set. Returns `true` if the value was
297292
/// present in the set.
298293
///
299-
/// The value may be any borrowed form of the set's value type,
300-
/// but the ordering on the borrowed form *must* match the
301-
/// ordering on the value type.
302-
///
303294
/// # Example
304295
///
305296
/// ```
@@ -312,7 +303,7 @@ impl<T: Ord> BTreeSet<T> {
312303
/// assert_eq!(set.remove(&2), false);
313304
/// ```
314305
#[unstable = "matches collection reform specification, waiting for dust to settle"]
315-
pub fn remove<Sized? Q>(&mut self, value: &Q) -> bool where Q: BorrowFrom<T> + Ord {
306+
pub fn remove(&mut self, value: &T) -> bool {
316307
self.map.remove(value).is_some()
317308
}
318309
}

branches/auto/src/libcollections/slice.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989

9090
use self::Direction::*;
9191
use alloc::boxed::Box;
92-
use core::borrow::{BorrowFrom, BorrowFromMut};
9392
use core::cmp;
9493
use core::kinds::Sized;
9594
use core::mem::size_of;
@@ -648,16 +647,6 @@ impl<T> SliceAllocPrelude<T> for [T] {
648647
}
649648
}
650649

651-
#[unstable = "trait is unstable"]
652-
impl<T> BorrowFrom<Vec<T>> for [T] {
653-
fn borrow_from(owned: &Vec<T>) -> &[T] { owned[] }
654-
}
655-
656-
#[unstable = "trait is unstable"]
657-
impl<T> BorrowFromMut<Vec<T>> for [T] {
658-
fn borrow_from_mut(owned: &mut Vec<T>) -> &mut [T] { owned[mut] }
659-
}
660-
661650
/// Unsafe operations
662651
pub mod raw {
663652
pub use core::slice::raw::{buf_as_slice, mut_buf_as_slice};

branches/auto/src/libcollections/str.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
pub use self::MaybeOwned::*;
5555
use self::RecompositionState::*;
5656
use self::DecompositionType::*;
57-
use core::borrow::BorrowFrom;
57+
5858
use core::default::Default;
5959
use core::fmt;
6060
use core::cmp;
@@ -604,11 +604,6 @@ impl<'a> fmt::Show for MaybeOwned<'a> {
604604
}
605605
}
606606

607-
#[unstable = "trait is unstable"]
608-
impl BorrowFrom<String> for str {
609-
fn borrow_from(owned: &String) -> &str { owned[] }
610-
}
611-
612607
/// Unsafe string operations.
613608
pub mod raw {
614609
pub use core::str::raw::{from_utf8, c_str_to_static_slice, slice_bytes};
@@ -1263,13 +1258,13 @@ mod tests {
12631258
#[test]
12641259
fn test_slice_shift_char() {
12651260
let data = "ประเทศไทย中";
1266-
assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中")));
1261+
assert_eq!(data.slice_shift_char(), (Some('ป'), "ระเทศไทย中"));
12671262
}
12681263

12691264
#[test]
12701265
fn test_slice_shift_char_2() {
12711266
let empty = "";
1272-
assert_eq!(empty.slice_shift_char(), None);
1267+
assert_eq!(empty.slice_shift_char(), (None, ""));
12731268
}
12741269

12751270
#[test]

branches/auto/src/libcollections/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl String {
549549
///
550550
/// # Warning
551551
///
552-
/// This is an O(n) operation as it requires copying every element in the
552+
/// This is a O(n) operation as it requires copying every element in the
553553
/// buffer.
554554
///
555555
/// # Panics
@@ -586,7 +586,7 @@ impl String {
586586
///
587587
/// # Warning
588588
///
589-
/// This is an O(n) operation as it requires copying every element in the
589+
/// This is a O(n) operation as it requires copying every element in the
590590
/// buffer.
591591
///
592592
/// # Panics

0 commit comments

Comments
 (0)