Test fixes and rebase conflicts
This commit is contained in:
parent
cb7599b83e
commit
470ae101d6
|
@ -412,7 +412,7 @@ impl<T> TypedArenaChunk<T> {
|
||||||
let size = calculate_size::<T>(self.capacity);
|
let size = calculate_size::<T>(self.capacity);
|
||||||
deallocate(self as *mut TypedArenaChunk<T> as *mut u8, size,
|
deallocate(self as *mut TypedArenaChunk<T> as *mut u8, size,
|
||||||
mem::min_align_of::<TypedArenaChunk<T>>());
|
mem::min_align_of::<TypedArenaChunk<T>>());
|
||||||
if next.is_not_null() {
|
if !next.is_null() {
|
||||||
let capacity = (*next).capacity;
|
let capacity = (*next).capacity;
|
||||||
(*next).destroy(capacity);
|
(*next).destroy(capacity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,14 +114,14 @@ mod prelude {
|
||||||
pub use core::ops::{Drop, Fn, FnMut, FnOnce};
|
pub use core::ops::{Drop, Fn, FnMut, FnOnce};
|
||||||
pub use core::option::Option;
|
pub use core::option::Option;
|
||||||
pub use core::option::Option::{Some, None};
|
pub use core::option::Option::{Some, None};
|
||||||
pub use core::ptr::RawPtr;
|
pub use core::ptr::PtrExt;
|
||||||
pub use core::result::Result;
|
pub use core::result::Result;
|
||||||
pub use core::result::Result::{Ok, Err};
|
pub use core::result::Result::{Ok, Err};
|
||||||
|
|
||||||
// in core and collections (may differ).
|
// in core and collections (may differ).
|
||||||
pub use slice::{PartialEqSliceExt, OrdSliceExt};
|
pub use slice::{PartialEqSliceExt, OrdSliceExt};
|
||||||
pub use slice::{AsSlice, SliceExt};
|
pub use slice::{AsSlice, SliceExt};
|
||||||
pub use str::{from_str, Str};
|
pub use str::{from_str, Str, StrExt};
|
||||||
|
|
||||||
// from other crates.
|
// from other crates.
|
||||||
pub use alloc::boxed::Box;
|
pub use alloc::boxed::Box;
|
||||||
|
|
|
@ -1770,15 +1770,9 @@ mod tests {
|
||||||
|
|
||||||
use core::default::Default;
|
use core::default::Default;
|
||||||
use core::iter::AdditiveIterator;
|
use core::iter::AdditiveIterator;
|
||||||
use super::{eq_slice, from_utf8, is_utf8, is_utf16, raw};
|
use super::{from_utf8, is_utf8, raw};
|
||||||
use super::truncate_utf16_at_nul;
|
|
||||||
use super::MaybeOwned::{Owned, Slice};
|
use super::MaybeOwned::{Owned, Slice};
|
||||||
use std::slice::{AsSlice, SliceExt};
|
use super::Utf8Error;
|
||||||
use string::{String, ToString};
|
|
||||||
use vec::Vec;
|
|
||||||
use slice::CloneSliceExt;
|
|
||||||
|
|
||||||
use unicode::char::UnicodeChar;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_le() {
|
fn test_le() {
|
||||||
|
|
|
@ -1082,7 +1082,7 @@ mod tests {
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
use str::{StrExt, Utf8Error};
|
use str::Utf8Error;
|
||||||
use str;
|
use str;
|
||||||
use super::as_string;
|
use super::as_string;
|
||||||
|
|
||||||
|
|
|
@ -538,7 +538,7 @@ pub unsafe fn from_c_multistring<F>(buf: *const libc::c_char,
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use prelude::{spawn, Some, None, Option, FnOnce, ToString, CloneSliceExt};
|
use prelude::{spawn, Some, None, Option, FnOnce, ToString, CloneSliceExt};
|
||||||
use prelude::{Clone, RawPtr, Iterator, SliceExt, StrExt};
|
use prelude::{Clone, PtrExt, Iterator, SliceExt, StrExt};
|
||||||
use ptr;
|
use ptr;
|
||||||
use thread::Thread;
|
use thread::Thread;
|
||||||
use libc;
|
use libc;
|
||||||
|
|
|
@ -278,7 +278,7 @@ fn test_resize_policy() {
|
||||||
///
|
///
|
||||||
/// impl Viking {
|
/// impl Viking {
|
||||||
/// /// Create a new Viking.
|
/// /// Create a new Viking.
|
||||||
/// pub fn new(name: &str, country: &str) -> Viking {
|
/// fn new(name: &str, country: &str) -> Viking {
|
||||||
/// Viking { name: name.to_string(), country: country.to_string() }
|
/// Viking { name: name.to_string(), country: country.to_string() }
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
|
|
@ -1207,6 +1207,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn env_map_keys_ci() {
|
fn env_map_keys_ci() {
|
||||||
|
use c_str::ToCStr;
|
||||||
use super::EnvKey;
|
use super::EnvKey;
|
||||||
let mut cmd = Command::new("");
|
let mut cmd = Command::new("");
|
||||||
cmd.env("path", "foo");
|
cmd.env("path", "foo");
|
||||||
|
|
|
@ -731,7 +731,7 @@ fn real_args() -> Vec<String> {
|
||||||
let ptr = ptr as *const u16;
|
let ptr = ptr as *const u16;
|
||||||
let buf = slice::from_raw_buf(&ptr, len);
|
let buf = slice::from_raw_buf(&ptr, len);
|
||||||
let opt_s = String::from_utf16(sys::os::truncate_utf16_at_nul(buf));
|
let opt_s = String::from_utf16(sys::os::truncate_utf16_at_nul(buf));
|
||||||
opt_s.expect("CommandLineToArgvW returned invalid UTF-16")
|
opt_s.ok().expect("CommandLineToArgvW returned invalid UTF-16")
|
||||||
});
|
});
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -60,19 +60,19 @@ mod test {
|
||||||
t!("_ZN4$UP$E", "Box");
|
t!("_ZN4$UP$E", "Box");
|
||||||
t!("_ZN8$UP$testE", "Boxtest");
|
t!("_ZN8$UP$testE", "Boxtest");
|
||||||
t!("_ZN8$UP$test4foobE", "Boxtest::foob");
|
t!("_ZN8$UP$test4foobE", "Boxtest::foob");
|
||||||
t!("_ZN8$x20test4foobE", " test::foob");
|
t!("_ZN10$u{20}test4foobE", " test::foob");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn demangle_many_dollars() {
|
fn demangle_many_dollars() {
|
||||||
t!("_ZN12test$x20test4foobE", "test test::foob");
|
t!("_ZN14test$u{20}test4foobE", "test test::foob");
|
||||||
t!("_ZN12test$UP$test4foobE", "testBoxtest::foob");
|
t!("_ZN12test$UP$test4foobE", "testBoxtest::foob");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn demangle_windows() {
|
fn demangle_windows() {
|
||||||
t!("ZN4testE", "test");
|
t!("ZN4testE", "test");
|
||||||
t!("ZN12test$x20test4foobE", "test test::foob");
|
t!("ZN14test$u{20}test4foobE", "test test::foob");
|
||||||
t!("ZN12test$UP$test4foobE", "testBoxtest::foob");
|
t!("ZN12test$UP$test4foobE", "testBoxtest::foob");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,9 @@ impl<T: Send> Drop for Mutex<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DUMMY: UnsafeCell<()> = UnsafeCell { value: () };
|
struct Dummy(UnsafeCell<()>);
|
||||||
|
unsafe impl Sync for Dummy {}
|
||||||
|
static DUMMY: Dummy = Dummy(UnsafeCell { value: () });
|
||||||
|
|
||||||
impl StaticMutex {
|
impl StaticMutex {
|
||||||
/// Acquires this lock, see `Mutex::lock`
|
/// Acquires this lock, see `Mutex::lock`
|
||||||
|
@ -242,7 +244,7 @@ impl StaticMutex {
|
||||||
#[unstable = "may be merged with Mutex in the future"]
|
#[unstable = "may be merged with Mutex in the future"]
|
||||||
pub fn lock(&'static self) -> LockResult<MutexGuard<()>> {
|
pub fn lock(&'static self) -> LockResult<MutexGuard<()>> {
|
||||||
unsafe { self.lock.lock() }
|
unsafe { self.lock.lock() }
|
||||||
MutexGuard::new(self, &DUMMY)
|
MutexGuard::new(self, &DUMMY.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to grab this lock, see `Mutex::try_lock`
|
/// Attempts to grab this lock, see `Mutex::try_lock`
|
||||||
|
@ -250,7 +252,7 @@ impl StaticMutex {
|
||||||
#[unstable = "may be merged with Mutex in the future"]
|
#[unstable = "may be merged with Mutex in the future"]
|
||||||
pub fn try_lock(&'static self) -> TryLockResult<MutexGuard<()>> {
|
pub fn try_lock(&'static self) -> TryLockResult<MutexGuard<()>> {
|
||||||
if unsafe { self.lock.try_lock() } {
|
if unsafe { self.lock.try_lock() } {
|
||||||
Ok(try!(MutexGuard::new(self, &DUMMY)))
|
Ok(try!(MutexGuard::new(self, &DUMMY.0)))
|
||||||
} else {
|
} else {
|
||||||
Err(TryLockError::WouldBlock)
|
Err(TryLockError::WouldBlock)
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,9 @@ impl<T> Drop for RWLock<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DUMMY: UnsafeCell<()> = UnsafeCell { value: () };
|
struct Dummy(UnsafeCell<()>);
|
||||||
|
unsafe impl Sync for Dummy {}
|
||||||
|
static DUMMY: Dummy = Dummy(UnsafeCell { value: () });
|
||||||
|
|
||||||
impl StaticRWLock {
|
impl StaticRWLock {
|
||||||
/// Locks this rwlock with shared read access, blocking the current thread
|
/// Locks this rwlock with shared read access, blocking the current thread
|
||||||
|
@ -244,7 +246,7 @@ impl StaticRWLock {
|
||||||
#[unstable = "may be merged with RWLock in the future"]
|
#[unstable = "may be merged with RWLock in the future"]
|
||||||
pub fn read(&'static self) -> LockResult<RWLockReadGuard<'static, ()>> {
|
pub fn read(&'static self) -> LockResult<RWLockReadGuard<'static, ()>> {
|
||||||
unsafe { self.lock.read() }
|
unsafe { self.lock.read() }
|
||||||
RWLockReadGuard::new(self, &DUMMY)
|
RWLockReadGuard::new(self, &DUMMY.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to acquire this lock with shared read access.
|
/// Attempt to acquire this lock with shared read access.
|
||||||
|
@ -255,7 +257,7 @@ impl StaticRWLock {
|
||||||
pub fn try_read(&'static self)
|
pub fn try_read(&'static self)
|
||||||
-> TryLockResult<RWLockReadGuard<'static, ()>> {
|
-> TryLockResult<RWLockReadGuard<'static, ()>> {
|
||||||
if unsafe { self.lock.try_read() } {
|
if unsafe { self.lock.try_read() } {
|
||||||
Ok(try!(RWLockReadGuard::new(self, &DUMMY)))
|
Ok(try!(RWLockReadGuard::new(self, &DUMMY.0)))
|
||||||
} else {
|
} else {
|
||||||
Err(TryLockError::WouldBlock)
|
Err(TryLockError::WouldBlock)
|
||||||
}
|
}
|
||||||
|
@ -269,7 +271,7 @@ impl StaticRWLock {
|
||||||
#[unstable = "may be merged with RWLock in the future"]
|
#[unstable = "may be merged with RWLock in the future"]
|
||||||
pub fn write(&'static self) -> LockResult<RWLockWriteGuard<'static, ()>> {
|
pub fn write(&'static self) -> LockResult<RWLockWriteGuard<'static, ()>> {
|
||||||
unsafe { self.lock.write() }
|
unsafe { self.lock.write() }
|
||||||
RWLockWriteGuard::new(self, &DUMMY)
|
RWLockWriteGuard::new(self, &DUMMY.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to lock this rwlock with exclusive write access.
|
/// Attempt to lock this rwlock with exclusive write access.
|
||||||
|
@ -280,7 +282,7 @@ impl StaticRWLock {
|
||||||
pub fn try_write(&'static self)
|
pub fn try_write(&'static self)
|
||||||
-> TryLockResult<RWLockWriteGuard<'static, ()>> {
|
-> TryLockResult<RWLockWriteGuard<'static, ()>> {
|
||||||
if unsafe { self.lock.try_write() } {
|
if unsafe { self.lock.try_write() } {
|
||||||
Ok(try!(RWLockWriteGuard::new(self, &DUMMY)))
|
Ok(try!(RWLockWriteGuard::new(self, &DUMMY.0)))
|
||||||
} else {
|
} else {
|
||||||
Err(TryLockError::WouldBlock)
|
Err(TryLockError::WouldBlock)
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,7 +669,7 @@ impl TcpStream {
|
||||||
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
|
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
|
||||||
let ret = Guard {
|
let ret = Guard {
|
||||||
fd: self.fd(),
|
fd: self.fd(),
|
||||||
guard: self.inner.lock.lock(),
|
guard: self.inner.lock.lock().unwrap(),
|
||||||
};
|
};
|
||||||
assert!(set_nonblocking(self.fd(), true).is_ok());
|
assert!(set_nonblocking(self.fd(), true).is_ok());
|
||||||
ret
|
ret
|
||||||
|
@ -808,7 +808,7 @@ impl UdpSocket {
|
||||||
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
|
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
|
||||||
let ret = Guard {
|
let ret = Guard {
|
||||||
fd: self.fd(),
|
fd: self.fd(),
|
||||||
guard: self.inner.lock.lock(),
|
guard: self.inner.lock.lock().unwrap(),
|
||||||
};
|
};
|
||||||
assert!(set_nonblocking(self.fd(), true).is_ok());
|
assert!(set_nonblocking(self.fd(), true).is_ok());
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -145,7 +145,7 @@ impl UnixStream {
|
||||||
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
|
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
|
||||||
let ret = Guard {
|
let ret = Guard {
|
||||||
fd: self.fd(),
|
fd: self.fd(),
|
||||||
guard: unsafe { self.inner.lock.lock() },
|
guard: unsafe { self.inner.lock.lock().unwrap() },
|
||||||
};
|
};
|
||||||
assert!(set_nonblocking(self.fd(), true).is_ok());
|
assert!(set_nonblocking(self.fd(), true).is_ok());
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -131,7 +131,6 @@ extern "system" {
|
||||||
|
|
||||||
pub mod compat {
|
pub mod compat {
|
||||||
use intrinsics::{atomic_store_relaxed, transmute};
|
use intrinsics::{atomic_store_relaxed, transmute};
|
||||||
use iter::IteratorExt;
|
|
||||||
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
|
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -265,8 +265,8 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> {
|
||||||
{
|
{
|
||||||
let filename = os::truncate_utf16_at_nul(&wfd.cFileName);
|
let filename = os::truncate_utf16_at_nul(&wfd.cFileName);
|
||||||
match String::from_utf16(filename) {
|
match String::from_utf16(filename) {
|
||||||
Some(filename) => paths.push(Path::new(filename)),
|
Ok(filename) => paths.push(Path::new(filename)),
|
||||||
None => {
|
Err(..) => {
|
||||||
assert!(libc::FindClose(find_handle) != 0);
|
assert!(libc::FindClose(find_handle) != 0);
|
||||||
return Err(IoError {
|
return Err(IoError {
|
||||||
kind: io::InvalidInput,
|
kind: io::InvalidInput,
|
||||||
|
|
|
@ -99,8 +99,9 @@ pub fn error_string(errnum: i32) -> String {
|
||||||
|
|
||||||
let msg = String::from_utf16(truncate_utf16_at_nul(&buf));
|
let msg = String::from_utf16(truncate_utf16_at_nul(&buf));
|
||||||
match msg {
|
match msg {
|
||||||
Some(msg) => format!("OS Error {}: {}", errnum, msg),
|
Ok(msg) => format!("OS Error {}: {}", errnum, msg),
|
||||||
None => format!("OS Error {} (FormatMessageW() returned invalid UTF-16)", errnum),
|
Err(..) => format!("OS Error {} (FormatMessageW() returned \
|
||||||
|
invalid UTF-16)", errnum),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +148,7 @@ pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) -> Option<String
|
||||||
// We want to explicitly catch the case when the
|
// We want to explicitly catch the case when the
|
||||||
// closure returned invalid UTF-16, rather than
|
// closure returned invalid UTF-16, rather than
|
||||||
// set `res` to None and continue.
|
// set `res` to None and continue.
|
||||||
let s = String::from_utf16(sub)
|
let s = String::from_utf16(sub).ok()
|
||||||
.expect("fill_utf16_buf_and_decode: closure created invalid UTF-16");
|
.expect("fill_utf16_buf_and_decode: closure created invalid UTF-16");
|
||||||
res = Some(s)
|
res = Some(s)
|
||||||
}
|
}
|
||||||
|
@ -169,8 +170,8 @@ pub fn getcwd() -> IoResult<Path> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match String::from_utf16(truncate_utf16_at_nul(&buf)) {
|
match String::from_utf16(truncate_utf16_at_nul(&buf)) {
|
||||||
Some(ref cwd) => Ok(Path::new(cwd)),
|
Ok(ref cwd) => Ok(Path::new(cwd)),
|
||||||
None => Err(IoError {
|
Err(..) => Err(IoError {
|
||||||
kind: OtherIoError,
|
kind: OtherIoError,
|
||||||
desc: "GetCurrentDirectoryW returned invalid UTF-16",
|
desc: "GetCurrentDirectoryW returned invalid UTF-16",
|
||||||
detail: None,
|
detail: None,
|
||||||
|
|
|
@ -101,8 +101,8 @@ impl TTY {
|
||||||
};
|
};
|
||||||
utf16.truncate(num as uint);
|
utf16.truncate(num as uint);
|
||||||
let utf8 = match String::from_utf16(utf16.as_slice()) {
|
let utf8 = match String::from_utf16(utf16.as_slice()) {
|
||||||
Some(utf8) => utf8.into_bytes(),
|
Ok(utf8) => utf8.into_bytes(),
|
||||||
None => return Err(invalid_encoding()),
|
Err(..) => return Err(invalid_encoding()),
|
||||||
};
|
};
|
||||||
self.utf8 = MemReader::new(utf8);
|
self.utf8 = MemReader::new(utf8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,5 @@ static boxed: Box<RefCell<int>> = box RefCell::new(0);
|
||||||
//~^ ERROR statics are not allowed to have custom pointers
|
//~^ ERROR statics are not allowed to have custom pointers
|
||||||
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
|
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
|
||||||
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
|
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
|
||||||
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
|
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -17,5 +17,4 @@ fn main() {
|
||||||
f(x);
|
f(x);
|
||||||
//~^ ERROR `core::kinds::Sync` is not implemented
|
//~^ ERROR `core::kinds::Sync` is not implemented
|
||||||
//~^^ ERROR `core::kinds::Sync` is not implemented
|
//~^^ ERROR `core::kinds::Sync` is not implemented
|
||||||
//~^^^ ERROR `core::kinds::Sync` is not implemented
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue