Skip to content

Commit eb1b500

Browse files
committed
Auto merge of #22548 - Manishearth:rollup, r=Manishearth
I had most of these tested locally, why not get them out of the way too?
2 parents 2b01a37 + 686648d commit eb1b500

File tree

198 files changed

+1274
-6271
lines changed

Some content is hidden

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

198 files changed

+1274
-6271
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ links to the major sections:
1414
If you have questions, please make a post on [internals.rust-lang.org][internals] or
1515
hop on [#rust-internals][pound-rust-internals].
1616

17-
As a reminder, all contributors are expected to follow our [Code of Conduct](coc).
17+
As a reminder, all contributors are expected to follow our [Code of Conduct][coc].
1818

1919
[pound-rust-internals]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals
2020
[internals]: http://internals.rust-lang.org

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Version 1.0.0-alpha.2 (February 2015)
5151
* Abstract [OS-specific string types][osstr], `std::ff::{OsString,
5252
OsStr}`, provide strings in platform-specific encodings for easier
5353
interop with system APIs. [RFC][osstr-rfc].
54-
* The `boxed::into_raw` and `Box::frow_raw` functions [convert
54+
* The `boxed::into_raw` and `Box::from_raw` functions [convert
5555
between `Box<T>` and `*mut T`][boxraw], a common pattern for
5656
creating raw pointers.
5757

src/doc/trpl/guessing-game.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn main() {
9191
```
9292

9393
You've seen this code before, when we talked about standard input. We
94-
import the `std::io` module with `use`, and then our `main` function contains
94+
import the `std::old_io` module with `use`, and then our `main` function contains
9595
our program's logic. We print a little message announcing the game, ask the
9696
user to input a guess, get their input, and then print it out.
9797

src/doc/trpl/if.md

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ if x == 5 {
3434
}
3535
```
3636

37+
If there is more than one case, use an `else if`:
38+
39+
```rust
40+
let x = 5;
41+
42+
if x == 5 {
43+
println!("x is five!");
44+
} else if x == 6 {
45+
println!("x is six!");
46+
} else {
47+
println!("x is not five or six :(");
48+
}
49+
```
50+
3751
This is all pretty standard. However, you can also do this:
3852

3953

src/doc/trpl/pointers.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,9 @@ than the hundred `int`s that make up the `BigStruct`.
687687

688688
This is an antipattern in Rust. Instead, write this:
689689

690-
```{rust}
690+
```rust
691+
#![feature(box_syntax)]
692+
691693
struct BigStruct {
692694
one: i32,
693695
two: i32,
@@ -706,10 +708,13 @@ fn main() {
706708
one_hundred: 100,
707709
});
708710

709-
let y = Box::new(foo(x));
711+
let y = box foo(x);
710712
}
711713
```
712714

715+
Note that this uses the `box_syntax` feature gate, so this syntax may change in
716+
the future.
717+
713718
This gives you flexibility without sacrificing performance.
714719

715720
You may think that this gives us terrible performance: return a value and then

src/doc/trpl/static-and-dynamic-dispatch.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ inlining and hence usually higher performance. It also has some downsides:
8484
causing code bloat due to many copies of the same function existing in the
8585
binary, one for each type.
8686

87-
Furthermore, compilers aren’t perfect and may “optimise” code to become slower.
87+
Furthermore, compilers aren’t perfect and may “optimize” code to become slower.
8888
For example, functions inlined too eagerly will bloat the instruction cache
8989
(cache rules everything around us). This is part of the reason that `#[inline]`
9090
and `#[inline(always)]` should be used carefully, and one reason why using a
@@ -104,15 +104,15 @@ objects, like `&Foo` or `Box<Foo>`, are normal values that store a value of
104104
known at runtime. The methods of the trait can be called on a trait object via
105105
a special record of function pointers (created and managed by the compiler).
106106

107-
A function that takes a trait object is not specialised to each of the types
107+
A function that takes a trait object is not specialized to each of the types
108108
that implements `Foo`: only one copy is generated, often (but not always)
109109
resulting in less code bloat. However, this comes at the cost of requiring
110110
slower virtual function calls, and effectively inhibiting any chance of
111111
inlining and related optimisations from occurring.
112112

113113
Trait objects are both simple and complicated: their core representation and
114114
layout is quite straight-forward, but there are some curly error messages and
115-
surprising behaviours to discover.
115+
surprising behaviors to discover.
116116

117117
### Obtaining a trait object
118118

@@ -140,13 +140,13 @@ and casts are identical.
140140

141141
This operation can be seen as "erasing" the compiler's knowledge about the
142142
specific type of the pointer, and hence trait objects are sometimes referred to
143-
"type erasure".
143+
as "type erasure".
144144

145145
### Representation
146146

147147
Let's start simple, with the runtime representation of a trait object. The
148148
`std::raw` module contains structs with layouts that are the same as the
149-
complicated build-in types, [including trait objects][stdraw]:
149+
complicated built-in types, [including trait objects][stdraw]:
150150

151151
```rust
152152
# mod foo {
@@ -223,14 +223,14 @@ static Foo_for_String_vtable: FooVtable = FooVtable {
223223
The `destructor` field in each vtable points to a function that will clean up
224224
any resources of the vtable's type, for `u8` it is trivial, but for `String` it
225225
will free the memory. This is necessary for owning trait objects like
226-
`Box<Foo>`, which need to clean-up both the `Box` allocation and as well as the
226+
`Box<Foo>`, which need to clean-up both the `Box` allocation as well as the
227227
internal type when they go out of scope. The `size` and `align` fields store
228228
the size of the erased type, and its alignment requirements; these are
229229
essentially unused at the moment since the information is embedded in the
230-
destructor, but will be used in future, as trait objects are progressively made
231-
more flexible.
230+
destructor, but will be used in the future, as trait objects are progressively
231+
made more flexible.
232232

233-
Suppose we've got some values that implement `Foo`, the explicit form of
233+
Suppose we've got some values that implement `Foo`, then the explicit form of
234234
construction and use of `Foo` trait objects might look a bit like (ignoring the
235235
type mismatches: they're all just pointers anyway):
236236

src/liballoc/arc.rs

-7
Original file line numberDiff line numberDiff line change
@@ -598,13 +598,6 @@ impl<T: Default + Sync + Send> Default for Arc<T> {
598598
fn default() -> Arc<T> { Arc::new(Default::default()) }
599599
}
600600

601-
#[cfg(stage0)]
602-
impl<H: Hasher, T: Hash<H>> Hash<H> for Arc<T> {
603-
fn hash(&self, state: &mut H) {
604-
(**self).hash(state)
605-
}
606-
}
607-
#[cfg(not(stage0))]
608601
#[stable(feature = "rust1", since = "1.0.0")]
609602
impl<T: Hash> Hash for Arc<T> {
610603
fn hash<H: Hasher>(&self, state: &mut H) {

src/liballoc/boxed.rs

-8
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,6 @@ impl<T: ?Sized + Ord> Ord for Box<T> {
220220
#[stable(feature = "rust1", since = "1.0.0")]
221221
impl<T: ?Sized + Eq> Eq for Box<T> {}
222222

223-
#[cfg(stage0)]
224-
impl<S: hash::Hasher, T: ?Sized + Hash<S>> Hash<S> for Box<T> {
225-
#[inline]
226-
fn hash(&self, state: &mut S) {
227-
(**self).hash(state);
228-
}
229-
}
230-
#[cfg(not(stage0))]
231223
#[stable(feature = "rust1", since = "1.0.0")]
232224
impl<T: ?Sized + Hash> Hash for Box<T> {
233225
fn hash<H: hash::Hasher>(&self, state: &mut H) {

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#![feature(unboxed_closures)]
7474
#![feature(unsafe_no_drop_flag)]
7575
#![feature(core)]
76+
#![cfg_attr(test, feature(test, alloc, rustc_private))]
7677
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
7778
feature(libc))]
7879

src/liballoc/rc.rs

-8
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,6 @@ impl<T: Ord> Ord for Rc<T> {
592592
}
593593

594594
// FIXME (#18248) Make `T` `Sized?`
595-
#[cfg(stage0)]
596-
impl<S: Hasher, T: Hash<S>> Hash<S> for Rc<T> {
597-
#[inline]
598-
fn hash(&self, state: &mut S) {
599-
(**self).hash(state);
600-
}
601-
}
602-
#[cfg(not(stage0))]
603595
#[stable(feature = "rust1", since = "1.0.0")]
604596
impl<T: Hash> Hash for Rc<T> {
605597
fn hash<H: Hasher>(&self, state: &mut H) {

src/libcollections/bit.rs

-20
Original file line numberDiff line numberDiff line change
@@ -985,17 +985,6 @@ impl fmt::Debug for BitVec {
985985
}
986986

987987
#[stable(feature = "rust1", since = "1.0.0")]
988-
#[cfg(stage0)]
989-
impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for BitVec {
990-
fn hash(&self, state: &mut S) {
991-
self.nbits.hash(state);
992-
for elem in self.blocks() {
993-
elem.hash(state);
994-
}
995-
}
996-
}
997-
#[stable(feature = "rust1", since = "1.0.0")]
998-
#[cfg(not(stage0))]
999988
impl hash::Hash for BitVec {
1000989
fn hash<H: hash::Hasher>(&self, state: &mut H) {
1001990
self.nbits.hash(state);
@@ -1776,16 +1765,7 @@ impl fmt::Debug for BitSet {
17761765
}
17771766
}
17781767

1779-
#[cfg(stage0)]
1780-
impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for BitSet {
1781-
fn hash(&self, state: &mut S) {
1782-
for pos in self {
1783-
pos.hash(state);
1784-
}
1785-
}
1786-
}
17871768
#[stable(feature = "rust1", since = "1.0.0")]
1788-
#[cfg(not(stage0))]
17891769
impl hash::Hash for BitSet {
17901770
fn hash<H: hash::Hasher>(&self, state: &mut H) {
17911771
for pos in self {

src/libcollections/borrow.rs

-10
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,6 @@ impl<'a, B: ?Sized> fmt::Display for Cow<'a, B> where
282282
}
283283

284284
#[stable(feature = "rust1", since = "1.0.0")]
285-
#[cfg(stage0)]
286-
impl<'a, B: ?Sized, S: Hasher> Hash<S> for Cow<'a, B> where B: Hash<S> + ToOwned
287-
{
288-
#[inline]
289-
fn hash(&self, state: &mut S) {
290-
Hash::hash(&**self, state)
291-
}
292-
}
293-
#[stable(feature = "rust1", since = "1.0.0")]
294-
#[cfg(not(stage0))]
295285
impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned
296286
{
297287
#[inline]

0 commit comments

Comments
 (0)