Skip to content

Commit 27894e9

Browse files
committed
---
yaml --- r: 235351 b: refs/heads/stable c: 69521af h: refs/heads/master i: 235349: 4732276 235347: 46f6d26 235343: b94de65 v: v3
1 parent 165bd18 commit 27894e9

File tree

14 files changed

+56
-195
lines changed

14 files changed

+56
-195
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: 78547d2b951c4499142fa586dfb852ba35d61655
32+
refs/heads/stable: 69521affbb6c177192522606d4f7f09f5c07537c
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/mk/cfg/i686-unknown-freebsd.mk

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

branches/stable/src/libcollections/str.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use core::result::Result;
6161
use core::str as core_str;
6262
use core::str::pattern::Pattern;
6363
use core::str::pattern::{Searcher, ReverseSearcher, DoubleEndedSearcher};
64+
use core::mem;
6465
use rustc_unicode::str::{UnicodeStr, Utf16Encoder};
6566

6667
use vec_deque::VecDeque;
@@ -69,6 +70,7 @@ use string::String;
6970
use rustc_unicode;
7071
use vec::Vec;
7172
use slice::SliceConcatExt;
73+
use boxed::Box;
7274

7375
pub use core::str::{FromStr, Utf8Error};
7476
pub use core::str::{Lines, LinesAny, CharRange};
@@ -82,10 +84,6 @@ pub use core::str::{from_utf8_unchecked, ParseBoolError};
8284
pub use rustc_unicode::str::{SplitWhitespace, Words, Graphemes, GraphemeIndices};
8385
pub use core::str::pattern;
8486

85-
/*
86-
Section: Creating a string
87-
*/
88-
8987
impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
9088
type Output = String;
9189

@@ -134,10 +132,6 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
134132
}
135133
}
136134

137-
/*
138-
Section: Iterators
139-
*/
140-
141135
// Helper functions used for Unicode normalization
142136
fn canonical_sort(comb: &mut [(char, u8)]) {
143137
let len = comb.len();
@@ -382,10 +376,6 @@ impl<'a> Iterator for Utf16Units<'a> {
382376
fn size_hint(&self) -> (usize, Option<usize>) { self.encoder.size_hint() }
383377
}
384378

385-
/*
386-
Section: Misc
387-
*/
388-
389379
// Return the initial codepoint accumulator for the first byte.
390380
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
391381
// for width 3, and 3 bits for width 4
@@ -414,15 +404,6 @@ impl ToOwned for str {
414404
}
415405
}
416406

417-
/*
418-
Section: CowString
419-
*/
420-
421-
/*
422-
Section: Trait implementations
423-
*/
424-
425-
426407
/// Any string that can be represented as a slice.
427408
#[lang = "str"]
428409
#[cfg(not(test))]
@@ -1924,4 +1905,14 @@ impl str {
19241905
pub fn escape_unicode(&self) -> String {
19251906
self.chars().flat_map(|c| c.escape_unicode()).collect()
19261907
}
1908+
1909+
/// Converts the `Box<str>` into a `String` without copying or allocating.
1910+
#[unstable(feature = "box_str",
1911+
reason = "recently added, matches RFC")]
1912+
pub fn into_string(self: Box<str>) -> String {
1913+
unsafe {
1914+
let slice = mem::transmute::<Box<str>, Box<[u8]>>(self);
1915+
String::from_utf8_unchecked(slice.into_vec())
1916+
}
1917+
}
19271918
}

branches/stable/src/libcollections/string.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use borrow::{Cow, IntoCow};
2929
use range::RangeArgument;
3030
use str::{self, FromStr, Utf8Error, Chars};
3131
use vec::{DerefVec, Vec, as_vec};
32+
use boxed::Box;
3233

3334
/// A growable string stored as a UTF-8 encoded buffer.
3435
#[derive(Clone, PartialOrd, Eq, Ord)]
@@ -741,6 +742,16 @@ impl String {
741742
string: self_ptr,
742743
}
743744
}
745+
746+
/// Converts the string into `Box<str>`.
747+
///
748+
/// Note that this will drop any excess capacity.
749+
#[unstable(feature = "box_str",
750+
reason = "recently added, matches RFC")]
751+
pub fn into_boxed_slice(self) -> Box<str> {
752+
let slice = self.vec.into_boxed_slice();
753+
unsafe { mem::transmute::<Box<[u8]>, Box<str>>(slice) }
754+
}
744755
}
745756

746757
impl FromUtf8Error {

branches/stable/src/libcollectionstest/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#![feature(str_escape)]
4545
#![feature(str_match_indices)]
4646
#![feature(str_utf16)]
47+
#![feature(box_str)]
4748
#![feature(subslice_offset)]
4849
#![feature(test)]
4950
#![feature(unboxed_closures)]

branches/stable/src/libcollectionstest/str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,14 @@ fn to_uppercase() {
17461746
assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ");
17471747
}
17481748

1749+
#[test]
1750+
fn test_into_string() {
1751+
// The only way to acquire a Box<str> in the first place is through a String, so just
1752+
// test that we can round-trip between Box<str> and String.
1753+
let string = String::from("Some text goes here");
1754+
assert_eq!(string.clone().into_boxed_slice().into_string(), string);
1755+
}
1756+
17491757
mod pattern {
17501758
use std::str::pattern::Pattern;
17511759
use std::str::pattern::{Searcher, ReverseSearcher};

branches/stable/src/libcollectionstest/string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,13 @@ fn test_extend_ref() {
374374
assert_eq!(&a, "foobar");
375375
}
376376

377+
#[test]
378+
fn test_into_boxed_slice() {
379+
let xs = String::from("hello my name is bob");
380+
let ys = xs.into_boxed_slice();
381+
assert_eq!(&*ys, "hello my name is bob");
382+
}
383+
377384
#[bench]
378385
fn bench_with_capacity(b: &mut Bencher) {
379386
b.iter(|| {

branches/stable/src/libcore/fmt/builders.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,6 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
175175
fn is_pretty(&self) -> bool {
176176
self.fmt.flags() & (1 << (FlagV1::Alternate as usize)) != 0
177177
}
178-
179-
/// Returns the wrapped `Formatter`.
180-
#[unstable(feature = "debug_builder_formatter", reason = "recently added")]
181-
pub fn formatter(&mut self) -> &mut fmt::Formatter<'b> {
182-
&mut self.fmt
183-
}
184178
}
185179

186180
struct DebugInner<'a, 'b: 'a> {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,19 +1488,20 @@ macro_rules! tuple {
14881488
impl<$($name:Debug),*> Debug for ($($name,)*) {
14891489
#[allow(non_snake_case, unused_assignments)]
14901490
fn fmt(&self, f: &mut Formatter) -> Result {
1491-
let mut builder = f.debug_tuple("");
1491+
try!(write!(f, "("));
14921492
let ($(ref $name,)*) = *self;
14931493
let mut n = 0;
14941494
$(
1495-
builder.field($name);
1495+
if n > 0 {
1496+
try!(write!(f, ", "));
1497+
}
1498+
try!(write!(f, "{:?}", *$name));
14961499
n += 1;
14971500
)*
1498-
14991501
if n == 1 {
1500-
try!(write!(builder.formatter(), ","));
1502+
try!(write!(f, ","));
15011503
}
1502-
1503-
builder.finish()
1504+
write!(f, ")")
15041505
}
15051506
}
15061507
peel! { $($name,)* }

branches/stable/src/liblibc/lib.rs

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -960,100 +960,6 @@ pub mod types {
960960
}
961961
}
962962

963-
#[cfg(target_arch = "x86")]
964-
pub mod arch {
965-
pub mod c95 {
966-
pub type c_char = i8;
967-
pub type c_schar = i8;
968-
pub type c_uchar = u8;
969-
pub type c_short = i16;
970-
pub type c_ushort = u16;
971-
pub type c_int = i32;
972-
pub type c_uint = u32;
973-
pub type c_long = i32;
974-
pub type c_ulong = u32;
975-
pub type c_float = f32;
976-
pub type c_double = f64;
977-
pub type size_t = u32;
978-
pub type ptrdiff_t = i32;
979-
pub type clock_t = i32;
980-
pub type time_t = i32;
981-
pub type suseconds_t = i32;
982-
pub type wchar_t = i32;
983-
}
984-
pub mod c99 {
985-
pub type c_longlong = i64;
986-
pub type c_ulonglong = u64;
987-
pub type intptr_t = i32;
988-
pub type uintptr_t = u32;
989-
pub type intmax_t = i64;
990-
pub type uintmax_t = u64;
991-
}
992-
pub mod posix88 {
993-
pub type off_t = i64;
994-
pub type dev_t = u32;
995-
pub type ino_t = u32;
996-
pub type pid_t = i32;
997-
pub type uid_t = u32;
998-
pub type gid_t = u32;
999-
pub type useconds_t = u32;
1000-
pub type mode_t = u16;
1001-
pub type ssize_t = i32;
1002-
}
1003-
pub mod posix01 {
1004-
use types::common::c95::{c_void};
1005-
use types::common::c99::{uint8_t, uint32_t, int32_t};
1006-
use types::os::arch::c95::{c_long, time_t};
1007-
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
1008-
use types::os::arch::posix88::{mode_t, off_t};
1009-
use types::os::arch::posix88::{uid_t};
1010-
1011-
pub type nlink_t = u16;
1012-
pub type blksize_t = i32;
1013-
pub type blkcnt_t = i64;
1014-
pub type fflags_t = u32;
1015-
#[repr(C)]
1016-
#[derive(Copy, Clone)] pub struct stat {
1017-
pub st_dev: dev_t,
1018-
pub st_ino: ino_t,
1019-
pub st_mode: mode_t,
1020-
pub st_nlink: nlink_t,
1021-
pub st_uid: uid_t,
1022-
pub st_gid: gid_t,
1023-
pub st_rdev: dev_t,
1024-
pub st_atime: time_t,
1025-
pub st_atime_nsec: c_long,
1026-
pub st_mtime: time_t,
1027-
pub st_mtime_nsec: c_long,
1028-
pub st_ctime: time_t,
1029-
pub st_ctime_nsec: c_long,
1030-
pub st_size: off_t,
1031-
pub st_blocks: blkcnt_t,
1032-
pub st_blksize: blksize_t,
1033-
pub st_flags: fflags_t,
1034-
pub st_gen: uint32_t,
1035-
pub st_lspare: int32_t,
1036-
pub st_birthtime: time_t,
1037-
pub st_birthtime_nsec: c_long,
1038-
pub __unused: [uint8_t; 2],
1039-
}
1040-
1041-
#[repr(C)]
1042-
#[derive(Copy, Clone)] pub struct utimbuf {
1043-
pub actime: time_t,
1044-
pub modtime: time_t,
1045-
}
1046-
1047-
pub type pthread_attr_t = *mut c_void;
1048-
}
1049-
pub mod posix08 {
1050-
}
1051-
pub mod bsd44 {
1052-
}
1053-
pub mod extra {
1054-
}
1055-
}
1056-
1057963
#[cfg(target_arch = "x86_64")]
1058964
pub mod arch {
1059965
pub mod c95 {

branches/stable/src/librustc_back/target/i686_unknown_freebsd.rs

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

branches/stable/src/librustc_back/target/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ impl Target {
368368
arm_linux_androideabi,
369369
aarch64_linux_android,
370370

371-
i686_unknown_freebsd,
372371
x86_64_unknown_freebsd,
373372

374373
i686_unknown_dragonfly,

branches/stable/src/libstd/fs.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,14 @@ impl File {
269269
/// will be extended to `size` and have all of the intermediate data filled
270270
/// in with 0s.
271271
///
272-
/// # Errors
273-
///
274-
/// This function will return an error if the file is not opened for writing.
275-
///
276272
/// # Examples
277273
///
278274
/// ```no_run
279275
/// use std::fs::File;
280276
///
281277
/// # fn foo() -> std::io::Result<()> {
282-
/// let mut f = try!(File::create("foo.txt"));
283-
/// try!(f.set_len(10));
278+
/// let mut f = try!(File::open("foo.txt"));
279+
/// try!(f.set_len(0));
284280
/// # Ok(())
285281
/// # }
286282
/// ```

0 commit comments

Comments
 (0)