Skip to content

Commit 470ae10

Browse files
committed
Test fixes and rebase conflicts
1 parent cb7599b commit 470ae10

File tree

19 files changed

+38
-41
lines changed

19 files changed

+38
-41
lines changed

src/libarena/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ impl<T> TypedArenaChunk<T> {
412412
let size = calculate_size::<T>(self.capacity);
413413
deallocate(self as *mut TypedArenaChunk<T> as *mut u8, size,
414414
mem::min_align_of::<TypedArenaChunk<T>>());
415-
if next.is_not_null() {
415+
if !next.is_null() {
416416
let capacity = (*next).capacity;
417417
(*next).destroy(capacity);
418418
}

src/libcollections/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ mod prelude {
114114
pub use core::ops::{Drop, Fn, FnMut, FnOnce};
115115
pub use core::option::Option;
116116
pub use core::option::Option::{Some, None};
117-
pub use core::ptr::RawPtr;
117+
pub use core::ptr::PtrExt;
118118
pub use core::result::Result;
119119
pub use core::result::Result::{Ok, Err};
120120

121121
// in core and collections (may differ).
122122
pub use slice::{PartialEqSliceExt, OrdSliceExt};
123123
pub use slice::{AsSlice, SliceExt};
124-
pub use str::{from_str, Str};
124+
pub use str::{from_str, Str, StrExt};
125125

126126
// from other crates.
127127
pub use alloc::boxed::Box;

src/libcollections/str.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1770,15 +1770,9 @@ mod tests {
17701770

17711771
use core::default::Default;
17721772
use core::iter::AdditiveIterator;
1773-
use super::{eq_slice, from_utf8, is_utf8, is_utf16, raw};
1774-
use super::truncate_utf16_at_nul;
1773+
use super::{from_utf8, is_utf8, raw};
17751774
use super::MaybeOwned::{Owned, Slice};
1776-
use std::slice::{AsSlice, SliceExt};
1777-
use string::{String, ToString};
1778-
use vec::Vec;
1779-
use slice::CloneSliceExt;
1780-
1781-
use unicode::char::UnicodeChar;
1775+
use super::Utf8Error;
17821776

17831777
#[test]
17841778
fn test_le() {

src/libcollections/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ mod tests {
10821082
use prelude::*;
10831083
use test::Bencher;
10841084

1085-
use str::{StrExt, Utf8Error};
1085+
use str::Utf8Error;
10861086
use str;
10871087
use super::as_string;
10881088

src/libstd/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ pub unsafe fn from_c_multistring<F>(buf: *const libc::c_char,
538538
mod tests {
539539
use super::*;
540540
use prelude::{spawn, Some, None, Option, FnOnce, ToString, CloneSliceExt};
541-
use prelude::{Clone, RawPtr, Iterator, SliceExt, StrExt};
541+
use prelude::{Clone, PtrExt, Iterator, SliceExt, StrExt};
542542
use ptr;
543543
use thread::Thread;
544544
use libc;

src/libstd/collections/hash/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn test_resize_policy() {
278278
///
279279
/// impl Viking {
280280
/// /// Create a new Viking.
281-
/// pub fn new(name: &str, country: &str) -> Viking {
281+
/// fn new(name: &str, country: &str) -> Viking {
282282
/// Viking { name: name.to_string(), country: country.to_string() }
283283
/// }
284284
/// }

src/libstd/io/process.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ mod tests {
12071207
#[test]
12081208
#[cfg(windows)]
12091209
fn env_map_keys_ci() {
1210+
use c_str::ToCStr;
12101211
use super::EnvKey;
12111212
let mut cmd = Command::new("");
12121213
cmd.env("path", "foo");

src/libstd/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ fn real_args() -> Vec<String> {
731731
let ptr = ptr as *const u16;
732732
let buf = slice::from_raw_buf(&ptr, len);
733733
let opt_s = String::from_utf16(sys::os::truncate_utf16_at_nul(buf));
734-
opt_s.expect("CommandLineToArgvW returned invalid UTF-16")
734+
opt_s.ok().expect("CommandLineToArgvW returned invalid UTF-16")
735735
});
736736

737737
unsafe {

src/libstd/rt/backtrace.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ mod test {
6060
t!("_ZN4$UP$E", "Box");
6161
t!("_ZN8$UP$testE", "Boxtest");
6262
t!("_ZN8$UP$test4foobE", "Boxtest::foob");
63-
t!("_ZN8$x20test4foobE", " test::foob");
63+
t!("_ZN10$u{20}test4foobE", " test::foob");
6464
}
6565

6666
#[test]
6767
fn demangle_many_dollars() {
68-
t!("_ZN12test$x20test4foobE", "test test::foob");
68+
t!("_ZN14test$u{20}test4foobE", "test test::foob");
6969
t!("_ZN12test$UP$test4foobE", "testBoxtest::foob");
7070
}
7171

7272
#[test]
7373
fn demangle_windows() {
7474
t!("ZN4testE", "test");
75-
t!("ZN12test$x20test4foobE", "test test::foob");
75+
t!("ZN14test$u{20}test4foobE", "test test::foob");
7676
t!("ZN12test$UP$test4foobE", "testBoxtest::foob");
7777
}
7878
}

src/libstd/sync/mutex.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,25 @@ impl<T: Send> Drop for Mutex<T> {
234234
}
235235
}
236236

237-
static DUMMY: UnsafeCell<()> = UnsafeCell { value: () };
237+
struct Dummy(UnsafeCell<()>);
238+
unsafe impl Sync for Dummy {}
239+
static DUMMY: Dummy = Dummy(UnsafeCell { value: () });
238240

239241
impl StaticMutex {
240242
/// Acquires this lock, see `Mutex::lock`
241243
#[inline]
242244
#[unstable = "may be merged with Mutex in the future"]
243245
pub fn lock(&'static self) -> LockResult<MutexGuard<()>> {
244246
unsafe { self.lock.lock() }
245-
MutexGuard::new(self, &DUMMY)
247+
MutexGuard::new(self, &DUMMY.0)
246248
}
247249

248250
/// Attempts to grab this lock, see `Mutex::try_lock`
249251
#[inline]
250252
#[unstable = "may be merged with Mutex in the future"]
251253
pub fn try_lock(&'static self) -> TryLockResult<MutexGuard<()>> {
252254
if unsafe { self.lock.try_lock() } {
253-
Ok(try!(MutexGuard::new(self, &DUMMY)))
255+
Ok(try!(MutexGuard::new(self, &DUMMY.0)))
254256
} else {
255257
Err(TryLockError::WouldBlock)
256258
}

src/libstd/sync/rwlock.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ impl<T> Drop for RWLock<T> {
233233
}
234234
}
235235

236-
static DUMMY: UnsafeCell<()> = UnsafeCell { value: () };
236+
struct Dummy(UnsafeCell<()>);
237+
unsafe impl Sync for Dummy {}
238+
static DUMMY: Dummy = Dummy(UnsafeCell { value: () });
237239

238240
impl StaticRWLock {
239241
/// Locks this rwlock with shared read access, blocking the current thread
@@ -244,7 +246,7 @@ impl StaticRWLock {
244246
#[unstable = "may be merged with RWLock in the future"]
245247
pub fn read(&'static self) -> LockResult<RWLockReadGuard<'static, ()>> {
246248
unsafe { self.lock.read() }
247-
RWLockReadGuard::new(self, &DUMMY)
249+
RWLockReadGuard::new(self, &DUMMY.0)
248250
}
249251

250252
/// Attempt to acquire this lock with shared read access.
@@ -255,7 +257,7 @@ impl StaticRWLock {
255257
pub fn try_read(&'static self)
256258
-> TryLockResult<RWLockReadGuard<'static, ()>> {
257259
if unsafe { self.lock.try_read() } {
258-
Ok(try!(RWLockReadGuard::new(self, &DUMMY)))
260+
Ok(try!(RWLockReadGuard::new(self, &DUMMY.0)))
259261
} else {
260262
Err(TryLockError::WouldBlock)
261263
}
@@ -269,7 +271,7 @@ impl StaticRWLock {
269271
#[unstable = "may be merged with RWLock in the future"]
270272
pub fn write(&'static self) -> LockResult<RWLockWriteGuard<'static, ()>> {
271273
unsafe { self.lock.write() }
272-
RWLockWriteGuard::new(self, &DUMMY)
274+
RWLockWriteGuard::new(self, &DUMMY.0)
273275
}
274276

275277
/// Attempt to lock this rwlock with exclusive write access.
@@ -280,7 +282,7 @@ impl StaticRWLock {
280282
pub fn try_write(&'static self)
281283
-> TryLockResult<RWLockWriteGuard<'static, ()>> {
282284
if unsafe { self.lock.try_write() } {
283-
Ok(try!(RWLockWriteGuard::new(self, &DUMMY)))
285+
Ok(try!(RWLockWriteGuard::new(self, &DUMMY.0)))
284286
} else {
285287
Err(TryLockError::WouldBlock)
286288
}

src/libstd/sys/common/net.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl TcpStream {
669669
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
670670
let ret = Guard {
671671
fd: self.fd(),
672-
guard: self.inner.lock.lock(),
672+
guard: self.inner.lock.lock().unwrap(),
673673
};
674674
assert!(set_nonblocking(self.fd(), true).is_ok());
675675
ret
@@ -808,7 +808,7 @@ impl UdpSocket {
808808
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
809809
let ret = Guard {
810810
fd: self.fd(),
811-
guard: self.inner.lock.lock(),
811+
guard: self.inner.lock.lock().unwrap(),
812812
};
813813
assert!(set_nonblocking(self.fd(), true).is_ok());
814814
ret

src/libstd/sys/unix/pipe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl UnixStream {
145145
fn lock_nonblocking<'a>(&'a self) -> Guard<'a> {
146146
let ret = Guard {
147147
fd: self.fd(),
148-
guard: unsafe { self.inner.lock.lock() },
148+
guard: unsafe { self.inner.lock.lock().unwrap() },
149149
};
150150
assert!(set_nonblocking(self.fd(), true).is_ok());
151151
ret

src/libstd/sys/windows/c.rs

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ extern "system" {
131131

132132
pub mod compat {
133133
use intrinsics::{atomic_store_relaxed, transmute};
134-
use iter::IteratorExt;
135134
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
136135
use prelude::*;
137136

src/libstd/sys/windows/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> {
265265
{
266266
let filename = os::truncate_utf16_at_nul(&wfd.cFileName);
267267
match String::from_utf16(filename) {
268-
Some(filename) => paths.push(Path::new(filename)),
269-
None => {
268+
Ok(filename) => paths.push(Path::new(filename)),
269+
Err(..) => {
270270
assert!(libc::FindClose(find_handle) != 0);
271271
return Err(IoError {
272272
kind: io::InvalidInput,

src/libstd/sys/windows/os.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ pub fn error_string(errnum: i32) -> String {
9999

100100
let msg = String::from_utf16(truncate_utf16_at_nul(&buf));
101101
match msg {
102-
Some(msg) => format!("OS Error {}: {}", errnum, msg),
103-
None => format!("OS Error {} (FormatMessageW() returned invalid UTF-16)", errnum),
102+
Ok(msg) => format!("OS Error {}: {}", errnum, msg),
103+
Err(..) => format!("OS Error {} (FormatMessageW() returned \
104+
invalid UTF-16)", errnum),
104105
}
105106
}
106107
}
@@ -147,7 +148,7 @@ pub fn fill_utf16_buf_and_decode(f: |*mut u16, DWORD| -> DWORD) -> Option<String
147148
// We want to explicitly catch the case when the
148149
// closure returned invalid UTF-16, rather than
149150
// set `res` to None and continue.
150-
let s = String::from_utf16(sub)
151+
let s = String::from_utf16(sub).ok()
151152
.expect("fill_utf16_buf_and_decode: closure created invalid UTF-16");
152153
res = Some(s)
153154
}
@@ -169,8 +170,8 @@ pub fn getcwd() -> IoResult<Path> {
169170
}
170171

171172
match String::from_utf16(truncate_utf16_at_nul(&buf)) {
172-
Some(ref cwd) => Ok(Path::new(cwd)),
173-
None => Err(IoError {
173+
Ok(ref cwd) => Ok(Path::new(cwd)),
174+
Err(..) => Err(IoError {
174175
kind: OtherIoError,
175176
desc: "GetCurrentDirectoryW returned invalid UTF-16",
176177
detail: None,

src/libstd/sys/windows/tty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ impl TTY {
101101
};
102102
utf16.truncate(num as uint);
103103
let utf8 = match String::from_utf16(utf16.as_slice()) {
104-
Some(utf8) => utf8.into_bytes(),
105-
None => return Err(invalid_encoding()),
104+
Ok(utf8) => utf8.into_bytes(),
105+
Err(..) => return Err(invalid_encoding()),
106106
};
107107
self.utf8 = MemReader::new(utf8);
108108
}

src/test/compile-fail/issue-7364.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ static boxed: Box<RefCell<int>> = box RefCell::new(0);
1616
//~^ ERROR statics are not allowed to have custom pointers
1717
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
1818
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
19-
//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
2019

2120
fn main() { }

src/test/compile-fail/mut-not-freeze.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ fn main() {
1717
f(x);
1818
//~^ ERROR `core::kinds::Sync` is not implemented
1919
//~^^ ERROR `core::kinds::Sync` is not implemented
20-
//~^^^ ERROR `core::kinds::Sync` is not implemented
2120
}

0 commit comments

Comments
 (0)