Skip to content

Commit 9f61225

Browse files
committed
---
yaml --- r: 236157 b: refs/heads/stable c: a7b8f5b h: refs/heads/master i: 236155: 6d9d8c5 v: v3
1 parent a456943 commit 9f61225

19 files changed

+159
-40
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 4d218d924fb140b43e2a9e1c6cf29283c94a5f15
32+
refs/heads/stable: a7b8f5bc47966bc995004f5905f831be4b68d026
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/doc/tarpl/races.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ race condition can't violate memory safety in a Rust program on
2525
its own. Only in conjunction with some other unsafe code can a race condition
2626
actually violate memory safety. For instance:
2727

28-
```rust,norun
28+
```rust,no_run
2929
use std::thread;
3030
use std::sync::atomic::{AtomicUsize, Ordering};
3131
use std::sync::Arc;
@@ -56,7 +56,7 @@ thread::spawn(move || {
5656
println!("{}", data[idx.load(Ordering::SeqCst)]);
5757
```
5858

59-
```rust,norun
59+
```rust,no_run
6060
use std::thread;
6161
use std::sync::atomic::{AtomicUsize, Ordering};
6262
use std::sync::Arc;

branches/stable/src/libcore/hash/mod.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ pub trait Hash {
9191
fn hash<H: Hasher>(&self, state: &mut H);
9292

9393
/// Feeds a slice of this type into the state provided.
94-
#[unstable(feature = "hash_slice",
95-
reason = "module was recently redesigned")]
94+
#[stable(feature = "hash_slice", since = "1.3.0")]
9695
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized {
9796
for piece in data {
9897
piece.hash(state);
@@ -113,29 +112,29 @@ pub trait Hasher {
113112

114113
/// Write a single `u8` into this hasher
115114
#[inline]
116-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
115+
#[stable(feature = "hasher_write", since = "1.3.0")]
117116
fn write_u8(&mut self, i: u8) { self.write(&[i]) }
118117
/// Write a single `u16` into this hasher.
119118
#[inline]
120-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
119+
#[stable(feature = "hasher_write", since = "1.3.0")]
121120
fn write_u16(&mut self, i: u16) {
122121
self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) })
123122
}
124123
/// Write a single `u32` into this hasher.
125124
#[inline]
126-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
125+
#[stable(feature = "hasher_write", since = "1.3.0")]
127126
fn write_u32(&mut self, i: u32) {
128127
self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) })
129128
}
130129
/// Write a single `u64` into this hasher.
131130
#[inline]
132-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
131+
#[stable(feature = "hasher_write", since = "1.3.0")]
133132
fn write_u64(&mut self, i: u64) {
134133
self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) })
135134
}
136135
/// Write a single `usize` into this hasher.
137136
#[inline]
138-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
137+
#[stable(feature = "hasher_write", since = "1.3.0")]
139138
fn write_usize(&mut self, i: usize) {
140139
if cfg!(target_pointer_width = "32") {
141140
self.write_u32(i as u32)
@@ -146,23 +145,23 @@ pub trait Hasher {
146145

147146
/// Write a single `i8` into this hasher.
148147
#[inline]
149-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
148+
#[stable(feature = "hasher_write", since = "1.3.0")]
150149
fn write_i8(&mut self, i: i8) { self.write_u8(i as u8) }
151150
/// Write a single `i16` into this hasher.
152151
#[inline]
153-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
152+
#[stable(feature = "hasher_write", since = "1.3.0")]
154153
fn write_i16(&mut self, i: i16) { self.write_u16(i as u16) }
155154
/// Write a single `i32` into this hasher.
156155
#[inline]
157-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
156+
#[stable(feature = "hasher_write", since = "1.3.0")]
158157
fn write_i32(&mut self, i: i32) { self.write_u32(i as u32) }
159158
/// Write a single `i64` into this hasher.
160159
#[inline]
161-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
160+
#[stable(feature = "hasher_write", since = "1.3.0")]
162161
fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) }
163162
/// Write a single `isize` into this hasher.
164163
#[inline]
165-
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
164+
#[stable(feature = "hasher_write", since = "1.3.0")]
166165
fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) }
167166
}
168167

branches/stable/src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#![allow(raw_pointer_derive)]
6666
#![deny(missing_docs)]
6767

68+
#![feature(associated_type_defaults)]
6869
#![feature(intrinsics)]
6970
#![feature(lang_items)]
7071
#![feature(on_unimplemented)]

branches/stable/src/librustdoc/markdown.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ use test::{TestOptions, Collector};
2929
/// Separate any lines at the start of the file that begin with `%`.
3030
fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
3131
let mut metadata = Vec::new();
32+
let mut count = 0;
3233
for line in s.lines() {
3334
if line.starts_with("%") {
3435
// remove %<whitespace>
35-
metadata.push(line[1..].trim_left())
36+
metadata.push(line[1..].trim_left());
37+
count += line.len() + 1;
3638
} else {
37-
let line_start_byte = s.find(line).unwrap();
38-
return (metadata, &s[line_start_byte..]);
39+
return (metadata, &s[count..]);
3940
}
4041
}
4142
// if we're here, then all lines were metadata % lines.

branches/stable/src/libstd/error.rs

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Error for string::FromUtf16Error {
168168
// copied from any.rs
169169
impl Error + 'static {
170170
/// Returns true if the boxed type is the same as `T`
171-
#[unstable(feature = "error_downcast", reason = "recently added")]
171+
#[stable(feature = "error_downcast", since = "1.3.0")]
172172
#[inline]
173173
pub fn is<T: Error + 'static>(&self) -> bool {
174174
// Get TypeId of the type this function is instantiated with
@@ -183,7 +183,7 @@ impl Error + 'static {
183183

184184
/// Returns some reference to the boxed value if it is of type `T`, or
185185
/// `None` if it isn't.
186-
#[unstable(feature = "error_downcast", reason = "recently added")]
186+
#[stable(feature = "error_downcast", since = "1.3.0")]
187187
#[inline]
188188
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
189189
if self.is::<T>() {
@@ -201,7 +201,7 @@ impl Error + 'static {
201201

202202
/// Returns some mutable reference to the boxed value if it is of type `T`, or
203203
/// `None` if it isn't.
204-
#[unstable(feature = "error_downcast", reason = "recently added")]
204+
#[stable(feature = "error_downcast", since = "1.3.0")]
205205
#[inline]
206206
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
207207
if self.is::<T>() {
@@ -220,21 +220,44 @@ impl Error + 'static {
220220

221221
impl Error + 'static + Send {
222222
/// Forwards to the method defined on the type `Any`.
223-
#[unstable(feature = "error_downcast", reason = "recently added")]
223+
#[stable(feature = "error_downcast", since = "1.3.0")]
224224
#[inline]
225225
pub fn is<T: Error + 'static>(&self) -> bool {
226226
<Error + 'static>::is::<T>(self)
227227
}
228228

229229
/// Forwards to the method defined on the type `Any`.
230-
#[unstable(feature = "error_downcast", reason = "recently added")]
230+
#[stable(feature = "error_downcast", since = "1.3.0")]
231231
#[inline]
232232
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
233233
<Error + 'static>::downcast_ref::<T>(self)
234234
}
235235

236236
/// Forwards to the method defined on the type `Any`.
237-
#[unstable(feature = "error_downcast", reason = "recently added")]
237+
#[stable(feature = "error_downcast", since = "1.3.0")]
238+
#[inline]
239+
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
240+
<Error + 'static>::downcast_mut::<T>(self)
241+
}
242+
}
243+
244+
impl Error + 'static + Send + Sync {
245+
/// Forwards to the method defined on the type `Any`.
246+
#[stable(feature = "error_downcast", since = "1.3.0")]
247+
#[inline]
248+
pub fn is<T: Error + 'static>(&self) -> bool {
249+
<Error + 'static>::is::<T>(self)
250+
}
251+
252+
/// Forwards to the method defined on the type `Any`.
253+
#[stable(feature = "error_downcast", since = "1.3.0")]
254+
#[inline]
255+
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
256+
<Error + 'static>::downcast_ref::<T>(self)
257+
}
258+
259+
/// Forwards to the method defined on the type `Any`.
260+
#[stable(feature = "error_downcast", since = "1.3.0")]
238261
#[inline]
239262
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
240263
<Error + 'static>::downcast_mut::<T>(self)
@@ -243,7 +266,7 @@ impl Error + 'static + Send {
243266

244267
impl Error {
245268
#[inline]
246-
#[unstable(feature = "error_downcast", reason = "recently added")]
269+
#[stable(feature = "error_downcast", since = "1.3.0")]
247270
/// Attempt to downcast the box to a concrete type.
248271
pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Error>> {
249272
if self.is::<T>() {
@@ -264,13 +287,74 @@ impl Error {
264287

265288
impl Error + Send {
266289
#[inline]
267-
#[unstable(feature = "error_downcast", reason = "recently added")]
290+
#[stable(feature = "error_downcast", since = "1.3.0")]
268291
/// Attempt to downcast the box to a concrete type.
269-
pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Error + Send>> {
292+
pub fn downcast<T: Error + 'static>(self: Box<Self>)
293+
-> Result<Box<T>, Box<Error + Send>> {
270294
let err: Box<Error> = self;
271295
<Error>::downcast(err).map_err(|s| unsafe {
272296
// reapply the Send marker
273297
transmute::<Box<Error>, Box<Error + Send>>(s)
274298
})
275299
}
276300
}
301+
302+
impl Error + Send + Sync {
303+
#[inline]
304+
#[stable(feature = "error_downcast", since = "1.3.0")]
305+
/// Attempt to downcast the box to a concrete type.
306+
pub fn downcast<T: Error + 'static>(self: Box<Self>)
307+
-> Result<Box<T>, Box<Self>> {
308+
let err: Box<Error> = self;
309+
<Error>::downcast(err).map_err(|s| unsafe {
310+
// reapply the Send+Sync marker
311+
transmute::<Box<Error>, Box<Error + Send + Sync>>(s)
312+
})
313+
}
314+
}
315+
316+
#[cfg(test)]
317+
mod tests {
318+
use prelude::v1::*;
319+
use super::Error;
320+
use fmt;
321+
322+
#[derive(Debug, PartialEq)]
323+
struct A;
324+
#[derive(Debug, PartialEq)]
325+
struct B;
326+
327+
impl fmt::Display for A {
328+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
329+
write!(f, "A")
330+
}
331+
}
332+
impl fmt::Display for B {
333+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
334+
write!(f, "B")
335+
}
336+
}
337+
338+
impl Error for A {
339+
fn description(&self) -> &str { "A-desc" }
340+
}
341+
impl Error for B {
342+
fn description(&self) -> &str { "A-desc" }
343+
}
344+
345+
#[test]
346+
fn downcasting() {
347+
let mut a = A;
348+
let mut a = &mut a as &mut (Error + 'static);
349+
assert_eq!(a.downcast_ref::<A>(), Some(&A));
350+
assert_eq!(a.downcast_ref::<B>(), None);
351+
assert_eq!(a.downcast_mut::<A>(), Some(&mut A));
352+
assert_eq!(a.downcast_mut::<B>(), None);
353+
354+
let a: Box<Error> = Box::new(A);
355+
match a.downcast::<B>() {
356+
Ok(..) => panic!("expected error"),
357+
Err(e) => assert_eq!(*e.downcast::<A>().unwrap(), A),
358+
}
359+
}
360+
}

branches/stable/src/libstd/io/error.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ impl Error {
219219
///
220220
/// If this `Error` was constructed via `new` then this function will
221221
/// return `Some`, otherwise it will return `None`.
222-
#[unstable(feature = "io_error_inner",
223-
reason = "recently added and requires UFCS to downcast")]
222+
#[stable(feature = "io_error_inner", since = "1.3.0")]
224223
pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> {
225224
match self.repr {
226225
Repr::Os(..) => None,
@@ -233,8 +232,7 @@ impl Error {
233232
///
234233
/// If this `Error` was constructed via `new` then this function will
235234
/// return `Some`, otherwise it will return `None`.
236-
#[unstable(feature = "io_error_inner",
237-
reason = "recently added and requires UFCS to downcast")]
235+
#[stable(feature = "io_error_inner", since = "1.3.0")]
238236
pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> {
239237
match self.repr {
240238
Repr::Os(..) => None,
@@ -246,8 +244,7 @@ impl Error {
246244
///
247245
/// If this `Error` was constructed via `new` then this function will
248246
/// return `Some`, otherwise it will return `None`.
249-
#[unstable(feature = "io_error_inner",
250-
reason = "recently added and requires UFCS to downcast")]
247+
#[stable(feature = "io_error_inner", since = "1.3.0")]
251248
pub fn into_inner(self) -> Option<Box<error::Error+Send+Sync>> {
252249
match self.repr {
253250
Repr::Os(..) => None,
@@ -349,10 +346,10 @@ mod test {
349346
// we have to call all of these UFCS style right now since method
350347
// resolution won't implicitly drop the Send+Sync bounds
351348
let mut err = Error::new(ErrorKind::Other, TestError);
352-
assert!(error::Error::is::<TestError>(err.get_ref().unwrap()));
349+
assert!(err.get_ref().unwrap().is::<TestError>());
353350
assert_eq!("asdf", err.get_ref().unwrap().description());
354-
assert!(error::Error::is::<TestError>(err.get_mut().unwrap()));
351+
assert!(err.get_mut().unwrap().is::<TestError>());
355352
let extracted = err.into_inner().unwrap();
356-
error::Error::downcast::<TestError>(extracted).unwrap();
353+
extracted.downcast::<TestError>().unwrap();
357354
}
358355
}

branches/stable/src/libstd/io/stdio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl Stdin {
255255
// in which case it will wait for the Enter key to be pressed before
256256
/// continuing
257257
#[stable(feature = "rust1", since = "1.0.0")]
258-
pub fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
258+
pub fn read_line(&self, buf: &mut String) -> io::Result<usize> {
259259
self.lock().read_line(buf)
260260
}
261261
}

branches/stable/src/libstd/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl Child {
505505
}
506506

507507
/// Returns the OS-assigned process identifier associated with this child.
508-
#[unstable(feature = "process_id", reason = "api recently added")]
508+
#[stable(feature = "process_id", since = "1.3.0")]
509509
pub fn id(&self) -> u32 {
510510
self.handle.id()
511511
}

branches/stable/src/libsyntax/feature_gate.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
163163

164164
// Allows the definition recursive static items.
165165
("static_recursion", "1.3.0", Active),
166-
// Allows default type parameters to influence type inference.
167-
("default_type_parameter_fallback", "1.3.0", Active)
166+
167+
// Allows default type parameters to influence type inference.
168+
("default_type_parameter_fallback", "1.3.0", Active),
169+
170+
// Allows associated type defaults
171+
("associated_type_defaults", "1.2.0", Active),
168172
];
169173
// (changing above list without updating src/doc/reference.md makes @cmr sad)
170174

@@ -762,6 +766,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
762766
self.gate_feature("const_fn", ti.span, "const fn is unstable");
763767
}
764768
}
769+
ast::TypeTraitItem(_, Some(_)) => {
770+
self.gate_feature("associated_type_defaults", ti.span,
771+
"associated type defaults are unstable");
772+
}
765773
_ => {}
766774
}
767775
visit::walk_trait_item(self, ti);

branches/stable/src/test/auxiliary/xcrate_associated_type_defaults.rs

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

11+
#![feature(associated_type_defaults)]
12+
1113
pub trait Foo {
1214
type Input = usize;
1315
fn bar(&self, _: Self::Input) {}

branches/stable/src/test/compile-fail/associated-types-overridden-default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![feature(associated_consts)]
12+
#![feature(associated_type_defaults)]
1213

1314
pub trait Tr {
1415
type Assoc = u8;

0 commit comments

Comments
 (0)