Skip to content

Commit 0200507

Browse files
committed
---
yaml --- r: 232740 b: refs/heads/try c: 2d0cb31 h: refs/heads/master v: v3
1 parent 52c4c6d commit 0200507

File tree

50 files changed

+532
-789
lines changed

Some content is hidden

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

50 files changed

+532
-789
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: ab21fe59e9dc79dd9949ab663e3d94e41273131c
4+
refs/heads/try: 2d0cb31d3011224c33ec780b8b2ff7bd17b6ab7f
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/mk/main.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
294294
LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
295295
LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
296296
LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
297-
LLVM_LIBDIR_RUSTFLAGS_$(1)=-L "$$(LLVM_LIBDIR_$(1))"
297+
LLVM_LIBDIR_RUSTFLAGS_$(1)=-L native="$$(LLVM_LIBDIR_$(1))"
298298
LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
299299
ifeq ($$(findstring freebsd,$(1)),freebsd)
300300
# On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),

branches/try/src/doc/trpl/crates-and-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ $ ls target/debug
115115
build deps examples libphrases-a7448e02a0468eaa.rlib native
116116
```
117117

118-
`libphrases-hash.rlib` is the compiled crate. Before we see how to use this
118+
`libphrase-hash.rlib` is the compiled crate. Before we see how to use this
119119
crate from another crate, let’s break it up into multiple files.
120120

121121
# Multiple file crates

branches/try/src/liballoc/arc.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ use boxed::Box;
7373

7474
use core::sync::atomic;
7575
use core::sync::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst};
76-
use core::borrow;
7776
use core::fmt;
7877
use core::cmp::Ordering;
7978
use core::mem::{align_of_val, size_of_val};
@@ -1110,7 +1109,3 @@ mod tests {
11101109
assert!(y.upgrade().is_none());
11111110
}
11121111
}
1113-
1114-
impl<T: ?Sized> borrow::Borrow<T> for Arc<T> {
1115-
fn borrow(&self) -> &T { &**self }
1116-
}

branches/try/src/liballoc/boxed.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ use heap;
5757
use raw_vec::RawVec;
5858

5959
use core::any::Any;
60-
use core::borrow;
6160
use core::cmp::Ordering;
6261
use core::fmt;
6362
use core::hash::{self, Hash};
@@ -563,10 +562,3 @@ impl<T: Clone> Clone for Box<[T]> {
563562
}
564563
}
565564

566-
impl<T: ?Sized> borrow::Borrow<T> for Box<T> {
567-
fn borrow(&self) -> &T { &**self }
568-
}
569-
570-
impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> {
571-
fn borrow_mut(&mut self) -> &mut T { &mut **self }
572-
}

branches/try/src/liballoc/rc.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ use boxed::Box;
158158
#[cfg(test)]
159159
use std::boxed::Box;
160160

161-
use core::borrow;
162161
use core::cell::Cell;
163162
use core::cmp::Ordering;
164163
use core::fmt;
@@ -1092,7 +1091,3 @@ mod tests {
10921091
assert_eq!(foo, foo.clone());
10931092
}
10941093
}
1095-
1096-
impl<T: ?Sized> borrow::Borrow<T> for Rc<T> {
1097-
fn borrow(&self) -> &T { &**self }
1098-
}

branches/try/src/libcollections/borrow.rs

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,119 @@ use core::ops::Deref;
2121
use core::option::Option;
2222

2323
use fmt;
24+
use alloc::{boxed, rc, arc};
2425

2526
use self::Cow::*;
2627

27-
pub use core::borrow::{Borrow, BorrowMut};
28+
/// A trait for borrowing data.
29+
///
30+
/// In general, there may be several ways to "borrow" a piece of data. The
31+
/// typical ways of borrowing a type `T` are `&T` (a shared borrow) and `&mut T`
32+
/// (a mutable borrow). But types like `Vec<T>` provide additional kinds of
33+
/// borrows: the borrowed slices `&[T]` and `&mut [T]`.
34+
///
35+
/// When writing generic code, it is often desirable to abstract over all ways
36+
/// of borrowing data from a given type. That is the role of the `Borrow`
37+
/// trait: if `T: Borrow<U>`, then `&U` can be borrowed from `&T`. A given
38+
/// type can be borrowed as multiple different types. In particular, `Vec<T>:
39+
/// Borrow<Vec<T>>` and `Vec<T>: Borrow<[T]>`.
40+
///
41+
/// If you are implementing `Borrow` and both `Self` and `Borrowed` implement
42+
/// `Hash`, `Eq`, and/or `Ord`, they must produce the same result.
43+
///
44+
/// `Borrow` is very similar to, but different than, `AsRef`. See
45+
/// [the book][book] for more.
46+
///
47+
/// [book]: ../../book/borrow-and-asref.html
48+
#[stable(feature = "rust1", since = "1.0.0")]
49+
pub trait Borrow<Borrowed: ?Sized> {
50+
/// Immutably borrows from an owned value.
51+
///
52+
/// # Examples
53+
///
54+
/// ```
55+
/// use std::borrow::Borrow;
56+
///
57+
/// fn check<T: Borrow<str>>(s: T) {
58+
/// assert_eq!("Hello", s.borrow());
59+
/// }
60+
///
61+
/// let s = "Hello".to_string();
62+
///
63+
/// check(s);
64+
///
65+
/// let s = "Hello";
66+
///
67+
/// check(s);
68+
/// ```
69+
#[stable(feature = "rust1", since = "1.0.0")]
70+
fn borrow(&self) -> &Borrowed;
71+
}
72+
73+
/// A trait for mutably borrowing data.
74+
///
75+
/// Similar to `Borrow`, but for mutable borrows.
76+
#[stable(feature = "rust1", since = "1.0.0")]
77+
pub trait BorrowMut<Borrowed: ?Sized> : Borrow<Borrowed> {
78+
/// Mutably borrows from an owned value.
79+
///
80+
/// # Examples
81+
///
82+
/// ```
83+
/// use std::borrow::BorrowMut;
84+
///
85+
/// fn check<T: BorrowMut<[i32]>>(mut v: T) {
86+
/// assert_eq!(&mut [1, 2, 3], v.borrow_mut());
87+
/// }
88+
///
89+
/// let v = vec![1, 2, 3];
90+
///
91+
/// check(v);
92+
/// ```
93+
#[stable(feature = "rust1", since = "1.0.0")]
94+
fn borrow_mut(&mut self) -> &mut Borrowed;
95+
}
96+
97+
#[stable(feature = "rust1", since = "1.0.0")]
98+
impl<T: ?Sized> Borrow<T> for T {
99+
fn borrow(&self) -> &T { self }
100+
}
101+
102+
#[stable(feature = "rust1", since = "1.0.0")]
103+
impl<T: ?Sized> BorrowMut<T> for T {
104+
fn borrow_mut(&mut self) -> &mut T { self }
105+
}
106+
107+
#[stable(feature = "rust1", since = "1.0.0")]
108+
impl<'a, T: ?Sized> Borrow<T> for &'a T {
109+
fn borrow(&self) -> &T { &**self }
110+
}
111+
112+
#[stable(feature = "rust1", since = "1.0.0")]
113+
impl<'a, T: ?Sized> Borrow<T> for &'a mut T {
114+
fn borrow(&self) -> &T { &**self }
115+
}
116+
117+
#[stable(feature = "rust1", since = "1.0.0")]
118+
impl<'a, T: ?Sized> BorrowMut<T> for &'a mut T {
119+
fn borrow_mut(&mut self) -> &mut T { &mut **self }
120+
}
121+
122+
impl<T: ?Sized> Borrow<T> for boxed::Box<T> {
123+
fn borrow(&self) -> &T { &**self }
124+
}
125+
126+
impl<T: ?Sized> BorrowMut<T> for boxed::Box<T> {
127+
fn borrow_mut(&mut self) -> &mut T { &mut **self }
128+
}
129+
130+
impl<T: ?Sized> Borrow<T> for rc::Rc<T> {
131+
fn borrow(&self) -> &T { &**self }
132+
}
133+
134+
impl<T: ?Sized> Borrow<T> for arc::Arc<T> {
135+
fn borrow(&self) -> &T { &**self }
136+
}
28137

29138
#[stable(feature = "rust1", since = "1.0.0")]
30139
impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B> where B: ToOwned, <B as ToOwned>::Owned: 'a {

branches/try/src/libcollections/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#![feature(unicode)]
5757
#![feature(unique)]
5858
#![feature(unsafe_no_drop_flag, filling_drop)]
59-
#![feature(decode_utf16)]
6059
#![feature(utf8_error)]
6160
#![cfg_attr(test, feature(rand, test))]
6261

branches/try/src/libcollections/string.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use core::ops::{self, Deref, Add, Index};
2020
use core::ptr;
2121
use core::slice;
2222
use core::str::pattern::Pattern;
23-
use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
2423
use rustc_unicode::str as unicode_str;
24+
use rustc_unicode::str::Utf16Item;
2525

2626
use borrow::{Cow, IntoCow};
2727
use range::RangeArgument;
@@ -267,7 +267,14 @@ impl String {
267267
/// ```
268268
#[stable(feature = "rust1", since = "1.0.0")]
269269
pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {
270-
decode_utf16(v.iter().cloned()).collect::<Result<_, _>>().map_err(|_| FromUtf16Error(()))
270+
let mut s = String::with_capacity(v.len());
271+
for c in unicode_str::utf16_items(v) {
272+
match c {
273+
Utf16Item::ScalarValue(c) => s.push(c),
274+
Utf16Item::LoneSurrogate(_) => return Err(FromUtf16Error(())),
275+
}
276+
}
277+
Ok(s)
271278
}
272279

273280
/// Decode a UTF-16 encoded vector `v` into a string, replacing
@@ -287,7 +294,7 @@ impl String {
287294
#[inline]
288295
#[stable(feature = "rust1", since = "1.0.0")]
289296
pub fn from_utf16_lossy(v: &[u16]) -> String {
290-
decode_utf16(v.iter().cloned()).map(|r| r.unwrap_or(REPLACEMENT_CHARACTER)).collect()
297+
unicode_str::utf16_items(v).map(|c| c.to_char_lossy()).collect()
291298
}
292299

293300
/// Creates a new `String` from a length, capacity, and pointer.

branches/try/src/libcore/any.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
//!
1414
//! `Any` itself can be used to get a `TypeId`, and has more features when used
1515
//! as a trait object. As `&Any` (a borrowed trait object), it has the `is` and
16-
//! `downcast_ref` methods, to test if the contained value is of a given type,
17-
//! and to get a reference to the inner value as a type. As `&mut Any`, there
18-
//! is also the `downcast_mut` method, for getting a mutable reference to the
19-
//! inner value. `Box<Any>` adds the `move` method, which will unwrap a
20-
//! `Box<T>` from the object. See the extension traits (`*Ext`) for the full
21-
//! details.
16+
//! `as_ref` methods, to test if the contained value is of a given type, and to
17+
//! get a reference to the inner value as a type. As `&mut Any`, there is also
18+
//! the `as_mut` method, for getting a mutable reference to the inner value.
19+
//! `Box<Any>` adds the `move` method, which will unwrap a `Box<T>` from the
20+
//! object. See the extension traits (`*Ext`) for the full details.
2221
//!
2322
//! Note that &Any is limited to testing whether a value is of a specified
2423
//! concrete type, and cannot be used to test whether a type implements a trait.

branches/try/src/libcore/borrow.rs

Lines changed: 0 additions & 109 deletions
This file was deleted.

branches/try/src/libcore/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ pub mod cmp;
139139
pub mod clone;
140140
pub mod default;
141141
pub mod convert;
142-
pub mod borrow;
143142

144143
/* Core types and methods on primitives */
145144

branches/try/src/libcoretest/char.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,3 @@ fn test_len_utf16() {
207207
assert!('\u{a66e}'.len_utf16() == 1);
208208
assert!('\u{1f4a9}'.len_utf16() == 2);
209209
}
210-
211-
#[test]
212-
fn test_decode_utf16() {
213-
fn check(s: &[u16], expected: &[Result<char, u16>]) {
214-
assert_eq!(::std::char::decode_utf16(s.iter().cloned()).collect::<Vec<_>>(), expected);
215-
}
216-
check(&[0xD800, 0x41, 0x42], &[Err(0xD800), Ok('A'), Ok('B')]);
217-
check(&[0xD800, 0], &[Err(0xD800), Ok('\0')]);
218-
}

branches/try/src/libcoretest/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![feature(float_from_str_radix)]
2020
#![feature(flt2dec)]
2121
#![feature(dec2flt)]
22-
#![feature(decode_utf16)]
2322
#![feature(fmt_radix)]
2423
#![feature(iter_arith)]
2524
#![feature(iter_arith)]

0 commit comments

Comments
 (0)