Skip to content

Commit b9dcc14

Browse files
committed
---
yaml --- r: 193343 b: refs/heads/beta c: 90686df h: refs/heads/master i: 193341: fbf39a9 193339: 7a85ddf 193335: 28639bb 193327: 8ffdc21 193311: 42d3ccb 193279: 0c482c6 v: v3
1 parent e9c36cb commit b9dcc14

File tree

119 files changed

+2530
-1544
lines changed

Some content is hidden

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

119 files changed

+2530
-1544
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: c195783c05d253c8e32fb781cce1ae978f8bd6bd
34+
refs/heads/beta: 90686df18cddb600ddfca6fa209cb046d8c4293d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: de8a23bbc3a7b9cbd7574b5b91a34af59bf030e6

branches/beta/src/doc/intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,10 @@ numbers[1] is 3
510510
numbers[0] is 2
511511
```
512512
513-
Each time, we can get a slithtly different output because the threads
514-
are not quaranteed to run in any set order. If you get the same order
515-
every time it is because each of these threads are very small and
516-
complete too fast for their indeterminate behavior to surface.
513+
Each time, we can get a slightly different output because the threads are not
514+
guaranteed to run in any set order. If you get the same order every time it is
515+
because each of these threads are very small and complete too fast for their
516+
indeterminate behavior to surface.
517517
518518
The important part here is that the Rust compiler was able to use ownership to
519519
give us assurance _at compile time_ that we weren't doing something incorrect

branches/beta/src/doc/trpl/guessing-game.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,11 @@ In this case, we say `x` is a `u32` explicitly, so Rust is able to properly
422422
tell `random()` what to generate. In a similar fashion, both of these work:
423423
424424
```{rust,ignore}
425-
let input_num = "5".parse::<u32>(); // input_num: Option<u32>
426-
let input_num: Result<u32, _> = "5".parse(); // input_num: Result<u32, <u32 as FromStr>::Err>
425+
let input_num_option = "5".parse::<u32>().ok(); // input_num: Option<u32>
426+
let input_num_result: Result<u32, _> = "5".parse(); // input_num: Result<u32, <u32 as FromStr>::Err>
427427
```
428428
429-
Here we're converting the `Result` returned by `parse` to an `Option` by using
429+
Above, we're converting the `Result` returned by `parse` to an `Option` by using
430430
the `ok` method as well. Anyway, with us now converting our input to a number,
431431
our code looks like this:
432432
@@ -470,14 +470,14 @@ Let's try it out!
470470
```bash
471471
$ cargo build
472472
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
473-
src/main.rs:22:15: 22:24 error: mismatched types: expected `u32` but found `core::option::Option<u32>` (expected u32 but found enum core::option::Option)
474-
src/main.rs:22 match cmp(input_num, secret_number) {
473+
src/main.rs:21:15: 21:24 error: mismatched types: expected `u32`, found `core::result::Result<u32, core::num::ParseIntError>` (expected u32, found enum `core::result::Result`) [E0308]
474+
src/main.rs:21 match cmp(input_num, secret_number) {
475475
^~~~~~~~~
476476
error: aborting due to previous error
477477
```
478478
479-
Oh yeah! Our `input_num` has the type `Option<u32>`, rather than `u32`. We
480-
need to unwrap the Option. If you remember from before, `match` is a great way
479+
Oh yeah! Our `input_num` has the type `Result<u32, <some error>>`, rather than `u32`. We
480+
need to unwrap the Result. If you remember from before, `match` is a great way
481481
to do that. Try this code:
482482
483483
```{rust,no_run}
@@ -500,7 +500,7 @@ fn main() {
500500
let input_num: Result<u32, _> = input.parse();
501501

502502
let num = match input_num {
503-
Ok(num) => num,
503+
Ok(n) => n,
504504
Err(_) => {
505505
println!("Please input a number!");
506506
return;
@@ -524,7 +524,7 @@ fn cmp(a: u32, b: u32) -> Ordering {
524524
}
525525
```
526526
527-
We use a `match` to either give us the `u32` inside of the `Option`, or else
527+
We use a `match` to either give us the `u32` inside of the `Result`, or else
528528
print an error message and return. Let's give this a shot:
529529
530530
```bash

branches/beta/src/liballoc/arc.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ impl<T> Arc<T> {
201201
impl<T> Arc<T> {
202202
#[inline]
203203
fn inner(&self) -> &ArcInner<T> {
204-
// This unsafety is ok because while this arc is alive we're guaranteed that the inner
205-
// pointer is valid. Furthermore, we know that the `ArcInner` structure itself is `Sync`
206-
// because the inner data is `Sync` as well, so we're ok loaning out an immutable pointer
207-
// to these contents.
204+
// This unsafety is ok because while this arc is alive we're guaranteed
205+
// that the inner pointer is valid. Furthermore, we know that the
206+
// `ArcInner` structure itself is `Sync` because the inner data is
207+
// `Sync` as well, so we're ok loaning out an immutable pointer to these
208+
// contents.
208209
unsafe { &**self._ptr }
209210
}
210211
}
@@ -236,13 +237,15 @@ impl<T> Clone for Arc<T> {
236237
/// ```
237238
#[inline]
238239
fn clone(&self) -> Arc<T> {
239-
// Using a relaxed ordering is alright here, as knowledge of the original reference
240-
// prevents other threads from erroneously deleting the object.
240+
// Using a relaxed ordering is alright here, as knowledge of the
241+
// original reference prevents other threads from erroneously deleting
242+
// the object.
241243
//
242-
// As explained in the [Boost documentation][1], Increasing the reference counter can
243-
// always be done with memory_order_relaxed: New references to an object can only be formed
244-
// from an existing reference, and passing an existing reference from one thread to another
245-
// must already provide any required synchronization.
244+
// As explained in the [Boost documentation][1], Increasing the
245+
// reference counter can always be done with memory_order_relaxed: New
246+
// references to an object can only be formed from an existing
247+
// reference, and passing an existing reference from one thread to
248+
// another must already provide any required synchronization.
246249
//
247250
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
248251
self.inner().strong.fetch_add(1, Relaxed);

branches/beta/src/libcollections/bit.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,17 @@ fn blocks_for_bits(bits: usize) -> usize {
189189
//
190190
// Note that we can technically avoid this branch with the expression
191191
// `(nbits + u32::BITS - 1) / 32::BITS`, but if nbits is almost usize::MAX this will overflow.
192-
if bits % u32::BITS == 0 {
193-
bits / u32::BITS
192+
if bits % u32::BITS as usize == 0 {
193+
bits / u32::BITS as usize
194194
} else {
195-
bits / u32::BITS + 1
195+
bits / u32::BITS as usize + 1
196196
}
197197
}
198198

199199
/// Computes the bitmask for the final word of the vector
200200
fn mask_for_bits(bits: usize) -> u32 {
201201
// Note especially that a perfect multiple of u32::BITS should mask all 1s.
202-
!0u32 >> (u32::BITS - bits % u32::BITS) % u32::BITS
202+
!0u32 >> (u32::BITS as usize - bits % u32::BITS as usize) % u32::BITS as usize
203203
}
204204

205205
impl BitVec {
@@ -237,7 +237,7 @@ impl BitVec {
237237
/// An operation might screw up the unused bits in the last block of the
238238
/// `BitVec`. As per (3), it's assumed to be all 0s. This method fixes it up.
239239
fn fix_last_block(&mut self) {
240-
let extra_bits = self.len() % u32::BITS;
240+
let extra_bits = self.len() % u32::BITS as usize;
241241
if extra_bits > 0 {
242242
let mask = (1 << extra_bits) - 1;
243243
let storage_len = self.storage.len();
@@ -313,7 +313,7 @@ impl BitVec {
313313
/// false, false, true, false]));
314314
/// ```
315315
pub fn from_bytes(bytes: &[u8]) -> BitVec {
316-
let len = bytes.len().checked_mul(u8::BITS).expect("capacity overflow");
316+
let len = bytes.len().checked_mul(u8::BITS as usize).expect("capacity overflow");
317317
let mut bit_vec = BitVec::with_capacity(len);
318318
let complete_words = bytes.len() / 4;
319319
let extra_bytes = bytes.len() % 4;
@@ -380,8 +380,8 @@ impl BitVec {
380380
if i >= self.nbits {
381381
return None;
382382
}
383-
let w = i / u32::BITS;
384-
let b = i % u32::BITS;
383+
let w = i / u32::BITS as usize;
384+
let b = i % u32::BITS as usize;
385385
self.storage.get(w).map(|&block|
386386
(block & (1 << b)) != 0
387387
)
@@ -407,8 +407,8 @@ impl BitVec {
407407
reason = "panic semantics are likely to change in the future")]
408408
pub fn set(&mut self, i: usize, x: bool) {
409409
assert!(i < self.nbits);
410-
let w = i / u32::BITS;
411-
let b = i % u32::BITS;
410+
let w = i / u32::BITS as usize;
411+
let b = i % u32::BITS as usize;
412412
let flag = 1 << b;
413413
let val = if x { self.storage[w] | flag }
414414
else { self.storage[w] & !flag };
@@ -789,7 +789,7 @@ impl BitVec {
789789
#[inline]
790790
#[stable(feature = "rust1", since = "1.0.0")]
791791
pub fn capacity(&self) -> usize {
792-
self.storage.capacity().checked_mul(u32::BITS).unwrap_or(usize::MAX)
792+
self.storage.capacity().checked_mul(u32::BITS as usize).unwrap_or(usize::MAX)
793793
}
794794

795795
/// Grows the `BitVec` in-place, adding `n` copies of `value` to the `BitVec`.
@@ -819,7 +819,7 @@ impl BitVec {
819819

820820
// Correct the old tail word, setting or clearing formerly unused bits
821821
let old_last_word = blocks_for_bits(self.nbits) - 1;
822-
if self.nbits % u32::BITS > 0 {
822+
if self.nbits % u32::BITS as usize > 0 {
823823
let mask = mask_for_bits(self.nbits);
824824
if value {
825825
self.storage[old_last_word] |= !mask;
@@ -868,7 +868,7 @@ impl BitVec {
868868
// (3)
869869
self.set(i, false);
870870
self.nbits = i;
871-
if self.nbits % u32::BITS == 0 {
871+
if self.nbits % u32::BITS as usize == 0 {
872872
// (2)
873873
self.storage.pop();
874874
}
@@ -890,7 +890,7 @@ impl BitVec {
890890
/// ```
891891
#[stable(feature = "rust1", since = "1.0.0")]
892892
pub fn push(&mut self, elem: bool) {
893-
if self.nbits % u32::BITS == 0 {
893+
if self.nbits % u32::BITS as usize == 0 {
894894
self.storage.push(0);
895895
}
896896
let insert_pos = self.nbits;
@@ -1406,7 +1406,7 @@ impl BitSet {
14061406
// Truncate
14071407
let trunc_len = cmp::max(old_len - n, 1);
14081408
bit_vec.storage.truncate(trunc_len);
1409-
bit_vec.nbits = trunc_len * u32::BITS;
1409+
bit_vec.nbits = trunc_len * u32::BITS as usize;
14101410
}
14111411

14121412
/// Iterator over each u32 stored in the `BitSet`.
@@ -1663,7 +1663,7 @@ impl BitSet {
16631663
#[inline]
16641664
#[stable(feature = "rust1", since = "1.0.0")]
16651665
pub fn len(&self) -> usize {
1666-
self.bit_vec.blocks().fold(0, |acc, n| acc + n.count_ones())
1666+
self.bit_vec.blocks().fold(0, |acc, n| acc + n.count_ones() as usize)
16671667
}
16681668

16691669
/// Returns whether there are no bits set in this set
@@ -1831,13 +1831,13 @@ impl<'a> Iterator for TwoBitPositions<'a> {
18311831
fn next(&mut self) -> Option<usize> {
18321832
while self.next_idx < self.set.bit_vec.len() ||
18331833
self.next_idx < self.other.bit_vec.len() {
1834-
let bit_idx = self.next_idx % u32::BITS;
1834+
let bit_idx = self.next_idx % u32::BITS as usize;
18351835
if bit_idx == 0 {
18361836
let s_bit_vec = &self.set.bit_vec;
18371837
let o_bit_vec = &self.other.bit_vec;
18381838
// Merging the two words is a bit of an awkward dance since
18391839
// one BitVec might be longer than the other
1840-
let word_idx = self.next_idx / u32::BITS;
1840+
let word_idx = self.next_idx / u32::BITS as usize;
18411841
let w1 = if word_idx < s_bit_vec.storage.len() {
18421842
s_bit_vec.storage[word_idx]
18431843
} else { 0 };
@@ -2441,70 +2441,70 @@ mod tests {
24412441

24422442
#[test]
24432443
fn test_bit_vec_push_pop() {
2444-
let mut s = BitVec::from_elem(5 * u32::BITS - 2, false);
2445-
assert_eq!(s.len(), 5 * u32::BITS - 2);
2446-
assert_eq!(s[5 * u32::BITS - 3], false);
2444+
let mut s = BitVec::from_elem(5 * u32::BITS as usize - 2, false);
2445+
assert_eq!(s.len(), 5 * u32::BITS as usize - 2);
2446+
assert_eq!(s[5 * u32::BITS as usize - 3], false);
24472447
s.push(true);
24482448
s.push(true);
2449-
assert_eq!(s[5 * u32::BITS - 2], true);
2450-
assert_eq!(s[5 * u32::BITS - 1], true);
2449+
assert_eq!(s[5 * u32::BITS as usize - 2], true);
2450+
assert_eq!(s[5 * u32::BITS as usize - 1], true);
24512451
// Here the internal vector will need to be extended
24522452
s.push(false);
2453-
assert_eq!(s[5 * u32::BITS], false);
2453+
assert_eq!(s[5 * u32::BITS as usize], false);
24542454
s.push(false);
2455-
assert_eq!(s[5 * u32::BITS + 1], false);
2456-
assert_eq!(s.len(), 5 * u32::BITS + 2);
2455+
assert_eq!(s[5 * u32::BITS as usize + 1], false);
2456+
assert_eq!(s.len(), 5 * u32::BITS as usize + 2);
24572457
// Pop it all off
24582458
assert_eq!(s.pop(), Some(false));
24592459
assert_eq!(s.pop(), Some(false));
24602460
assert_eq!(s.pop(), Some(true));
24612461
assert_eq!(s.pop(), Some(true));
2462-
assert_eq!(s.len(), 5 * u32::BITS - 2);
2462+
assert_eq!(s.len(), 5 * u32::BITS as usize - 2);
24632463
}
24642464

24652465
#[test]
24662466
fn test_bit_vec_truncate() {
2467-
let mut s = BitVec::from_elem(5 * u32::BITS, true);
2467+
let mut s = BitVec::from_elem(5 * u32::BITS as usize, true);
24682468

2469-
assert_eq!(s, BitVec::from_elem(5 * u32::BITS, true));
2470-
assert_eq!(s.len(), 5 * u32::BITS);
2471-
s.truncate(4 * u32::BITS);
2472-
assert_eq!(s, BitVec::from_elem(4 * u32::BITS, true));
2473-
assert_eq!(s.len(), 4 * u32::BITS);
2469+
assert_eq!(s, BitVec::from_elem(5 * u32::BITS as usize, true));
2470+
assert_eq!(s.len(), 5 * u32::BITS as usize);
2471+
s.truncate(4 * u32::BITS as usize);
2472+
assert_eq!(s, BitVec::from_elem(4 * u32::BITS as usize, true));
2473+
assert_eq!(s.len(), 4 * u32::BITS as usize);
24742474
// Truncating to a size > s.len() should be a noop
2475-
s.truncate(5 * u32::BITS);
2476-
assert_eq!(s, BitVec::from_elem(4 * u32::BITS, true));
2477-
assert_eq!(s.len(), 4 * u32::BITS);
2478-
s.truncate(3 * u32::BITS - 10);
2479-
assert_eq!(s, BitVec::from_elem(3 * u32::BITS - 10, true));
2480-
assert_eq!(s.len(), 3 * u32::BITS - 10);
2475+
s.truncate(5 * u32::BITS as usize);
2476+
assert_eq!(s, BitVec::from_elem(4 * u32::BITS as usize, true));
2477+
assert_eq!(s.len(), 4 * u32::BITS as usize);
2478+
s.truncate(3 * u32::BITS as usize - 10);
2479+
assert_eq!(s, BitVec::from_elem(3 * u32::BITS as usize - 10, true));
2480+
assert_eq!(s.len(), 3 * u32::BITS as usize - 10);
24812481
s.truncate(0);
24822482
assert_eq!(s, BitVec::from_elem(0, true));
24832483
assert_eq!(s.len(), 0);
24842484
}
24852485

24862486
#[test]
24872487
fn test_bit_vec_reserve() {
2488-
let mut s = BitVec::from_elem(5 * u32::BITS, true);
2488+
let mut s = BitVec::from_elem(5 * u32::BITS as usize, true);
24892489
// Check capacity
2490-
assert!(s.capacity() >= 5 * u32::BITS);
2491-
s.reserve(2 * u32::BITS);
2492-
assert!(s.capacity() >= 7 * u32::BITS);
2493-
s.reserve(7 * u32::BITS);
2494-
assert!(s.capacity() >= 12 * u32::BITS);
2495-
s.reserve_exact(7 * u32::BITS);
2496-
assert!(s.capacity() >= 12 * u32::BITS);
2497-
s.reserve(7 * u32::BITS + 1);
2498-
assert!(s.capacity() >= 12 * u32::BITS + 1);
2490+
assert!(s.capacity() >= 5 * u32::BITS as usize);
2491+
s.reserve(2 * u32::BITS as usize);
2492+
assert!(s.capacity() >= 7 * u32::BITS as usize);
2493+
s.reserve(7 * u32::BITS as usize);
2494+
assert!(s.capacity() >= 12 * u32::BITS as usize);
2495+
s.reserve_exact(7 * u32::BITS as usize);
2496+
assert!(s.capacity() >= 12 * u32::BITS as usize);
2497+
s.reserve(7 * u32::BITS as usize + 1);
2498+
assert!(s.capacity() >= 12 * u32::BITS as usize + 1);
24992499
// Check that length hasn't changed
2500-
assert_eq!(s.len(), 5 * u32::BITS);
2500+
assert_eq!(s.len(), 5 * u32::BITS as usize);
25012501
s.push(true);
25022502
s.push(false);
25032503
s.push(true);
2504-
assert_eq!(s[5 * u32::BITS - 1], true);
2505-
assert_eq!(s[5 * u32::BITS - 0], true);
2506-
assert_eq!(s[5 * u32::BITS + 1], false);
2507-
assert_eq!(s[5 * u32::BITS + 2], true);
2504+
assert_eq!(s[5 * u32::BITS as usize - 1], true);
2505+
assert_eq!(s[5 * u32::BITS as usize - 0], true);
2506+
assert_eq!(s[5 * u32::BITS as usize + 1], false);
2507+
assert_eq!(s[5 * u32::BITS as usize + 2], true);
25082508
}
25092509

25102510
#[test]
@@ -2557,7 +2557,7 @@ mod bit_vec_bench {
25572557
let mut bit_vec = 0 as usize;
25582558
b.iter(|| {
25592559
for _ in 0..100 {
2560-
bit_vec |= 1 << ((r.next_u32() as usize) % u32::BITS);
2560+
bit_vec |= 1 << ((r.next_u32() as usize) % u32::BITS as usize);
25612561
}
25622562
black_box(&bit_vec);
25632563
});
@@ -2590,10 +2590,10 @@ mod bit_vec_bench {
25902590
#[bench]
25912591
fn bench_bit_set_small(b: &mut Bencher) {
25922592
let mut r = rng();
2593-
let mut bit_vec = BitVec::from_elem(u32::BITS, false);
2593+
let mut bit_vec = BitVec::from_elem(u32::BITS as usize, false);
25942594
b.iter(|| {
25952595
for _ in 0..100 {
2596-
bit_vec.set((r.next_u32() as usize) % u32::BITS, true);
2596+
bit_vec.set((r.next_u32() as usize) % u32::BITS as usize, true);
25972597
}
25982598
black_box(&bit_vec);
25992599
});
@@ -2610,7 +2610,7 @@ mod bit_vec_bench {
26102610

26112611
#[bench]
26122612
fn bench_bit_vec_small_iter(b: &mut Bencher) {
2613-
let bit_vec = BitVec::from_elem(u32::BITS, false);
2613+
let bit_vec = BitVec::from_elem(u32::BITS as usize, false);
26142614
b.iter(|| {
26152615
let mut sum = 0;
26162616
for _ in 0..10 {
@@ -3052,7 +3052,7 @@ mod bit_set_bench {
30523052
let mut bit_vec = BitSet::new();
30533053
b.iter(|| {
30543054
for _ in 0..100 {
3055-
bit_vec.insert((r.next_u32() as usize) % u32::BITS);
3055+
bit_vec.insert((r.next_u32() as usize) % u32::BITS as usize);
30563056
}
30573057
black_box(&bit_vec);
30583058
});

0 commit comments

Comments
 (0)