Skip to content

Commit 511cdb9

Browse files
committed
---
yaml --- r: 210562 b: refs/heads/try c: af57ec5 h: refs/heads/master v: v3
1 parent 47f61d7 commit 511cdb9

File tree

38 files changed

+308
-80
lines changed

38 files changed

+308
-80
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: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: 683da9c3840a622601818488941161dc7d53652e
5+
refs/heads/try: af57ec58517caa2c1612cfe28ccb0ef7490c6427
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ variety of numbers, we need to give Rust a hint as to the exact type of number
713713
we want. Hence, `let guess: u32`. The colon (`:`) after `guess` tells Rust
714714
we’re going to annotate its type. `u32` is an unsigned, thirty-two bit
715715
integer. Rust has [a number of built-in number types][number], but we’ve
716-
chosen `u32`. It’s a good default choice for a small positive numer.
716+
chosen `u32`. It’s a good default choice for a small positive number.
717717
718718
[parse]: ../std/primitive.str.html#method.parse
719719
[number]: primitive-types.html#numeric-types
@@ -922,7 +922,7 @@ failure. Each contains more information: the successful parsed integer, or an
922922
error type. In this case, we `match` on `Ok(num)`, which sets the inner value
923923
of the `Ok` to the name `num`, and then we just return it on the right-hand
924924
side. In the `Err` case, we don’t care what kind of error it is, so we just
925-
use `_` intead of a name. This ignores the error, and `continue` causes us
925+
use `_` instead of a name. This ignores the error, and `continue` causes us
926926
to go to the next iteration of the `loop`.
927927
928928
Now we should be good! Let’s try:

branches/try/src/doc/trpl/match.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ side of a `let` binding or directly where an expression is used:
5050
```rust
5151
let x = 5;
5252

53-
let numer = match x {
53+
let number = match x {
5454
1 => "one",
5555
2 => "two",
5656
3 => "three",

branches/try/src/doc/trpl/mutability.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ When we call `clone()`, the `Arc<T>` needs to update the reference count. Yet
7878
we’ve not used any `mut`s here, `x` is an immutable binding, and we didn’t take
7979
`&mut 5` or anything. So what gives?
8080

81-
To this, we have to go back to the core of Rust’s guiding philosophy, memory
82-
safety, and the mechanism by which Rust guarantees it, the
81+
To understand this, we have to go back to the core of Rust’s guiding
82+
philosophy, memory safety, and the mechanism by which Rust guarantees it, the
8383
[ownership][ownership] system, and more specifically, [borrowing][borrowing]:
8484

8585
> You may have one or the other of these two kinds of borrows, but not both at

branches/try/src/doc/trpl/ownership.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn foo(v: Vec<i32>) -> Vec<i32> {
174174
}
175175
```
176176

177-
This would get very tedius. It gets worse the more things we want to take ownership of:
177+
This would get very tedious. It gets worse the more things we want to take ownership of:
178178

179179
```rust
180180
fn foo(v1: Vec<i32>, v2: Vec<i32>) -> (Vec<i32>, Vec<i32>, i32) {

branches/try/src/doc/trpl/primitive-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Slices have type `&[T]`. We’ll talk about that `T` when we cover
176176

177177
[generics]: generics.html
178178

179-
You can find more documentation for `slices`s [in the standard library
179+
You can find more documentation for slices [in the standard library
180180
documentation][slice].
181181

182182
[slice]: ../std/primitive.slice.html

branches/try/src/doc/trpl/references-and-borrowing.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ println!("{}", y);
312312

313313
We get this error:
314314

315+
```text
315316
error: `x` does not live long enough
316317
y = &x;
317318
^
@@ -334,3 +335,37 @@ In other words, `y` is only valid for the scope where `x` exists. As soon as
334335
`x` goes away, it becomes invalid to refer to it. As such, the error says that
335336
the borrow ‘doesn’t live long enough’ because it’s not valid for the right
336337
amount of time.
338+
339+
The same problem occurs when the reference is declared _before_ the variable it refers to:
340+
341+
```rust,ignore
342+
let y: &i32;
343+
let x = 5;
344+
y = &x;
345+
346+
println!("{}", y);
347+
```
348+
349+
We get this error:
350+
351+
```text
352+
error: `x` does not live long enough
353+
y = &x;
354+
^
355+
note: reference must be valid for the block suffix following statement 0 at
356+
2:16...
357+
let y: &i32;
358+
let x = 5;
359+
y = &x;
360+
361+
println!("{}", y);
362+
}
363+
364+
note: ...but borrowed value is only valid for the block suffix following
365+
statement 1 at 3:14
366+
let x = 5;
367+
y = &x;
368+
369+
println!("{}", y);
370+
}
371+
```

branches/try/src/etc/CONFIGS.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Configs
22

3-
Here are some links to repos with configs which ease the use of rust:
3+
These are some links to repos with configs which ease the use of rust.
4+
5+
## Officially Maintained Configs
46

57
* [rust.vim](https://github.com/rust-lang/rust.vim)
68
* [emacs rust-mode](https://github.com/rust-lang/rust-mode)
79
* [gedit-config](https://github.com/rust-lang/gedit-config)
810
* [kate-config](https://github.com/rust-lang/kate-config)
911
* [nano-config](https://github.com/rust-lang/nano-config)
1012
* [zsh-config](https://github.com/rust-lang/zsh-config)
13+
14+
## Community-maintained Configs
15+
16+
* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/))

branches/try/src/etc/check-sanitycheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import os
1414
import sys
1515
import functools
16-
import resource
1716

1817
STATUS = 0
1918

@@ -37,6 +36,7 @@ def inner():
3736

3837
@only_on(('linux', 'darwin', 'freebsd', 'openbsd'))
3938
def check_rlimit_core():
39+
import resource
4040
soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
4141
if soft > 0:
4242
error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', """\

branches/try/src/libcollections/bit.rs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,89 @@ impl BitSet {
17961796
self.other_op(other, |w1, w2| w1 ^ w2);
17971797
}
17981798

1799+
/// Moves all elements from `other` into `Self`, leaving `other` empty.
1800+
///
1801+
/// # Examples
1802+
///
1803+
/// ```
1804+
/// # #![feature(collections, bit_set_append_split_off)]
1805+
/// use std::collections::{BitVec, BitSet};
1806+
///
1807+
/// let mut a = BitSet::new();
1808+
/// a.insert(2);
1809+
/// a.insert(6);
1810+
///
1811+
/// let mut b = BitSet::new();
1812+
/// b.insert(1);
1813+
/// b.insert(3);
1814+
/// b.insert(6);
1815+
///
1816+
/// a.append(&mut b);
1817+
///
1818+
/// assert_eq!(a.len(), 4);
1819+
/// assert_eq!(b.len(), 0);
1820+
/// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01110010])));
1821+
/// ```
1822+
#[unstable(feature = "bit_set_append_split_off",
1823+
reason = "recently added as part of collections reform 2")]
1824+
pub fn append(&mut self, other: &mut Self) {
1825+
self.union_with(other);
1826+
other.clear();
1827+
}
1828+
1829+
/// Splits the `BitSet` into two at the given key including the key.
1830+
/// Retains the first part in-place while returning the second part.
1831+
///
1832+
/// # Examples
1833+
///
1834+
/// ```
1835+
/// # #![feature(collections, bit_set_append_split_off)]
1836+
/// use std::collections::{BitSet, BitVec};
1837+
/// let mut a = BitSet::new();
1838+
/// a.insert(2);
1839+
/// a.insert(6);
1840+
/// a.insert(1);
1841+
/// a.insert(3);
1842+
///
1843+
/// let b = a.split_off(3);
1844+
///
1845+
/// assert_eq!(a.len(), 2);
1846+
/// assert_eq!(b.len(), 2);
1847+
/// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100000])));
1848+
/// assert_eq!(b, BitSet::from_bit_vec(BitVec::from_bytes(&[0b00010010])));
1849+
/// ```
1850+
#[unstable(feature = "bit_set_append_split_off",
1851+
reason = "recently added as part of collections reform 2")]
1852+
pub fn split_off(&mut self, at: usize) -> Self {
1853+
let mut other = BitSet::new();
1854+
1855+
if at == 0 {
1856+
swap(self, &mut other);
1857+
return other;
1858+
} else if at >= self.bit_vec.len() {
1859+
return other;
1860+
}
1861+
1862+
// Calculate block and bit at which to split
1863+
let w = at / u32::BITS;
1864+
let b = at % u32::BITS;
1865+
1866+
// Pad `other` with `w` zero blocks,
1867+
// append `self`'s blocks in the range from `w` to the end to `other`
1868+
other.bit_vec.storage.extend(repeat(0u32).take(w)
1869+
.chain(self.bit_vec.storage[w..].iter().cloned()));
1870+
other.bit_vec.nbits = self.bit_vec.nbits;
1871+
1872+
if b > 0 {
1873+
other.bit_vec.storage[w] &= !0 << b;
1874+
}
1875+
1876+
// Sets `bit_vec.len()` and fixes the last block as well
1877+
self.bit_vec.truncate(at);
1878+
1879+
other
1880+
}
1881+
17991882
/// Returns the number of set bits in this set.
18001883
#[inline]
18011884
#[stable(feature = "rust1", since = "1.0.0")]

branches/try/src/libcollections/string.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ impl<T: fmt::Display + ?Sized> ToString for T {
10521052

10531053
#[stable(feature = "rust1", since = "1.0.0")]
10541054
impl AsRef<str> for String {
1055+
#[inline]
10551056
fn as_ref(&self) -> &str {
10561057
self
10571058
}

branches/try/src/libcollectionstest/bit/set.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,67 @@ fn test_bit_vec_clone() {
387387
assert!(b.contains(&1000));
388388
}
389389

390+
#[test]
391+
fn test_bit_set_append() {
392+
let mut a = BitSet::new();
393+
a.insert(2);
394+
a.insert(6);
395+
396+
let mut b = BitSet::new();
397+
b.insert(1);
398+
b.insert(3);
399+
b.insert(6);
400+
401+
a.append(&mut b);
402+
403+
assert_eq!(a.len(), 4);
404+
assert_eq!(b.len(), 0);
405+
assert!(b.capacity() >= 6);
406+
407+
assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01110010])));
408+
}
409+
410+
#[test]
411+
fn test_bit_set_split_off() {
412+
// Split at 0
413+
let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100000, 0b00010010, 0b10010010,
414+
0b00110011, 0b01101011, 0b10101101]));
415+
416+
let b = a.split_off(0);
417+
418+
assert_eq!(a.len(), 0);
419+
assert_eq!(b.len(), 21);
420+
421+
assert_eq!(b, BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100000, 0b00010010, 0b10010010,
422+
0b00110011, 0b01101011, 0b10101101])));
423+
424+
// Split behind last element
425+
let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100000, 0b00010010, 0b10010010,
426+
0b00110011, 0b01101011, 0b10101101]));
427+
428+
let b = a.split_off(50);
429+
430+
assert_eq!(a.len(), 21);
431+
assert_eq!(b.len(), 0);
432+
433+
assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100000, 0b00010010, 0b10010010,
434+
0b00110011, 0b01101011, 0b10101101])));
435+
436+
// Split at arbitrary element
437+
let mut a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100000, 0b00010010, 0b10010010,
438+
0b00110011, 0b01101011, 0b10101101]));
439+
440+
let b = a.split_off(34);
441+
442+
assert_eq!(a.len(), 12);
443+
assert_eq!(b.len(), 9);
444+
445+
assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b10100000, 0b00010010, 0b10010010,
446+
0b00110011, 0b01000000])));
447+
assert_eq!(b, BitSet::from_bit_vec(BitVec::from_bytes(&[0, 0, 0, 0,
448+
0b00101011, 0b10101101])));
449+
}
450+
390451
mod bench {
391452
use std::collections::{BitSet, BitVec};
392453
use std::__rand::{Rng, thread_rng, ThreadRng};

branches/try/src/libcollectionstest/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(bit_set_append_split_off)]
1112
#![feature(bit_vec_append_split_off)]
1213
#![feature(box_syntax)]
1314
#![feature(collections)]

branches/try/src/libcore/convert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl<T> AsMut<[T]> for [T] {
173173

174174
#[stable(feature = "rust1", since = "1.0.0")]
175175
impl AsRef<str> for str {
176+
#[inline]
176177
fn as_ref(&self) -> &str {
177178
self
178179
}

branches/try/src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
11251125
// that case we can adjust the length of the
11261126
// original vec accordingly, but we'd have to
11271127
// make trans do the right thing, and it would
1128-
// only work for `~` vectors. It seems simpler
1128+
// only work for `Box<[T]>`s. It seems simpler
11291129
// to just require that people call
11301130
// `vec.pop()` or `vec.unshift()`.
11311131
let slice_bk = ty::BorrowKind::from_mutbl(slice_mutbl);

branches/try/src/librustc/middle/traits/coherence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
323323
def_id.krate == ast::LOCAL_CRATE
324324
}
325325

326-
ty::ty_uniq(_) => { // treat ~T like Box<T>
326+
ty::ty_uniq(_) => { // Box<T>
327327
let krate = tcx.lang_items.owned_box().map(|d| d.krate);
328328
krate == Some(ast::LOCAL_CRATE)
329329
}

branches/try/src/librustc/middle/traits/select.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,10 +2441,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
24412441
/// `match_impl()`. For example, if `impl_def_id` is declared
24422442
/// as:
24432443
///
2444-
/// impl<T:Copy> Foo for ~T { ... }
2444+
/// impl<T:Copy> Foo for Box<T> { ... }
24452445
///
2446-
/// and `obligation_self_ty` is `int`, we'd back an `Err(_)`
2447-
/// result. But if `obligation_self_ty` were `~int`, we'd get
2446+
/// and `obligation_self_ty` is `int`, we'd get back an `Err(_)`
2447+
/// result. But if `obligation_self_ty` were `Box<int>`, we'd get
24482448
/// back `Ok(T=int)`.
24492449
fn match_inherent_impl(&mut self,
24502450
impl_def_id: ast::DefId,

branches/try/src/librustc/util/ppaux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice<T> {
637637
}
638638
}
639639

640-
// This is necessary to handle types like Option<~[T]>, for which
640+
// This is necessary to handle types like Option<Vec<T>>, for which
641641
// autoderef cannot convert the &[T] handler
642642
impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec<T> {
643643
fn repr(&self, tcx: &ctxt<'tcx>) -> String {

branches/try/src/librustc_borrowck/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
732732
/// let p: Point;
733733
/// p.x = 22; // ok, even though `p` is uninitialized
734734
///
735-
/// let p: ~Point;
735+
/// let p: Box<Point>;
736736
/// (*p).x = 22; // not ok, p is uninitialized, can't deref
737737
/// ```
738738
fn check_if_assigned_path_is_moved(&self,

branches/try/src/librustc_privacy/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
13141314
// `impl [... for] Private` is never visible.
13151315
let self_contains_private;
13161316
// impl [... for] Public<...>, but not `impl [... for]
1317-
// ~[Public]` or `(Public,)` etc.
1317+
// Vec<Public>` or `(Public,)` etc.
13181318
let self_is_public_path;
13191319

13201320
// check the properties of the Self type:

branches/try/src/librustc_trans/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI,
289289
// when using unix's linker. Perhaps one day when we just use a linker from LLVM
290290
// we won't need to do this name mangling. The problem with name mangling is
291291
// that it seriously limits the available characters. For example we can't
292-
// have things like &T or ~[T] in symbol names when one would theoretically
292+
// have things like &T in symbol names when one would theoretically
293293
// want them for things like impls of traits on that type.
294294
//
295295
// To be able to work on all platforms and get *some* reasonable output, we

0 commit comments

Comments
 (0)