Skip to content

Commit 72f48dc

Browse files
committed
---
yaml --- r: 195478 b: refs/heads/master c: 80bf31d h: refs/heads/master v: v3
1 parent b3224ee commit 72f48dc

Some content is hidden

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

85 files changed

+364
-804
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: e10ee2c8572421c056ea68e6656fee936e0330d8
2+
refs/heads/master: 80bf31dd514055177b22c3dc66836d39eb5b1648
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b3317d68910900f135f9f38e43a7a699bc736b4a
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf

trunk/src/compiletest/compiletest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#![feature(std_misc)]
1919
#![feature(test)]
2020
#![feature(path_ext)]
21+
#![feature(convert)]
2122
#![feature(str_char)]
2223

2324
#![deny(warnings)]

trunk/src/liballoc/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ use heap::deallocate;
110110
/// let child_numbers = shared_numbers.clone();
111111
///
112112
/// thread::spawn(move || {
113-
/// let local_numbers = &child_numbers[..];
113+
/// let local_numbers = child_numbers.as_slice();
114114
///
115115
/// // Work with the local numbers
116116
/// });

trunk/src/liballoc/boxed.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use core::prelude::*;
5151
use core::any::Any;
5252
use core::cmp::Ordering;
5353
use core::default::Default;
54-
use core::error::Error;
54+
use core::error::{Error, FromError};
5555
use core::fmt;
5656
use core::hash::{self, Hash};
5757
use core::mem;
@@ -233,10 +233,24 @@ impl<T: ?Sized + Hash> Hash for Box<T> {
233233
}
234234
}
235235

236-
impl Box<Any> {
237-
#[inline]
236+
/// Extension methods for an owning `Any` trait object.
237+
#[unstable(feature = "alloc",
238+
reason = "this trait will likely disappear once compiler bugs blocking \
239+
a direct impl on `Box<Any>` have been fixed ")]
240+
// FIXME(#18737): this should be a direct impl on `Box<Any>`. If you're
241+
// removing this please make sure that you can downcase on
242+
// `Box<Any + Send>` as well as `Box<Any>`
243+
pub trait BoxAny {
244+
/// Returns the boxed value if it is of type `T`, or
245+
/// `Err(Self)` if it isn't.
238246
#[stable(feature = "rust1", since = "1.0.0")]
239-
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
247+
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>>;
248+
}
249+
250+
#[stable(feature = "rust1", since = "1.0.0")]
251+
impl BoxAny for Box<Any> {
252+
#[inline]
253+
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
240254
if self.is::<T>() {
241255
unsafe {
242256
// Get the raw representation of the trait object
@@ -253,10 +267,10 @@ impl Box<Any> {
253267
}
254268
}
255269

256-
impl Box<Any+Send> {
270+
#[stable(feature = "rust1", since = "1.0.0")]
271+
impl BoxAny for Box<Any+Send> {
257272
#[inline]
258-
#[stable(feature = "rust1", since = "1.0.0")]
259-
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
273+
fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
260274
<Box<Any>>::downcast(self)
261275
}
262276
}
@@ -308,8 +322,8 @@ impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
308322
impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
309323

310324
#[stable(feature = "rust1", since = "1.0.0")]
311-
impl<'a, E: Error + 'a> From<E> for Box<Error + 'a> {
312-
fn from(err: E) -> Box<Error + 'a> {
325+
impl<'a, E: Error + 'a> FromError<E> for Box<Error + 'a> {
326+
fn from_error(err: E) -> Box<Error + 'a> {
313327
Box::new(err)
314328
}
315329
}

trunk/src/liballoc/boxed_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use core::clone::Clone;
1717

1818
use std::boxed;
1919
use std::boxed::Box;
20+
use std::boxed::BoxAny;
2021

2122
#[test]
2223
fn test_owned_clone() {

trunk/src/libcollections/borrow.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,6 @@ use self::Cow::*;
4040
#[stable(feature = "rust1", since = "1.0.0")]
4141
pub trait Borrow<Borrowed: ?Sized> {
4242
/// Immutably borrow from an owned value.
43-
///
44-
/// # Examples
45-
///
46-
/// ```
47-
/// use std::borrow::Borrow;
48-
///
49-
/// fn check<T: Borrow<str>>(s: T) {
50-
/// assert_eq!("Hello", s.borrow());
51-
/// }
52-
///
53-
/// let s = "Hello".to_string();
54-
///
55-
/// check(s);
56-
///
57-
/// let s = "Hello";
58-
///
59-
/// check(s);
60-
/// ```
6143
#[stable(feature = "rust1", since = "1.0.0")]
6244
fn borrow(&self) -> &Borrowed;
6345
}
@@ -68,20 +50,6 @@ pub trait Borrow<Borrowed: ?Sized> {
6850
#[stable(feature = "rust1", since = "1.0.0")]
6951
pub trait BorrowMut<Borrowed: ?Sized> : Borrow<Borrowed> {
7052
/// Mutably borrow from an owned value.
71-
///
72-
/// # Examples
73-
///
74-
/// ```
75-
/// use std::borrow::BorrowMut;
76-
///
77-
/// fn check<T: BorrowMut<[i32]>>(mut v: T) {
78-
/// assert_eq!(&mut [1, 2, 3], v.borrow_mut());
79-
/// }
80-
///
81-
/// let v = vec![1, 2, 3];
82-
///
83-
/// check(v);
84-
/// ```
8553
#[stable(feature = "rust1", since = "1.0.0")]
8654
fn borrow_mut(&mut self) -> &mut Borrowed;
8755
}
@@ -203,18 +171,6 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
203171
/// Acquire a mutable reference to the owned form of the data.
204172
///
205173
/// Copies the data if it is not already owned.
206-
///
207-
/// # Examples
208-
///
209-
/// ```
210-
/// use std::borrow::Cow;
211-
///
212-
/// let mut cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
213-
///
214-
/// let hello = cow.to_mut();
215-
///
216-
/// assert_eq!(&[1, 2, 3], hello);
217-
/// ```
218174
#[stable(feature = "rust1", since = "1.0.0")]
219175
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {
220176
match *self {
@@ -229,18 +185,6 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
229185
/// Extract the owned data.
230186
///
231187
/// Copies the data if it is not already owned.
232-
///
233-
/// # Examples
234-
///
235-
/// ```
236-
/// use std::borrow::Cow;
237-
///
238-
/// let cow: Cow<[_]> = Cow::Owned(vec![1, 2, 3]);
239-
///
240-
/// let hello = cow.into_owned();
241-
///
242-
/// assert_eq!(vec![1, 2, 3], hello);
243-
/// ```
244188
#[stable(feature = "rust1", since = "1.0.0")]
245189
pub fn into_owned(self) -> <B as ToOwned>::Owned {
246190
match self {

trunk/src/libcollections/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#![feature(unsafe_no_drop_flag, filling_drop)]
3939
#![feature(step_by)]
4040
#![feature(str_char)]
41+
#![feature(convert)]
4142
#![feature(slice_patterns)]
4243
#![feature(debug_builders)]
4344
#![cfg_attr(test, feature(rand, rustc_private, test, hash, collections))]

trunk/src/libcollections/slice.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ use core::iter::MultiplicativeIterator;
8989
use core::marker::Sized;
9090
use core::mem::size_of;
9191
use core::mem;
92+
#[cfg(stage0)]
93+
use core::num::wrapping::WrappingOps;
9294
use core::ops::FnMut;
9395
use core::option::Option::{self, Some, None};
9496
use core::ptr;
@@ -555,6 +557,7 @@ impl<T> [T] {
555557
/// ```rust
556558
/// # #![feature(core)]
557559
/// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
560+
/// let s = s.as_slice();
558561
///
559562
/// let seek = 13;
560563
/// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Ok(9));
@@ -921,6 +924,7 @@ impl<T> [T] {
921924
/// ```rust
922925
/// # #![feature(core)]
923926
/// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
927+
/// let s = s.as_slice();
924928
///
925929
/// assert_eq!(s.binary_search(&13), Ok(9));
926930
/// assert_eq!(s.binary_search(&4), Err(7));

trunk/src/libcollections/str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,12 +1470,12 @@ impl str {
14701470
/// let gr1 = "a\u{310}e\u{301}o\u{308}\u{332}".graphemes(true).collect::<Vec<&str>>();
14711471
/// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"];
14721472
///
1473-
/// assert_eq!(&gr1[..], b);
1473+
/// assert_eq!(gr1.as_slice(), b);
14741474
///
14751475
/// let gr2 = "a\r\nb🇷🇺🇸🇹".graphemes(true).collect::<Vec<&str>>();
14761476
/// let b: &[_] = &["a", "\r\n", "b", "🇷🇺🇸🇹"];
14771477
///
1478-
/// assert_eq!(&gr2[..], b);
1478+
/// assert_eq!(gr2.as_slice(), b);
14791479
/// ```
14801480
#[unstable(feature = "unicode",
14811481
reason = "this functionality may only be provided by libunicode")]
@@ -1493,7 +1493,7 @@ impl str {
14931493
/// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(usize, &str)>>();
14941494
/// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
14951495
///
1496-
/// assert_eq!(&gr_inds[..], b);
1496+
/// assert_eq!(gr_inds.as_slice(), b);
14971497
/// ```
14981498
#[unstable(feature = "unicode",
14991499
reason = "this functionality may only be provided by libunicode")]

trunk/src/libcollections/string.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl String {
9393
/// ```
9494
/// # #![feature(collections, core)]
9595
/// let s = String::from_str("hello");
96-
/// assert_eq!(&s[..], "hello");
96+
/// assert_eq!(s.as_slice(), "hello");
9797
/// ```
9898
#[inline]
9999
#[unstable(feature = "collections",
@@ -364,14 +364,6 @@ impl String {
364364
self.vec
365365
}
366366

367-
/// Extract a string slice containing the entire string.
368-
#[inline]
369-
#[unstable(feature = "convert",
370-
reason = "waiting on RFC revision")]
371-
pub fn as_str(&self) -> &str {
372-
self
373-
}
374-
375367
/// Pushes the given string onto this string buffer.
376368
///
377369
/// # Examples
@@ -856,6 +848,7 @@ impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str {
856848
#[allow(deprecated)]
857849
impl Str for String {
858850
#[inline]
851+
#[stable(feature = "rust1", since = "1.0.0")]
859852
fn as_slice(&self) -> &str {
860853
unsafe { mem::transmute(&*self.vec) }
861854
}

trunk/src/libcollections/vec.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,11 @@ impl<T> Vec<T> {
425425
}
426426
}
427427

428-
/// Extract a slice containing the entire vector.
429-
#[inline]
430-
#[unstable(feature = "convert",
431-
reason = "waiting on RFC revision")]
432-
pub fn as_slice(&self) -> &[T] {
433-
self
434-
}
435-
436428
/// Deprecated: use `&mut s[..]` instead.
437429
#[inline]
438-
#[unstable(feature = "convert",
439-
reason = "waiting on RFC revision")]
430+
#[unstable(feature = "collections",
431+
reason = "will be replaced by slice syntax")]
432+
#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")]
440433
pub fn as_mut_slice(&mut self) -> &mut [T] {
441434
&mut self[..]
442435
}
@@ -830,13 +823,13 @@ impl<T> Vec<T> {
830823
/// # #![feature(collections, core)]
831824
/// let v = vec![0, 1, 2];
832825
/// let w = v.map_in_place(|i| i + 3);
833-
/// assert_eq!(&w[..], &[3, 4, 5]);
826+
/// assert_eq!(w.as_slice(), [3, 4, 5].as_slice());
834827
///
835828
/// #[derive(PartialEq, Debug)]
836829
/// struct Newtype(u8);
837830
/// let bytes = vec![0x11, 0x22];
838831
/// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
839-
/// assert_eq!(&newtyped_bytes[..], &[Newtype(0x11), Newtype(0x22)]);
832+
/// assert_eq!(newtyped_bytes.as_slice(), [Newtype(0x11), Newtype(0x22)].as_slice());
840833
/// ```
841834
#[unstable(feature = "collections",
842835
reason = "API may change to provide stronger guarantees")]
@@ -1649,6 +1642,13 @@ impl<T> AsRef<Vec<T>> for Vec<T> {
16491642
}
16501643
}
16511644

1645+
#[stable(feature = "rust1", since = "1.0.0")]
1646+
impl<T> Into<Vec<T>> for Vec<T> {
1647+
fn into(self) -> Vec<T> {
1648+
self
1649+
}
1650+
}
1651+
16521652
#[stable(feature = "rust1", since = "1.0.0")]
16531653
impl<T> AsRef<[T]> for Vec<T> {
16541654
fn as_ref(&self) -> &[T] {

trunk/src/libcollections/vec_deque.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ use core::default::Default;
2525
use core::fmt;
2626
use core::iter::{self, repeat, FromIterator, IntoIterator, RandomAccessIterator};
2727
use core::mem;
28+
#[cfg(stage0)]
29+
use core::num::wrapping::WrappingOps;
2830
use core::ops::{Index, IndexMut};
2931
use core::ptr::{self, Unique};
3032
use core::slice;
@@ -525,8 +527,7 @@ impl<T> VecDeque<T> {
525527
/// buf.push_back(3);
526528
/// buf.push_back(4);
527529
/// let b: &[_] = &[&5, &3, &4];
528-
/// let c: Vec<&i32> = buf.iter().collect();
529-
/// assert_eq!(&c[..], b);
530+
/// assert_eq!(buf.iter().collect::<Vec<&i32>>().as_slice(), b);
530531
/// ```
531532
#[stable(feature = "rust1", since = "1.0.0")]
532533
pub fn iter(&self) -> Iter<T> {

trunk/src/libcollectionstest/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ use std::fmt;
1313
#[test]
1414
fn test_format() {
1515
let s = fmt::format(format_args!("Hello, {}!", "world"));
16-
assert_eq!(&s[..], "Hello, world!");
16+
assert_eq!(s.as_slice(), "Hello, world!");
1717
}

trunk/src/libcollectionstest/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#![feature(unicode)]
2222
#![feature(unsafe_destructor)]
2323
#![feature(into_cow)]
24-
#![feature(convert)]
2524
#![cfg_attr(test, feature(str_char))]
2625

2726
#[macro_use] extern crate log;

trunk/src/libcollectionstest/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn test_from_elem() {
5959
// Test on-heap from_elem.
6060
v = vec![20; 6];
6161
{
62-
let v = &v[..];
62+
let v = v.as_slice();
6363
assert_eq!(v[0], 20);
6464
assert_eq!(v[1], 20);
6565
assert_eq!(v[2], 20);

trunk/src/libcollectionstest/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,9 +1470,9 @@ fn test_split_strator() {
14701470
fn test_str_default() {
14711471
use std::default::Default;
14721472

1473-
fn t<S: Default + AsRef<str>>() {
1473+
fn t<S: Default + Str>() {
14741474
let s: S = Default::default();
1475-
assert_eq!(s.as_ref(), "");
1475+
assert_eq!(s.as_slice(), "");
14761476
}
14771477

14781478
t::<&str>();

trunk/src/libcore/any.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ pub struct TypeId {
202202
impl TypeId {
203203
/// Returns the `TypeId` of the type this generic function has been
204204
/// instantiated with
205-
#[stable(feature = "rust1", since = "1.0.0")]
205+
#[unstable(feature = "core",
206+
reason = "may grow a `Reflect` bound soon via marker traits")]
206207
pub fn of<T: ?Sized + Any>() -> TypeId {
207208
TypeId {
208209
t: unsafe { intrinsics::type_id::<T>() },

0 commit comments

Comments
 (0)