Skip to content

Commit 3e88ea9

Browse files
committed
---
yaml --- r: 152983 b: refs/heads/try2 c: 0bfcfcf h: refs/heads/master i: 152981: 8ab22fa 152979: 245e3cf 152975: bf52d02 v: v3
1 parent fe69200 commit 3e88ea9

File tree

15 files changed

+521
-413
lines changed

15 files changed

+521
-413
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: db29e1b9603e135948c1d77b85e2f9875270ab71
8+
refs/heads/try2: 0bfcfcffa7afae00e2371c9e92fae5558ec24c26
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/dist.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ PKG_FILES := \
5454
driver \
5555
etc \
5656
$(foreach crate,$(CRATES),lib$(crate)) \
57-
libcoretest \
5857
libbacktrace \
5958
rt \
6059
rustllvm \

branches/try2/src/doc/guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Save the file, and then type this into your terminal window:
160160

161161
```{bash}
162162
$ rustc hello_world.rs
163-
$ ./hello_world # or hello_world.exe on Windows
163+
$ ./hello_world # just 'hello_world' on Windows
164164
Hello, world
165165
```
166166

@@ -243,7 +243,7 @@ There are now two files: our source code, with the `.rs` extension, and the
243243
executable (`hello_world.exe` on Windows, `hello_world` everywhere else)
244244

245245
```{bash}
246-
$ ./hello_world # or hello_world.exe on Windows
246+
$ ./hello_world # or ./hello_world.exe on Windows
247247
```
248248

249249
This prints out our `Hello, world!` text to our terminal.

branches/try2/src/libcollections/str.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ pub fn from_utf8_owned(vv: Vec<u8>) -> Result<String, Vec<u8>> {
106106
/// # Failure
107107
///
108108
/// Fails if invalid UTF-8
109+
///
110+
/// # Example
111+
///
112+
/// ```rust
113+
/// use std::str;
114+
/// let string = str::from_byte(66u8);
115+
/// assert_eq!(string.as_slice(), "B");
116+
/// ```
109117
pub fn from_byte(b: u8) -> String {
110118
assert!(b < 128u8);
111119
String::from_char(1, b as char)
@@ -803,9 +811,15 @@ pub trait StrAllocating: Str {
803811
}
804812

805813
/// Converts to a vector of `u16` encoded as UTF-16.
806-
#[deprecated = "use `utf16_units` instead"]
807814
fn to_utf16(&self) -> Vec<u16> {
808-
self.as_slice().utf16_units().collect::<Vec<u16>>()
815+
let me = self.as_slice();
816+
let mut u = Vec::new();
817+
for ch in me.chars() {
818+
let mut buf = [0u16, ..2];
819+
let n = ch.encode_utf16(buf /* as mut slice! */);
820+
u.push_all(buf.slice_to(n));
821+
}
822+
u
809823
}
810824

811825
/// Given a string, make a new string with repeated copies of it.
@@ -1613,17 +1627,14 @@ mod tests {
16131627

16141628
for p in pairs.iter() {
16151629
let (s, u) = (*p).clone();
1616-
let s_as_utf16 = s.as_slice().utf16_units().collect::<Vec<u16>>();
1617-
let u_as_string = from_utf16(u.as_slice()).unwrap();
1618-
16191630
assert!(is_utf16(u.as_slice()));
1620-
assert_eq!(s_as_utf16, u);
1631+
assert_eq!(s.to_utf16(), u);
16211632

1622-
assert_eq!(u_as_string, s);
1633+
assert_eq!(from_utf16(u.as_slice()).unwrap(), s);
16231634
assert_eq!(from_utf16_lossy(u.as_slice()), s);
16241635

1625-
assert_eq!(from_utf16(s_as_utf16.as_slice()).unwrap(), s);
1626-
assert_eq!(u_as_string.as_slice().utf16_units().collect::<Vec<u16>>(), u);
1636+
assert_eq!(from_utf16(s.to_utf16().as_slice()).unwrap(), s);
1637+
assert_eq!(from_utf16(u.as_slice()).unwrap().to_utf16(), u);
16271638
}
16281639
}
16291640

branches/try2/src/libcore/str.rs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
use mem;
1818
use char;
19-
use char::Char;
2019
use clone::Clone;
2120
use cmp;
2221
use cmp::{PartialEq, Eq};
@@ -25,7 +24,7 @@ use default::Default;
2524
use iter::{Filter, Map, Iterator};
2625
use iter::{DoubleEndedIterator, ExactSize};
2726
use iter::range;
28-
use num::{CheckedMul, Saturating};
27+
use num::Saturating;
2928
use option::{None, Option, Some};
3029
use raw::Repr;
3130
use slice::ImmutableVector;
@@ -558,41 +557,6 @@ impl<'a> Iterator<&'a str> for StrSplits<'a> {
558557
}
559558
}
560559

561-
/// External iterator for a string's UTF16 codeunits.
562-
/// Use with the `std::iter` module.
563-
#[deriving(Clone)]
564-
pub struct Utf16CodeUnits<'a> {
565-
chars: Chars<'a>,
566-
extra: u16
567-
}
568-
569-
impl<'a> Iterator<u16> for Utf16CodeUnits<'a> {
570-
#[inline]
571-
fn next(&mut self) -> Option<u16> {
572-
if self.extra != 0 {
573-
let tmp = self.extra;
574-
self.extra = 0;
575-
return Some(tmp);
576-
}
577-
578-
let mut buf = [0u16, ..2];
579-
self.chars.next().map(|ch| {
580-
let n = ch.encode_utf16(buf /* as mut slice! */);
581-
if n == 2 { self.extra = buf[1]; }
582-
buf[0]
583-
})
584-
}
585-
586-
#[inline]
587-
fn size_hint(&self) -> (uint, Option<uint>) {
588-
let (low, high) = self.chars.size_hint();
589-
// every char gets either one u16 or two u16,
590-
// so this iterator is between 1 or 2 times as
591-
// long as the underlying iterator.
592-
(low, high.and_then(|n| n.checked_mul(&2)))
593-
}
594-
}
595-
596560
/*
597561
Section: Comparing strings
598562
*/
@@ -1645,9 +1609,6 @@ pub trait StrSlice<'a> {
16451609
/// and that it is not reallocated (e.g. by pushing to the
16461610
/// string).
16471611
fn as_ptr(&self) -> *const u8;
1648-
1649-
/// Return an iterator of `u16` over the string encoded as UTF-16.
1650-
fn utf16_units(&self) -> Utf16CodeUnits<'a>;
16511612
}
16521613

16531614
impl<'a> StrSlice<'a> for &'a str {
@@ -1996,11 +1957,6 @@ impl<'a> StrSlice<'a> for &'a str {
19961957
fn as_ptr(&self) -> *const u8 {
19971958
self.repr().data
19981959
}
1999-
2000-
#[inline]
2001-
fn utf16_units(&self) -> Utf16CodeUnits<'a> {
2002-
Utf16CodeUnits{ chars: self.chars(), extra: 0}
2003-
}
20041960
}
20051961

20061962
impl<'a> Default for &'a str {

branches/try2/src/libnative/io/c_win32.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ extern "system" {
7070

7171
pub mod compat {
7272
use std::intrinsics::{atomic_store_relaxed, transmute};
73-
use std::iter::Iterator;
7473
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
7574

7675
extern "system" {
@@ -83,8 +82,7 @@ pub mod compat {
8382
// layer (after it's loaded) shouldn't be any slower than a regular DLL
8483
// call.
8584
unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint) {
86-
let module: Vec<u16> = module.utf16_units().collect();
87-
let module = module.append_one(0);
85+
let module = module.to_utf16().append_one(0);
8886
symbol.with_c_str(|symbol| {
8987
let handle = GetModuleHandleW(module.as_ptr());
9088
let func: uint = transmute(GetProcAddress(handle, symbol));

branches/try2/src/libnative/io/file_win32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl Drop for Inner {
255255

256256
pub fn to_utf16(s: &CString) -> IoResult<Vec<u16>> {
257257
match s.as_str() {
258-
Some(s) => Ok(s.utf16_units().collect::<Vec<u16>>().append_one(0)),
258+
Some(s) => Ok(s.to_utf16().append_one(0)),
259259
None => Err(IoError {
260260
code: libc::ERROR_INVALID_NAME as uint,
261261
extra: 0,

branches/try2/src/libnative/io/process.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,6 @@ fn spawn_process_os(cfg: ProcessConfig,
294294
use libc::funcs::extra::msvcrt::get_osfhandle;
295295

296296
use std::mem;
297-
use std::iter::Iterator;
298-
use std::str::StrSlice;
299297

300298
if cfg.gid.is_some() || cfg.uid.is_some() {
301299
return Err(IoError {
@@ -330,8 +328,7 @@ fn spawn_process_os(cfg: ProcessConfig,
330328
lpSecurityDescriptor: ptr::mut_null(),
331329
bInheritHandle: 1,
332330
};
333-
let filename: Vec<u16> = "NUL".utf16_units().collect();
334-
let filename = filename.append_one(0);
331+
let filename = "NUL".to_utf16().append_one(0);
335332
*slot = libc::CreateFileW(filename.as_ptr(),
336333
access,
337334
libc::FILE_SHARE_READ |
@@ -374,8 +371,7 @@ fn spawn_process_os(cfg: ProcessConfig,
374371

375372
with_envp(cfg.env, |envp| {
376373
with_dirp(cfg.cwd, |dirp| {
377-
let mut cmd_str: Vec<u16> = cmd_str.as_slice().utf16_units().collect();
378-
cmd_str = cmd_str.append_one(0);
374+
let mut cmd_str = cmd_str.to_utf16().append_one(0);
379375
let created = CreateProcessW(ptr::null(),
380376
cmd_str.as_mut_ptr(),
381377
ptr::mut_null(),
@@ -774,7 +770,7 @@ fn with_envp<T>(env: Option<&[(CString, CString)]>, cb: |*mut c_void| -> T) -> T
774770
let kv = format!("{}={}",
775771
pair.ref0().as_str().unwrap(),
776772
pair.ref1().as_str().unwrap());
777-
blk.extend(kv.as_slice().utf16_units());
773+
blk.push_all(kv.to_utf16().as_slice());
778774
blk.push(0);
779775
}
780776

@@ -792,9 +788,7 @@ fn with_dirp<T>(d: Option<&CString>, cb: |*const u16| -> T) -> T {
792788
Some(dir) => {
793789
let dir_str = dir.as_str()
794790
.expect("expected workingdirectory to be utf-8 encoded");
795-
let dir_str: Vec<u16> = dir_str.utf16_units().collect();
796-
let dir_str = dir_str.append_one(0);
797-
791+
let dir_str = dir_str.to_utf16().append_one(0);
798792
cb(dir_str.as_ptr())
799793
},
800794
None => cb(ptr::null())

branches/try2/src/librustdoc/flock.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ mod imp {
162162

163163
impl Lock {
164164
pub fn new(p: &Path) -> Lock {
165-
let p_16: Vec<u16> = p.as_str().unwrap().utf16_units().collect();
166-
let p_16 = p_16.append_one(0);
165+
let p_16 = p.as_str().unwrap().to_utf16().append_one(0);
167166
let handle = unsafe {
168167
libc::CreateFileW(p_16.as_ptr(),
169168
libc::FILE_GENERIC_READ |

branches/try2/src/librustdoc/lib.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -408,17 +408,18 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
408408
// "crate": { parsed crate ... },
409409
// "plugins": { output of plugins ... }
410410
// }
411-
let mut json = std::collections::TreeMap::new();
412-
json.insert("schema".to_string(), json::String(SCHEMA_VERSION.to_string()));
413-
let plugins_json = res.move_iter()
414-
.filter_map(|opt| {
415-
match opt {
416-
None => None,
417-
Some((string, json)) => {
418-
Some((string.to_string(), json))
411+
let mut json = box std::collections::TreeMap::new();
412+
json.insert("schema".to_string(),
413+
json::String(SCHEMA_VERSION.to_string()));
414+
let plugins_json = box res.move_iter()
415+
.filter_map(|opt| {
416+
match opt {
417+
None => None,
418+
Some((string, json)) => {
419+
Some((string.to_string(), json))
420+
}
419421
}
420-
}
421-
}).collect();
422+
}).collect();
422423

423424
// FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
424425
// straight to the Rust JSON representation.
@@ -428,7 +429,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
428429
let mut encoder = json::Encoder::new(&mut w as &mut io::Writer);
429430
krate.encode(&mut encoder).unwrap();
430431
}
431-
str::from_utf8_owned(w.unwrap()).unwrap()
432+
str::from_utf8(w.unwrap().as_slice()).unwrap().to_string()
432433
};
433434
let crate_json = match json::from_str(crate_json_str.as_slice()) {
434435
Ok(j) => j,
@@ -439,5 +440,6 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
439440
json.insert("plugins".to_string(), json::Object(plugins_json));
440441

441442
let mut file = try!(File::create(&dst));
442-
json::Object(json).to_writer(&mut file)
443+
try!(json::Object(json).to_writer(&mut file));
444+
Ok(())
443445
}

0 commit comments

Comments
 (0)