Skip to content

Commit c9ec2d8

Browse files
committed
---
yaml --- r: 189366 b: refs/heads/master c: d65064d h: refs/heads/master v: v3
1 parent b393157 commit c9ec2d8

File tree

16 files changed

+394
-1042
lines changed

16 files changed

+394
-1042
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c7d5354567e596c578b1ff656f52fae80a93b48a
2+
refs/heads/master: d65064da349f1f7182180549628fb0ee650771b7
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 270a677d4d698916f5ad103f0afc3c070b8dbeb4
55
refs/heads/try: 649d35e4d830b27806705dc5352c86ab6d6fd1a1

trunk/src/doc/grammar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ field_expr : expr '.' ident ;
514514
### Array expressions
515515

516516
```antlr
517-
array_expr : '[' "mut" ? array_elems? ']' ;
517+
array_expr : '[' "mut" ? vec_elems? ']' ;
518518
519519
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
520520
```

trunk/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2847,7 +2847,7 @@ automatically dereferenced to make the field access possible.
28472847
### Array expressions
28482848

28492849
```{.ebnf .gram}
2850-
array_expr : '[' "mut" ? array_elems? ']' ;
2850+
array_expr : '[' "mut" ? vec_elems? ']' ;
28512851
28522852
array_elems : [expr [',' expr]*] | [expr ';' expr] ;
28532853
```

trunk/src/doc/trpl/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
* [Standard Input](standard-input.md)
1717
* [Guessing Game](guessing-game.md)
1818
* [II: Intermediate Rust](intermediate.md)
19-
* [More Strings](more-strings.md)
2019
* [Crates and Modules](crates-and-modules.md)
2120
* [Testing](testing.md)
2221
* [Pointers](pointers.md)
2322
* [Ownership](ownership.md)
23+
* [More Strings](more-strings.md)
2424
* [Patterns](patterns.md)
2525
* [Method Syntax](method-syntax.md)
2626
* [Closures](closures.md)

trunk/src/doc/trpl/concurrency.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,15 @@ method which has this signature:
223223
fn lock(&self) -> LockResult<MutexGuard<T>>
224224
```
225225

226-
Because `Send` is not implemented for `MutexGuard<T>`, we can't transfer the
227-
guard across thread boundaries, which gives us our error.
226+
If we [look at the code for MutexGuard](https://github.com/rust-lang/rust/blob/ca4b9674c26c1de07a2042cb68e6a062d7184cef/src/libstd/sync/mutex.rs#L172), we'll see
227+
this:
228+
229+
```ignore
230+
__marker: marker::NoSend,
231+
```
232+
233+
Because our guard is `NoSend`, it's not `Send`. Which means we can't actually
234+
transfer the guard across thread boundaries, which gives us our error.
228235

229236
We can use `Arc<T>` to fix this. Here's the working version:
230237

trunk/src/doc/trpl/more-strings.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,7 @@ This will print:
278278

279279
Many more bytes than graphemes!
280280

281-
# `Deref` coercions
281+
# Other Documentation
282282

283-
References to `String`s will automatically coerce into `&str`s. Like this:
284-
285-
```
286-
fn hello(s: &str) {
287-
println!("Hello, {}!", s);
288-
}
289-
290-
let slice = "Steve";
291-
let string = "Steve".to_string();
292-
293-
hello(slice);
294-
hello(&string);
295-
```
283+
* [the `&str` API documentation](../std/str/index.html)
284+
* [the `String` API documentation](../std/string/index.html)

trunk/src/doc/trpl/plugins.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ that implements Roman numeral integer literals.
6363

6464
```ignore
6565
#![crate_type="dylib"]
66-
#![feature(plugin_registrar, rustc_private)]
66+
#![feature(plugin_registrar)]
6767
6868
extern crate syntax;
6969
extern crate rustc;
@@ -92,13 +92,13 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
9292
}
9393
};
9494
95-
let mut text = &*text;
95+
let mut text = &text;
9696
let mut total = 0;
9797
while !text.is_empty() {
9898
match NUMERALS.iter().find(|&&(rn, _)| text.starts_with(rn)) {
9999
Some(&(rn, val)) => {
100100
total += val;
101-
text = &text[rn.len()..];
101+
text = text.slice_from(rn.len());
102102
}
103103
None => {
104104
cx.span_err(sp, "invalid Roman numeral");
@@ -107,7 +107,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
107107
}
108108
}
109109
110-
MacEager::expr(cx.expr_u32(sp, total))
110+
MacEager::expr(cx.expr_usize(sp, total))
111111
}
112112
113113
#[plugin_registrar]

trunk/src/doc/trpl/traits.md

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -435,46 +435,3 @@ println!("the inverse of {} is {:?}", 2.0f64, inverse(2.0f64));
435435
println!("the inverse of {} is {:?}", 0.0f32, inverse(0.0f32));
436436
println!("the inverse of {} is {:?}", 0.0f64, inverse(0.0f64));
437437
```
438-
439-
## Default methods
440-
441-
There's one last feature of traits we should cover: default methods. It's
442-
easiest just to show an example:
443-
444-
```rust
445-
trait Foo {
446-
fn bar(&self);
447-
448-
fn baz(&self) { println!("We called baz."); }
449-
}
450-
```
451-
452-
Implementors of the `Foo` trait need to implement `bar()`, but they don't
453-
need to implement `baz()`. They'll get this default behavior. They can
454-
override the default if they so choose:
455-
456-
```rust
457-
# trait Foo {
458-
# fn bar(&self);
459-
# fn baz(&self) { println!("We called baz."); }
460-
# }
461-
struct UseDefault;
462-
463-
impl Foo for UseDefault {
464-
fn bar(&self) { println!("We called bar."); }
465-
}
466-
467-
struct OverrideDefault;
468-
469-
impl Foo for OverrideDefault {
470-
fn bar(&self) { println!("We called bar."); }
471-
472-
fn baz(&self) { println!("Override baz!"); }
473-
}
474-
475-
let default = UseDefault;
476-
default.baz(); // prints "We called bar."
477-
478-
let over = OverrideDefault;
479-
over.baz(); // prints "Override baz!"
480-
```

trunk/src/libcore/intrinsics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,11 @@ extern "rust-intrinsic" {
545545
pub fn u32_mul_with_overflow(x: u32, y: u32) -> (u32, bool);
546546
/// Performs checked `u64` multiplication.
547547
pub fn u64_mul_with_overflow(x: u64, y: u64) -> (u64, bool);
548+
}
548549

550+
// SNAP 880fb89
551+
#[cfg(not(stage0))]
552+
extern "rust-intrinsic" {
549553
/// Returns (a + b) mod 2^N, where N is the width of N in bits.
550554
pub fn overflowing_add<T>(a: T, b: T) -> T;
551555
/// Returns (a - b) mod 2^N, where N is the width of N in bits.

trunk/src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub trait IteratorExt: Iterator + Sized {
611611
///
612612
/// ```
613613
/// let a = [1, 2, 3, 4, 5];
614-
/// assert!(a.iter().fold(0, |acc, &item| acc + item) == 15);
614+
/// assert!(a.iter().fold(0, |a, &b| a + b) == 15);
615615
/// ```
616616
#[inline]
617617
#[stable(feature = "rust1", since = "1.0.0")]

trunk/src/libcore/marker.rs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -351,45 +351,7 @@ pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
351351
/// instance, it will behave *as if* an instance of the type `T` were
352352
/// present for the purpose of various automatic analyses.
353353
///
354-
/// # Examples
355-
///
356-
/// When handling external resources over a foreign function interface, `PhantomData<T>` can
357-
/// prevent mismatches by enforcing types in the method implementations, although the struct
358-
/// doesn't actually contain values of the resource type.
359-
///
360-
/// ```
361-
/// # trait ResType { fn foo(&self); };
362-
/// # struct ParamType;
363-
/// # mod foreign_lib {
364-
/// # pub fn new(_: usize) -> *mut () { 42 as *mut () }
365-
/// # pub fn do_stuff(_: *mut (), _: usize) {}
366-
/// # }
367-
/// # fn convert_params(_: ParamType) -> usize { 42 }
368-
/// use std::marker::PhantomData;
369-
/// use std::mem;
370-
///
371-
/// struct ExternalResource<R> {
372-
/// resource_handle: *mut (),
373-
/// resource_type: PhantomData<R>,
374-
/// }
375-
///
376-
/// impl<R: ResType> ExternalResource<R> {
377-
/// fn new() -> ExternalResource<R> {
378-
/// let size_of_res = mem::size_of::<R>();
379-
/// ExternalResource {
380-
/// resource_handle: foreign_lib::new(size_of_res),
381-
/// resource_type: PhantomData,
382-
/// }
383-
/// }
384-
///
385-
/// fn do_stuff(&self, param: ParamType) {
386-
/// let foreign_params = convert_params(param);
387-
/// foreign_lib::do_stuff(self.resource_handle, foreign_params);
388-
/// }
389-
/// }
390-
/// ```
391-
///
392-
/// Another example: embedding a `PhantomData<T>` will inform the compiler
354+
/// For example, embedding a `PhantomData<T>` will inform the compiler
393355
/// that one or more instances of the type `T` could be dropped when
394356
/// instances of the type itself is dropped, though that may not be
395357
/// apparent from the other structure of the type itself. This is

trunk/src/libcore/num/wrapping.rs

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

1212
use ops::*;
1313

14+
#[cfg(not(stage0))]
1415
use intrinsics::{overflowing_add, overflowing_sub, overflowing_mul};
1516

1617
use intrinsics::{i8_add_with_overflow, u8_add_with_overflow};
@@ -39,6 +40,7 @@ pub trait OverflowingOps {
3940
fn overflowing_mul(self, rhs: Self) -> (Self, bool);
4041
}
4142

43+
#[cfg(not(stage0))]
4244
macro_rules! wrapping_impl {
4345
($($t:ty)*) => ($(
4446
impl WrappingOps for $t {
@@ -64,6 +66,26 @@ macro_rules! wrapping_impl {
6466
)*)
6567
}
6668

69+
#[cfg(stage0)]
70+
macro_rules! wrapping_impl {
71+
($($t:ty)*) => ($(
72+
impl WrappingOps for $t {
73+
#[inline(always)]
74+
fn wrapping_add(self, rhs: $t) -> $t {
75+
self + rhs
76+
}
77+
#[inline(always)]
78+
fn wrapping_sub(self, rhs: $t) -> $t {
79+
self - rhs
80+
}
81+
#[inline(always)]
82+
fn wrapping_mul(self, rhs: $t) -> $t {
83+
self * rhs
84+
}
85+
}
86+
)*)
87+
}
88+
6789
wrapping_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
6890

6991
#[unstable(feature = "core", reason = "may be removed, renamed, or relocated")]

0 commit comments

Comments
 (0)