Skip to content

Commit cc6ae7f

Browse files
committed
---
yaml --- r: 216695 b: refs/heads/stable c: 464077d h: refs/heads/master i: 216693: c35ee80 216691: 075a31d 216687: e192674 v: v3
1 parent e5c8fe4 commit cc6ae7f

Some content is hidden

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

61 files changed

+793
-345
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ refs/heads/tmp: 378a370ff2057afeb1eae86eb6e78c476866a4a6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: a5286998df566e736b32f6795bfc3803bdaf453d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 1884c87207369be9bdfc9b765d67c4dbbb08d3d6
32+
refs/heads/stable: 464077d0a723dfdae0bbc7d67bc34014f374c463
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375

branches/stable/src/doc/complement-design-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ representation as a primitive. This allows using Rust `enum`s in FFI where C
3939
`enum`s are also used, for most use cases. The attribute can also be applied
4040
to `struct`s to get the same layout as a C struct would.
4141

42-
[repr]: reference.html#miscellaneous-attributes
42+
[repr]: reference.html#ffi-attributes
4343

4444
## There is no GC
4545

branches/stable/src/doc/reference.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,13 +1867,12 @@ macro scope.
18671867
lower to the target's SIMD instructions, if any; the `simd` feature gate
18681868
is necessary to use this attribute.
18691869
- `static_assert` - on statics whose type is `bool`, terminates compilation
1870-
with an error if it is not initialized to `true`.
1871-
- `unsafe_destructor` - allow implementations of the "drop" language item
1872-
where the type it is implemented for does not implement the "send" language
1873-
item; the `unsafe_destructor` feature gate is needed to use this attribute
1870+
with an error if it is not initialized to `true`. To use this, the `static_assert`
1871+
feature gate must be enabled.
18741872
- `unsafe_no_drop_flag` - on structs, remove the flag that prevents
18751873
destructors from being run twice. Destructors might be run multiple times on
1876-
the same object with this attribute.
1874+
the same object with this attribute. To use this, the `unsafe_no_drop_flag` feature
1875+
gate must be enabled.
18771876
- `doc` - Doc comments such as `/// foo` are equivalent to `#[doc = "foo"]`.
18781877
- `rustc_on_unimplemented` - Write a custom note to be shown along with the error
18791878
when the trait is found to be unimplemented on a type.

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ fn main() {
8282
8383
let mut guess = String::new();
8484
85-
let input = io::stdin().read_line(&mut guess)
85+
io::stdin().read_line(&mut guess)
8686
.ok()
8787
.expect("Failed to read line");
8888
89-
println!("You guessed: {}", input);
89+
println!("You guessed: {}", guess);
9090
}
9191
```
9292

@@ -302,12 +302,12 @@ project.
302302
There’s just one line of this first example left:
303303

304304
```rust,ignore
305-
println!("You guessed: {}", input);
305+
println!("You guessed: {}", guess);
306306
}
307307
```
308308

309309
This prints out the string we saved our input in. The `{}`s are a placeholder,
310-
and so we pass it `input` as an argument. If we had multiple `{}`s, we would
310+
and so we pass it `guess` as an argument. If we had multiple `{}`s, we would
311311
pass multiple arguments:
312312

313313
```rust
@@ -410,24 +410,29 @@ $ cargo build
410410
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
411411
```
412412

413-
So, we told Cargo we wanted any version of `rand`, and so it fetched the
414-
latest version at the time this was written, `v0.3.8`. But what happens
415-
when next week, version `v0.4.0` comes out, which changes something with
416-
`rand`, and it includes a breaking change? After all, a `v0.y.z` version
417-
in SemVer can change every release.
413+
So, we told Cargo we wanted any version of `rand`, and so it fetched the latest
414+
version at the time this was written, `v0.3.8`. But what happens when next
415+
week, version `v0.3.9` comes out, with an important bugfix? While getting
416+
bugfixes is important, what if `0.3.9` contains a regression that breaks our
417+
code?
418418

419419
The answer to this problem is the `Cargo.lock` file you’ll now find in your
420420
project directory. When you build your project for the first time, Cargo
421421
figures out all of the versions that fit your criteria, and then writes them
422422
to the `Cargo.lock` file. When you build your project in the future, Cargo
423423
will see that the `Cargo.lock` file exists, and then use that specific version
424424
rather than do all the work of figuring out versions again. This lets you
425-
have a repeatable build automatically.
425+
have a repeatable build automatically. In other words, we’ll stay at `0.3.8`
426+
until we explicitly upgrade, and so will anyone who we share our code with,
427+
thanks to the lock file.
426428

427-
What about when we _do_ want to use `v0.4.0`? Cargo has another command,
429+
What about when we _do_ want to use `v0.3.9`? Cargo has another command,
428430
`update`, which says ‘ignore the lock, figure out all the latest versions that
429431
fit what we’ve specified. If that works, write those versions out to the lock
430-
file’.
432+
file’. But, by default, Cargo will only look for versions larger than `0.3.0`
433+
and smaller than `0.4.0`. If we want to move to `0.4.x`, we’d have to update
434+
the `Cargo.toml` directly. When we do, the next time we `cargo build`, Cargo
435+
will update the index and re-evaluate our `rand` requirements.
431436

432437
There’s a lot more to say about [Cargo][doccargo] and [its
433438
ecosystem][doccratesio], but for now, that’s all we need to know. Cargo makes

branches/stable/src/doc/trpl/strings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ individual bytes, or as codepoints:
7373
let hachiko = "忠犬ハチ公";
7474

7575
for b in hachiko.as_bytes() {
76-
print!("{}, ", b);
76+
print!("{}, ", b);
7777
}
7878

7979
println!("");
8080

8181
for c in hachiko.chars() {
82-
print!("{}, ", c);
82+
print!("{}, ", c);
8383
}
8484

8585
println!("");

branches/stable/src/grammar/RustLexer.g4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ lexer grammar RustLexer;
88

99

1010
tokens {
11-
EQ, LT, LE, EQEQ, NE, GE, GT, ANDAND, OROR, NOT, TILDE, PLUT,
11+
EQ, LT, LE, EQEQ, NE, GE, GT, ANDAND, OROR, NOT, TILDE, PLUS,
1212
MINUS, STAR, SLASH, PERCENT, CARET, AND, OR, SHL, SHR, BINOP,
1313
BINOPEQ, AT, DOT, DOTDOT, DOTDOTDOT, COMMA, SEMI, COLON,
1414
MOD_SEP, RARROW, FAT_ARROW, LPAREN, RPAREN, LBRACKET, RBRACKET,
15-
LBRACE, RBRACE, POUND, DOLLAR, UNDERSCORE, LIT_CHAR,
15+
LBRACE, RBRACE, POUND, DOLLAR, UNDERSCORE, LIT_CHAR, LIT_BYTE,
1616
LIT_INTEGER, LIT_FLOAT, LIT_STR, LIT_STR_RAW, LIT_BINARY,
17-
LIT_BINARY_RAW, IDENT, LIFETIME, WHITESPACE, DOC_COMMENT,
18-
COMMENT, SHEBANG
17+
LIT_BINARY_RAW, QUESTION, IDENT, LIFETIME, WHITESPACE, DOC_COMMENT,
18+
COMMENT, SHEBANG, UTF8_BOM
1919
}
2020

2121
import xidstart , xidcontinue;

branches/stable/src/grammar/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {
111111
"LIT_BINARY_RAW" => token::Literal(token::BinaryRaw(Name(0), 0), None),
112112
"QUESTION" => token::Question,
113113
"SHEBANG" => token::Shebang(Name(0)),
114-
_ => continue,
114+
_ => panic!("Bad token str `{}`", val),
115115
};
116116

117117
res.insert(num.to_string(), tok);

branches/stable/src/liballoc/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
//! }
3838
//! ```
3939
//!
40-
//! This will print `Cons(1, Box(Cons(2, Box(Nil))))`.
40+
//! This will print `Cons(1, Cons(2, Nil))`.
4141
//!
4242
//! Recursive structures must be boxed, because if the definition of `Cons` looked like this:
4343
//!

branches/stable/src/libcollections/bit.rs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ use core::hash;
8989
use core::iter::RandomAccessIterator;
9090
use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned};
9191
use core::iter::{self, FromIterator};
92+
use core::mem::swap;
9293
use core::ops::Index;
9394
use core::slice;
9495
use core::{u8, u32, usize};
@@ -602,6 +603,106 @@ impl BitVec {
602603
Iter { bit_vec: self, next_idx: 0, end_idx: self.nbits }
603604
}
604605

606+
/// Moves all bits from `other` into `Self`, leaving `other` empty.
607+
///
608+
/// # Examples
609+
///
610+
/// ```
611+
/// # #![feature(collections, bit_vec_append_split_off)]
612+
/// use std::collections::BitVec;
613+
///
614+
/// let mut a = BitVec::from_bytes(&[0b10000000]);
615+
/// let mut b = BitVec::from_bytes(&[0b01100001]);
616+
///
617+
/// a.append(&mut b);
618+
///
619+
/// assert_eq!(a.len(), 16);
620+
/// assert_eq!(b.len(), 0);
621+
/// assert!(a.eq_vec(&[true, false, false, false, false, false, false, false,
622+
/// false, true, true, false, false, false, false, true]));
623+
/// ```
624+
#[unstable(feature = "bit_vec_append_split_off",
625+
reason = "recently added as part of collections reform 2")]
626+
pub fn append(&mut self, other: &mut Self) {
627+
let b = self.len() % u32::BITS;
628+
629+
self.nbits += other.len();
630+
other.nbits = 0;
631+
632+
if b == 0 {
633+
self.storage.append(&mut other.storage);
634+
} else {
635+
self.storage.reserve(other.storage.len());
636+
637+
for block in other.storage.drain(..) {
638+
*(self.storage.last_mut().unwrap()) |= block << b;
639+
self.storage.push(block >> (u32::BITS - b));
640+
}
641+
}
642+
}
643+
644+
/// Splits the `BitVec` into two at the given bit,
645+
/// retaining the first half in-place and returning the second one.
646+
///
647+
/// # Examples
648+
///
649+
/// ```
650+
/// # #![feature(collections, bit_vec_append_split_off)]
651+
/// use std::collections::BitVec;
652+
/// let mut a = BitVec::new();
653+
/// a.push(true);
654+
/// a.push(false);
655+
/// a.push(false);
656+
/// a.push(true);
657+
///
658+
/// let b = a.split_off(2);
659+
///
660+
/// assert_eq!(a.len(), 2);
661+
/// assert_eq!(b.len(), 2);
662+
/// assert!(a.eq_vec(&[true, false]));
663+
/// assert!(b.eq_vec(&[false, true]));
664+
/// ```
665+
#[unstable(feature = "bit_vec_append_split_off",
666+
reason = "recently added as part of collections reform 2")]
667+
pub fn split_off(&mut self, at: usize) -> Self {
668+
assert!(at <= self.len(), "`at` out of bounds");
669+
670+
let mut other = BitVec::new();
671+
672+
if at == 0 {
673+
swap(self, &mut other);
674+
return other;
675+
} else if at == self.len() {
676+
return other;
677+
}
678+
679+
let w = at / u32::BITS;
680+
let b = at % u32::BITS;
681+
other.nbits = self.nbits - at;
682+
self.nbits = at;
683+
if b == 0 {
684+
// Split at block boundary
685+
other.storage = self.storage.split_off(w);
686+
} else {
687+
other.storage.reserve(self.storage.len() - w);
688+
689+
{
690+
let mut iter = self.storage[w..].iter();
691+
let mut last = *iter.next().unwrap();
692+
for &cur in iter {
693+
other.storage.push((last >> b) | (cur << (u32::BITS - b)));
694+
last = cur;
695+
}
696+
other.storage.push(last >> b);
697+
}
698+
699+
self.storage.truncate(w+1);
700+
self.fix_last_block();
701+
}
702+
703+
other
704+
}
705+
605706
/// Returns `true` if all bits are 0.
606707
///
607708
/// # Examples

0 commit comments

Comments
 (0)