]> git.lizzy.rs Git - rust.git/commitdiff
Test fixes and rebase conflicts
authorAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:38:07 +0000 (16:38 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 07:55:49 +0000 (23:55 -0800)
19 files changed:
src/libarena/lib.rs
src/libcollections/lib.rs
src/libcollections/str.rs
src/libcollections/string.rs
src/libstd/c_str.rs
src/libstd/collections/hash/map.rs
src/libstd/io/process.rs
src/libstd/os.rs
src/libstd/rt/backtrace.rs
src/libstd/sync/mutex.rs
src/libstd/sync/rwlock.rs
src/libstd/sys/common/net.rs
src/libstd/sys/unix/pipe.rs
src/libstd/sys/windows/c.rs
src/libstd/sys/windows/fs.rs
src/libstd/sys/windows/os.rs
src/libstd/sys/windows/tty.rs
src/test/compile-fail/issue-7364.rs
src/test/compile-fail/mut-not-freeze.rs

index 1f4df1fd0a5a28e1199ac28ca10c0ec90bc39433..b0fa5434a1474c65f2ebb64be23a4316f337b87f 100644 (file)
@@ -412,7 +412,7 @@ unsafe fn destroy(&mut self, len: uint) {
         let size = calculate_size::<T>(self.capacity);
         deallocate(self as *mut TypedArenaChunk<T> as *mut u8, size,
                    mem::min_align_of::<TypedArenaChunk<T>>());
-        if next.is_not_null() {
+        if !next.is_null() {
             let capacity = (*next).capacity;
             (*next).destroy(capacity);
         }
index 363d30abd0347b02eef24cd234b3abb6a1c08dc7..fe9d8de440a17aca42c15bad4f6d11fc071b031b 100644 (file)
@@ -114,14 +114,14 @@ mod prelude {
     pub use core::ops::{Drop, Fn, FnMut, FnOnce};
     pub use core::option::Option;
     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::{Ok, Err};
 
     // in core and collections (may differ).
     pub use slice::{PartialEqSliceExt, OrdSliceExt};
     pub use slice::{AsSlice, SliceExt};
-    pub use str::{from_str, Str};
+    pub use str::{from_str, Str, StrExt};
 
     // from other crates.
     pub use alloc::boxed::Box;
index fdc52ab8eb054f101e10b497bd4cbecee8211cdf..7c7a7e19a2f18c92ece50074a8dceaf1e5992643 100644 (file)
@@ -1770,15 +1770,9 @@ mod tests {
 
     use core::default::Default;
     use core::iter::AdditiveIterator;
-    use super::{eq_slice, from_utf8, is_utf8, is_utf16, raw};
-    use super::truncate_utf16_at_nul;
+    use super::{from_utf8, is_utf8, raw};
     use super::MaybeOwned::{Owned, Slice};
-    use std::slice::{AsSlice, SliceExt};
-    use string::{String, ToString};
-    use vec::Vec;
-    use slice::CloneSliceExt;
-
-    use unicode::char::UnicodeChar;
+    use super::Utf8Error;
 
     #[test]
     fn test_le() {
index 51ad0b52b81892455e569be41b33d7a655d98f5d..c6c19cae75f1efc1b55a005d0f6a8eeb6cf307d6 100644 (file)
@@ -1082,7 +1082,7 @@ mod tests {
     use prelude::*;
     use test::Bencher;
 
-    use str::{StrExt, Utf8Error};
+    use str::Utf8Error;
     use str;
     use super::as_string;
 
index 39c57b99b36f018e40e2db890de8d2605d825abd..f28abcc10cfd8dcf0d651005566e08a61a67834c 100644 (file)
@@ -538,7 +538,7 @@ pub unsafe fn from_c_multistring<F>(buf: *const libc::c_char,
 mod tests {
     use super::*;
     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 thread::Thread;
     use libc;
index c62ca6f59295d8f08fabf4806fe63c943d15368e..7b7473b2c993c27d3cd13d6e9cd86034f3eed7ab 100644 (file)
@@ -278,7 +278,7 @@ fn test_resize_policy() {
 ///
 /// impl 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() }
 ///     }
 /// }
index 9e0c76e4e79f5de2cb55bbbc65919ce6060dac0a..b127507f048d22ff0d7751feb212277d075979f4 100644 (file)
@@ -1207,6 +1207,7 @@ fn dont_close_fd_on_command_spawn() {
     #[test]
     #[cfg(windows)]
     fn env_map_keys_ci() {
+        use c_str::ToCStr;
         use super::EnvKey;
         let mut cmd = Command::new("");
         cmd.env("path", "foo");
index 049d97798e4e3dcb9e9967d9597a472e7a3c2994..989f44f7b8e4239326adf25ac0ec1be2cf154474 100644 (file)
@@ -731,7 +731,7 @@ fn real_args() -> Vec<String> {
         let ptr = ptr as *const u16;
         let buf = slice::from_raw_buf(&ptr, len);
         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 {
index 775e9bb526f7cbc84a300e47b4385b386e6d1654..3eeb0ad3968fe9b091e77cc9f4154d5466a98c4a 100644 (file)
@@ -60,19 +60,19 @@ fn demangle_dollars() {
         t!("_ZN4$UP$E", "Box");
         t!("_ZN8$UP$testE", "Boxtest");
         t!("_ZN8$UP$test4foobE", "Boxtest::foob");
-        t!("_ZN8$x20test4foobE", " test::foob");
+        t!("_ZN10$u{20}test4foobE", " test::foob");
     }
 
     #[test]
     fn demangle_many_dollars() {
-        t!("_ZN12test$x20test4foobE", "test test::foob");
+        t!("_ZN14test$u{20}test4foobE", "test test::foob");
         t!("_ZN12test$UP$test4foobE", "testBoxtest::foob");
     }
 
     #[test]
     fn demangle_windows() {
         t!("ZN4testE", "test");
-        t!("ZN12test$x20test4foobE", "test test::foob");
+        t!("ZN14test$u{20}test4foobE", "test test::foob");
         t!("ZN12test$UP$test4foobE", "testBoxtest::foob");
     }
 }
index 32c2c67152fe4a68ba53ffe8dc7441c833575857..52004bb4a8f5f4a99f59658424c13ed59af0cb91 100644 (file)
@@ -234,7 +234,9 @@ fn drop(&mut self) {
     }
 }
 
-static DUMMY: UnsafeCell<()> = UnsafeCell { value: () };
+struct Dummy(UnsafeCell<()>);
+unsafe impl Sync for Dummy {}
+static DUMMY: Dummy = Dummy(UnsafeCell { value: () });
 
 impl StaticMutex {
     /// Acquires this lock, see `Mutex::lock`
@@ -242,7 +244,7 @@ impl StaticMutex {
     #[unstable = "may be merged with Mutex in the future"]
     pub fn lock(&'static self) -> LockResult<MutexGuard<()>> {
         unsafe { self.lock.lock() }
-        MutexGuard::new(self, &DUMMY)
+        MutexGuard::new(self, &DUMMY.0)
     }
 
     /// Attempts to grab this lock, see `Mutex::try_lock`
@@ -250,7 +252,7 @@ pub fn lock(&'static self) -> LockResult<MutexGuard<()>> {
     #[unstable = "may be merged with Mutex in the future"]
     pub fn try_lock(&'static self) -> TryLockResult<MutexGuard<()>> {
         if unsafe { self.lock.try_lock() } {
-            Ok(try!(MutexGuard::new(self, &DUMMY)))
+            Ok(try!(MutexGuard::new(self, &DUMMY.0)))
         } else {
             Err(TryLockError::WouldBlock)
         }
index 1b7a7f3f323a8822725dbe71299a750156b309ff..7f3c77c97adefdeb10c055ca31d74de7c5d9eaf7 100644 (file)
@@ -233,7 +233,9 @@ fn drop(&mut self) {
     }
 }
 
-static DUMMY: UnsafeCell<()> = UnsafeCell { value: () };
+struct Dummy(UnsafeCell<()>);
+unsafe impl Sync for Dummy {}
+static DUMMY: Dummy = Dummy(UnsafeCell { value: () });
 
 impl StaticRWLock {
     /// 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"]
     pub fn read(&'static self) -> LockResult<RWLockReadGuard<'static, ()>> {
         unsafe { self.lock.read() }
-        RWLockReadGuard::new(self, &DUMMY)
+        RWLockReadGuard::new(self, &DUMMY.0)
     }
 
     /// Attempt to acquire this lock with shared read access.
@@ -255,7 +257,7 @@ pub fn read(&'static self) -> LockResult<RWLockReadGuard<'static, ()>> {
     pub fn try_read(&'static self)
                     -> TryLockResult<RWLockReadGuard<'static, ()>> {
         if unsafe { self.lock.try_read() } {
-            Ok(try!(RWLockReadGuard::new(self, &DUMMY)))
+            Ok(try!(RWLockReadGuard::new(self, &DUMMY.0)))
         } else {
             Err(TryLockError::WouldBlock)
         }
@@ -269,7 +271,7 @@ pub fn try_read(&'static self)
     #[unstable = "may be merged with RWLock in the future"]
     pub fn write(&'static self) -> LockResult<RWLockWriteGuard<'static, ()>> {
         unsafe { self.lock.write() }
-        RWLockWriteGuard::new(self, &DUMMY)
+        RWLockWriteGuard::new(self, &DUMMY.0)
     }
 
     /// Attempt to lock this rwlock with exclusive write access.
@@ -280,7 +282,7 @@ pub fn write(&'static self) -> LockResult<RWLockWriteGuard<'static, ()>> {
     pub fn try_write(&'static self)
                      -> TryLockResult<RWLockWriteGuard<'static, ()>> {
         if unsafe { self.lock.try_write() } {
-            Ok(try!(RWLockWriteGuard::new(self, &DUMMY)))
+            Ok(try!(RWLockWriteGuard::new(self, &DUMMY.0)))
         } else {
             Err(TryLockError::WouldBlock)
         }
index 793e81e1ab5e957d4109cae8025dc1b75becc4de..7a09137a225dca5e21dc6d68994a9c71ee947e63 100644 (file)
@@ -669,7 +669,7 @@ fn lock_nonblocking(&self) {}
     fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
         let ret = Guard {
             fd: self.fd(),
-            guard: self.inner.lock.lock(),
+            guard: self.inner.lock.lock().unwrap(),
         };
         assert!(set_nonblocking(self.fd(), true).is_ok());
         ret
@@ -808,7 +808,7 @@ fn lock_nonblocking(&self) {}
     fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
         let ret = Guard {
             fd: self.fd(),
-            guard: self.inner.lock.lock(),
+            guard: self.inner.lock.lock().unwrap(),
         };
         assert!(set_nonblocking(self.fd(), true).is_ok());
         ret
index f1b078b4e80ab6c46d3f81a23ec980e0b163830b..868b460aa5ed3897e807bc667aaf05babd764949 100644 (file)
@@ -145,7 +145,7 @@ fn lock_nonblocking(&self) {}
     fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
         let ret = Guard {
             fd: self.fd(),
-            guard: unsafe { self.inner.lock.lock() },
+            guard: unsafe { self.inner.lock.lock().unwrap() },
         };
         assert!(set_nonblocking(self.fd(), true).is_ok());
         ret
index d1cb91bcdb377918d881db4076610a4ab03584b2..06259d61fcb8413bfa24b78e6cd36ed7352b7a87 100644 (file)
@@ -131,7 +131,6 @@ pub fn CancelIoEx(hFile: libc::HANDLE,
 
 pub mod compat {
     use intrinsics::{atomic_store_relaxed, transmute};
-    use iter::IteratorExt;
     use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
     use prelude::*;
 
index 15eddd569beec82d9d6171a1977283997d3b203c..3ad439078b9a146767660b3469ca6d93586add35 100644 (file)
@@ -265,8 +265,8 @@ fn prune(root: &Path, dirs: Vec<Path>) -> Vec<Path> {
                 {
                     let filename = os::truncate_utf16_at_nul(&wfd.cFileName);
                     match String::from_utf16(filename) {
-                        Some(filename) => paths.push(Path::new(filename)),
-                        None => {
+                        Ok(filename) => paths.push(Path::new(filename)),
+                        Err(..) => {
                             assert!(libc::FindClose(find_handle) != 0);
                             return Err(IoError {
                                 kind: io::InvalidInput,
index e007b46b261b485819cfe17ed5da4413ae472e00..fa08290a888e9f3a2f86d1dcc303eec09aae1e2e 100644 (file)
@@ -99,8 +99,9 @@ fn FormatMessageW(flags: DWORD,
 
         let msg = String::from_utf16(truncate_utf16_at_nul(&buf));
         match msg {
-            Some(msg) => format!("OS Error {}: {}", errnum, msg),
-            None => format!("OS Error {} (FormatMessageW() returned invalid UTF-16)", errnum),
+            Ok(msg) => format!("OS Error {}: {}", errnum, msg),
+            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
                 // closure returned invalid UTF-16, rather than
                 // 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");
                 res = Some(s)
             }
@@ -169,8 +170,8 @@ pub fn getcwd() -> IoResult<Path> {
     }
 
     match String::from_utf16(truncate_utf16_at_nul(&buf)) {
-        Some(ref cwd) => Ok(Path::new(cwd)),
-        None => Err(IoError {
+        Ok(ref cwd) => Ok(Path::new(cwd)),
+        Err(..) => Err(IoError {
             kind: OtherIoError,
             desc: "GetCurrentDirectoryW returned invalid UTF-16",
             detail: None,
index f793de5bb57ef9f735ea28fe6d989ec9be725bc4..99292b3b44bd1749b3b84ca51e3d1c4d06fdd97c 100644 (file)
@@ -101,8 +101,8 @@ pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
             };
             utf16.truncate(num as uint);
             let utf8 = match String::from_utf16(utf16.as_slice()) {
-                Some(utf8) => utf8.into_bytes(),
-                None => return Err(invalid_encoding()),
+                Ok(utf8) => utf8.into_bytes(),
+                Err(..) => return Err(invalid_encoding()),
             };
             self.utf8 = MemReader::new(utf8);
         }
index ab5ba29665286a25f2d72bb8904ce5cfb55688d8..77836143f27dd8824c8d91c7831d44f8d3b7cb64 100644 (file)
@@ -16,6 +16,5 @@
 //~^ 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
 
 fn main() { }
index 4b058f6fdb343cef21cd68dc531f15edd9352259..95ebb8bd882215524fe298fbe46989142cba7c91 100644 (file)
@@ -17,5 +17,4 @@ fn main() {
     f(x);
     //~^ ERROR `core::kinds::Sync` is not implemented
     //~^^ ERROR `core::kinds::Sync` is not implemented
-    //~^^^ ERROR `core::kinds::Sync` is not implemented
 }