From 43bfaa4a336095eb5697fb2df50909fd3c72ed14 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 25 Mar 2015 17:06:52 -0700 Subject: Mass rename uint/int to usize/isize Now that support has been removed, all lingering use cases are renamed. --- src/libstd/sys/common/backtrace.rs | 8 ++--- src/libstd/sys/common/helper_thread.rs | 14 ++++---- src/libstd/sys/common/mod.rs | 12 +++---- src/libstd/sys/common/net.rs | 58 ++++++++++++++++---------------- src/libstd/sys/common/stack.rs | 50 +++++++++++++-------------- src/libstd/sys/common/thread_info.rs | 6 ++-- src/libstd/sys/common/thread_local.rs | 14 ++++---- src/libstd/sys/common/wtf8.rs | 34 +++++++++---------- src/libstd/sys/unix/backtrace.rs | 10 +++--- src/libstd/sys/unix/c.rs | 6 ++-- src/libstd/sys/unix/fs.rs | 18 +++++----- src/libstd/sys/unix/os.rs | 8 ++--- src/libstd/sys/unix/pipe.rs | 4 +-- src/libstd/sys/unix/process.rs | 10 +++--- src/libstd/sys/unix/stack_overflow.rs | 6 ++-- src/libstd/sys/unix/sync.rs | 24 ++++++------- src/libstd/sys/unix/tcp.rs | 2 +- src/libstd/sys/unix/timer.rs | 12 +++---- src/libstd/sys/unix/tty.rs | 6 ++-- src/libstd/sys/windows/backtrace.rs | 4 +-- src/libstd/sys/windows/fs.rs | 18 +++++----- src/libstd/sys/windows/pipe.rs | 18 +++++----- src/libstd/sys/windows/process.rs | 10 +++--- src/libstd/sys/windows/stack_overflow.rs | 6 ++-- src/libstd/sys/windows/tcp.rs | 2 +- src/libstd/sys/windows/thread.rs | 4 +-- src/libstd/sys/windows/thread_local.rs | 10 +++--- src/libstd/sys/windows/timer.rs | 6 ++-- src/libstd/sys/windows/tty.rs | 10 +++--- 29 files changed, 195 insertions(+), 195 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index c42a755b444..cd118b3c9ee 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -14,10 +14,10 @@ use io::prelude::*; use io; #[cfg(target_pointer_width = "64")] -pub const HEX_WIDTH: uint = 18; +pub const HEX_WIDTH: usize = 18; #[cfg(target_pointer_width = "32")] -pub const HEX_WIDTH: uint = 10; +pub const HEX_WIDTH: usize = 10; // All rust symbols are in theory lists of "::"-separated identifiers. Some // assemblers, however, can't handle these characters in symbol names. To get @@ -57,7 +57,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { let mut i = 0; for c in chars.by_ref() { if c.is_numeric() { - i = i * 10 + c as uint - '0' as uint; + i = i * 10 + c as usize - '0' as usize; } else { break } @@ -86,7 +86,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { while rest.char_at(0).is_numeric() { rest = &rest[1..]; } - let i: uint = inner[.. (inner.len() - rest.len())].parse().unwrap(); + let i: usize = inner[.. (inner.len() - rest.len())].parse().unwrap(); inner = &rest[i..]; rest = &rest[..i]; while rest.len() > 0 { diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index 10077dfd1b8..34a58f6c83a 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -51,7 +51,7 @@ pub struct Helper { pub chan: UnsafeCell<*mut Sender>, /// OS handle used to wake up a blocked helper thread - pub signal: UnsafeCell, + pub signal: UnsafeCell, /// Flag if this helper thread has booted and been initialized yet. pub initialized: UnsafeCell, @@ -96,11 +96,11 @@ impl Helper { { unsafe { let _guard = self.lock.lock().unwrap(); - if *self.chan.get() as uint == 0 { + if *self.chan.get() as usize == 0 { let (tx, rx) = channel(); *self.chan.get() = boxed::into_raw(box tx); let (receive, send) = helper_signal::new(); - *self.signal.get() = send as uint; + *self.signal.get() = send as usize; let receive = RaceBox(receive); @@ -114,7 +114,7 @@ impl Helper { let _ = rt::at_exit(move || { self.shutdown() }); *self.initialized.get() = true; - } else if *self.chan.get() as uint == 1 { + } else if *self.chan.get() as usize == 1 { panic!("cannot continue usage after shutdown"); } } @@ -130,8 +130,8 @@ impl Helper { // Must send and *then* signal to ensure that the child receives the // message. Otherwise it could wake up and go to sleep before we // send the message. - assert!(*self.chan.get() as uint != 0); - assert!(*self.chan.get() as uint != 1, + assert!(*self.chan.get() as usize != 0); + assert!(*self.chan.get() as usize != 1, "cannot continue usage after shutdown"); (**self.chan.get()).send(msg).unwrap(); helper_signal::signal(*self.signal.get() as helper_signal::signal); @@ -146,7 +146,7 @@ impl Helper { let mut guard = self.lock.lock().unwrap(); let ptr = *self.chan.get(); - if ptr as uint == 1 { + if ptr as usize == 1 { panic!("cannot continue usage after shutdown"); } // Close the channel by destroying it diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index 29c05b1e0d8..a8769ba99e8 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -56,7 +56,7 @@ pub fn timeout(desc: &'static str) -> IoError { } #[allow(deprecated)] -pub fn short_write(n: uint, desc: &'static str) -> IoError { +pub fn short_write(n: usize, desc: &'static str) -> IoError { IoError { kind: if n == 0 { old_io::TimedOut } else { old_io::ShortWrite(n) }, desc: desc, @@ -84,7 +84,7 @@ pub fn mkerr_libc(ret: T) -> IoResult<()> { } pub fn keep_going(data: &[u8], mut f: F) -> i64 where - F: FnMut(*const u8, uint) -> i64, + F: FnMut(*const u8, usize) -> i64, { let origamt = data.len(); let mut data = data.as_ptr(); @@ -94,8 +94,8 @@ pub fn keep_going(data: &[u8], mut f: F) -> i64 where if ret == 0 { break } else if ret != -1 { - amt -= ret as uint; - data = unsafe { data.offset(ret as int) }; + amt -= ret as usize; + data = unsafe { data.offset(ret as isize) }; } else { return ret; } @@ -134,7 +134,7 @@ pub trait ProcessConfig { fn args(&self) -> &[CString]; fn env(&self) -> Option<&collections::HashMap>; fn cwd(&self) -> Option<&CString>; - fn uid(&self) -> Option; - fn gid(&self) -> Option; + fn uid(&self) -> Option; + fn gid(&self) -> Option; fn detach(&self) -> bool; } diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 96b72b42e54..1a0ee17904a 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -148,7 +148,7 @@ pub fn getsockopt(fd: sock_t, opt: libc::c_int, if ret != 0 { Err(last_net_error()) } else { - assert!(len as uint == mem::size_of::()); + assert!(len as usize == mem::size_of::()); Ok(slot) } } @@ -170,14 +170,14 @@ pub fn sockname(fd: sock_t, return Err(last_net_error()) } } - return sockaddr_to_addr(&storage, len as uint); + return sockaddr_to_addr(&storage, len as usize); } pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, - len: uint) -> IoResult { + len: usize) -> IoResult { match storage.ss_family as libc::c_int { libc::AF_INET => { - assert!(len as uint >= mem::size_of::()); + assert!(len as usize >= mem::size_of::()); let storage: &libc::sockaddr_in = unsafe { mem::transmute(storage) }; @@ -192,7 +192,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, }) } libc::AF_INET6 => { - assert!(len as uint >= mem::size_of::()); + assert!(len as usize >= mem::size_of::()); let storage: &libc::sockaddr_in6 = unsafe { mem::transmute(storage) }; @@ -283,13 +283,13 @@ pub fn get_host_addresses(host: Option<&str>, servname: Option<&str>, while !rp.is_null() { unsafe { let addr = try!(sockaddr_to_addr(mem::transmute((*rp).ai_addr), - (*rp).ai_addrlen as uint)); + (*rp).ai_addrlen as usize)); addrs.push(addrinfo::Info { address: addr, - family: (*rp).ai_family as uint, + family: (*rp).ai_family as usize, socktype: None, protocol: None, - flags: (*rp).ai_flags as uint + flags: (*rp).ai_flags as usize }); rp = (*rp).ai_next as *mut libc::addrinfo; @@ -312,7 +312,7 @@ extern "system" { flags: c_int) -> c_int; } -const NI_MAXHOST: uint = 1025; +const NI_MAXHOST: usize = 1025; pub fn get_address_name(addr: IpAddr) -> Result { let addr = SocketAddr{ip: addr, port: 0}; @@ -393,7 +393,7 @@ pub fn get_address_name(addr: IpAddr) -> Result { // [1] http://twistedmatrix.com/pipermail/twisted-commits/2012-April/034692.html // [2] http://stackoverflow.com/questions/19819198/does-send-msg-dontwait -pub fn read(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoResult where +pub fn read(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoResult where L: FnMut() -> T, R: FnMut(bool) -> libc::c_int, { @@ -431,7 +431,7 @@ pub fn read(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoR match ret { 0 => Err(sys_common::eof()), n if n < 0 => Err(last_net_error()), - n => Ok(n as uint) + n => Ok(n as usize) } } @@ -440,9 +440,9 @@ pub fn write(fd: sock_t, buf: &[u8], write_everything: bool, mut lock: L, - mut write: W) -> IoResult where + mut write: W) -> IoResult where L: FnMut() -> T, - W: FnMut(bool, *const u8, uint) -> i64, + W: FnMut(bool, *const u8, usize) -> i64, { let mut ret = -1; let mut written = 0; @@ -454,7 +454,7 @@ pub fn write(fd: sock_t, }); } else { ret = retry(|| { write(false, buf.as_ptr(), buf.len()) }); - if ret > 0 { written = ret as uint; } + if ret > 0 { written = ret as usize; } } } @@ -483,7 +483,7 @@ pub fn write(fd: sock_t, match retry(|| write(deadline.is_some(), ptr, len)) { -1 if wouldblock() => {} -1 => return Err(last_net_error()), - n => { written += n as uint; } + n => { written += n as usize; } } } ret = 0; @@ -513,8 +513,8 @@ pub fn connect_timeout(fd: sock_t, // If the connection is in progress, then we need to wait for it to // finish (with a timeout). The current strategy for doing this is // to use select() with a timeout. - -1 if os::errno() as int == INPROGRESS as int || - os::errno() as int == WOULDBLOCK as int => { + -1 if os::errno() as isize == INPROGRESS as isize || + os::errno() as isize == WOULDBLOCK as isize => { let mut set: c::fd_set = unsafe { mem::zeroed() }; c::fd_set(&mut set, fd); match await(fd, &mut set, timeout_ms) { @@ -686,7 +686,7 @@ impl TcpStream { nodelay as libc::c_int) } - pub fn set_keepalive(&mut self, seconds: Option) -> IoResult<()> { + pub fn set_keepalive(&mut self, seconds: Option) -> IoResult<()> { let ret = setsockopt(self.fd(), libc::SOL_SOCKET, libc::SO_KEEPALIVE, seconds.is_some() as libc::c_int); match seconds { @@ -696,18 +696,18 @@ impl TcpStream { } #[cfg(any(target_os = "macos", target_os = "ios"))] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, seconds as libc::c_int) } #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, seconds as libc::c_int) } #[cfg(target_os = "openbsd")] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::SO_KEEPALIVE, seconds as libc::c_int) } @@ -716,7 +716,7 @@ impl TcpStream { target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")))] - fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, _seconds: usize) -> IoResult<()> { Ok(()) } @@ -733,7 +733,7 @@ impl TcpStream { ret } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult { let fd = self.fd(); let dolock = || self.lock_nonblocking(); let doread = |nb| unsafe { @@ -749,7 +749,7 @@ impl TcpStream { pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe { + let dowrite = |nb: bool, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::send(fd, buf as *const _, @@ -876,7 +876,7 @@ impl UdpSocket { sockname(self.fd(), libc::getsockname) } - pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)> { + pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(usize, SocketAddr)> { let fd = self.fd(); let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; let storagep = &mut storage as *mut _ as *mut libc::sockaddr; @@ -893,7 +893,7 @@ impl UdpSocket { storagep, &mut addrlen) as libc::c_int })); - Ok((n as uint, sockaddr_to_addr(&storage, addrlen as uint).unwrap())) + Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize).unwrap())) } pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { @@ -903,7 +903,7 @@ impl UdpSocket { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb, buf: *const u8, len: uint| unsafe { + let dowrite = |nb, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::sendto(fd, buf as *const libc::c_void, @@ -939,11 +939,11 @@ impl UdpSocket { } } - pub fn multicast_time_to_live(&mut self, ttl: int) -> IoResult<()> { + pub fn multicast_time_to_live(&mut self, ttl: isize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_IP, libc::IP_MULTICAST_TTL, ttl as libc::c_int) } - pub fn time_to_live(&mut self, ttl: int) -> IoResult<()> { + pub fn time_to_live(&mut self, ttl: isize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_IP, libc::IP_TTL, ttl as libc::c_int) } diff --git a/src/libstd/sys/common/stack.rs b/src/libstd/sys/common/stack.rs index 8c428275ccf..8dc3407db77 100644 --- a/src/libstd/sys/common/stack.rs +++ b/src/libstd/sys/common/stack.rs @@ -46,7 +46,7 @@ // corresponding prolog, decision was taken to disable segmented // stack support on iOS. -pub const RED_ZONE: uint = 20 * 1024; +pub const RED_ZONE: usize = 20 * 1024; /// This function is invoked from rust's current __morestack function. Segmented /// stacks are currently not enabled as segmented stacks, but rather one giant @@ -117,7 +117,7 @@ extern fn stack_exhausted() { // On all other platforms both variants behave identically. #[inline(always)] -pub unsafe fn record_os_managed_stack_bounds(stack_lo: uint, _stack_hi: uint) { +pub unsafe fn record_os_managed_stack_bounds(stack_lo: usize, _stack_hi: usize) { record_sp_limit(stack_lo + RED_ZONE); } @@ -136,31 +136,31 @@ pub unsafe fn record_os_managed_stack_bounds(stack_lo: uint, _stack_hi: uint) { /// would be unfortunate for the functions themselves to trigger a morestack /// invocation (if they were an actual function call). #[inline(always)] -pub unsafe fn record_sp_limit(limit: uint) { +pub unsafe fn record_sp_limit(limit: usize) { return target_record_sp_limit(limit); // x86-64 #[cfg(all(target_arch = "x86_64", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $$0x60+90*8, %rsi movq $0, %gs:(%rsi)" :: "r"(limit) : "rsi" : "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:112" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile") } @@ -168,18 +168,18 @@ pub unsafe fn record_sp_limit(limit: uint) { #[cfg(all(target_arch = "x86", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movl $$0x48+90*4, %eax movl $0, %gs:(%eax)" :: "r"(limit) : "eax" : "volatile") } #[cfg(all(target_arch = "x86", any(target_os = "linux", target_os = "freebsd")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movl $0, %gs:48" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } // mips, arm - Some brave soul can port these to inline asm, but it's over @@ -188,7 +188,7 @@ pub unsafe fn record_sp_limit(limit: uint) { target_arch = "mipsel", all(target_arch = "arm", not(target_os = "ios"))))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { use libc::c_void; return record_sp_limit(limit as *const c_void); extern { @@ -205,7 +205,7 @@ pub unsafe fn record_sp_limit(limit: uint) { all(target_arch = "arm", target_os = "ios"), target_os = "bitrig", target_os = "openbsd"))] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } } @@ -218,38 +218,38 @@ pub unsafe fn record_sp_limit(limit: uint) { /// As with the setter, this function does not have a __morestack header and can /// therefore be called in a "we're out of stack" situation. #[inline(always)] -pub unsafe fn get_sp_limit() -> uint { +pub unsafe fn get_sp_limit() -> usize { return target_get_sp_limit(); // x86-64 #[cfg(all(target_arch = "x86_64", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq $$0x60+90*8, %rsi movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { return 1024; } #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile"); return limit; @@ -259,7 +259,7 @@ pub unsafe fn get_sp_limit() -> uint { #[cfg(all(target_arch = "x86", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movl $$0x48+90*4, %eax movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile"); @@ -268,13 +268,13 @@ pub unsafe fn get_sp_limit() -> uint { #[cfg(all(target_arch = "x86", any(target_os = "linux", target_os = "freebsd")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { return 1024; } @@ -284,9 +284,9 @@ pub unsafe fn get_sp_limit() -> uint { target_arch = "mipsel", all(target_arch = "arm", not(target_os = "ios"))))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { use libc::c_void; - return get_sp_limit() as uint; + return get_sp_limit() as usize; extern { fn get_sp_limit() -> *const c_void; } @@ -305,7 +305,7 @@ pub unsafe fn get_sp_limit() -> uint { target_os = "bitrig", target_os = "openbsd"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { 1024 } } diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs index 90526b8f4f3..22cb5943371 100644 --- a/src/libstd/sys/common/thread_info.rs +++ b/src/libstd/sys/common/thread_info.rs @@ -18,7 +18,7 @@ use thread::Thread; use thread::LocalKeyState; struct ThreadInfo { - stack_guard: uint, + stack_guard: usize, thread: Thread, } @@ -47,11 +47,11 @@ pub fn current_thread() -> Thread { ThreadInfo::with(|info| info.thread.clone()) } -pub fn stack_guard() -> uint { +pub fn stack_guard() -> usize { ThreadInfo::with(|info| info.stack_guard) } -pub fn set(stack_guard: uint, thread: Thread) { +pub fn set(stack_guard: usize, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ stack_guard: stack_guard, diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs index 5e2a138fa63..5995d7ac10f 100644 --- a/src/libstd/sys/common/thread_local.rs +++ b/src/libstd/sys/common/thread_local.rs @@ -178,7 +178,7 @@ impl StaticKey { } } - unsafe fn lazy_init(&self) -> uint { + unsafe fn lazy_init(&self) -> usize { // POSIX allows the key created here to be 0, but the compare_and_swap // below relies on using 0 as a sentinel value to check who won the // race to set the shared TLS key. As far as I know, there is no @@ -197,9 +197,9 @@ impl StaticKey { key2 }; assert!(key != 0); - match self.inner.key.compare_and_swap(0, key as uint, Ordering::SeqCst) { + match self.inner.key.compare_and_swap(0, key as usize, Ordering::SeqCst) { // The CAS succeeded, so we've created the actual key - 0 => key as uint, + 0 => key as usize, // If someone beat us to the punch, use their key instead n => { imp::destroy(key); n } } @@ -261,8 +261,8 @@ mod tests { assert!(k2.get().is_null()); k1.set(1 as *mut _); k2.set(2 as *mut _); - assert_eq!(k1.get() as uint, 1); - assert_eq!(k2.get() as uint, 2); + assert_eq!(k1.get() as usize, 1); + assert_eq!(k2.get() as usize, 2); } #[test] @@ -275,8 +275,8 @@ mod tests { assert!(K2.get().is_null()); K1.set(1 as *mut _); K2.set(2 as *mut _); - assert_eq!(K1.get() as uint, 1); - assert_eq!(K2.get() as uint, 2); + assert_eq!(K1.get() as usize, 1); + assert_eq!(K2.get() as usize, 2); } } } diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 9f3dae34c7a..7efe7d96b71 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -158,7 +158,7 @@ impl Wtf8Buf { /// Create an new, empty WTF-8 string with pre-allocated capacity for `n` bytes. #[inline] - pub fn with_capacity(n: uint) -> Wtf8Buf { + pub fn with_capacity(n: usize) -> Wtf8Buf { Wtf8Buf { bytes: Vec::with_capacity(n) } } @@ -214,7 +214,7 @@ impl Wtf8Buf { // Attempt to not use an intermediate buffer by just pushing bytes // directly onto this string. let slice = slice::from_raw_parts_mut( - self.bytes.as_mut_ptr().offset(cur_len as int), + self.bytes.as_mut_ptr().offset(cur_len as isize), 4 ); let used = encode_utf8_raw(code_point.value, mem::transmute(slice)) @@ -234,15 +234,15 @@ impl Wtf8Buf { /// /// # Panics /// - /// Panics if the new capacity overflows `uint`. + /// Panics if the new capacity overflows `usize`. #[inline] - pub fn reserve(&mut self, additional: uint) { + pub fn reserve(&mut self, additional: usize) { self.bytes.reserve(additional) } /// Returns the number of bytes that this string buffer can hold without reallocating. #[inline] - pub fn capacity(&self) -> uint { + pub fn capacity(&self) -> usize { self.bytes.capacity() } @@ -313,7 +313,7 @@ impl Wtf8Buf { /// Panics if `new_len` > current length, /// or if `new_len` is not a code point boundary. #[inline] - pub fn truncate(&mut self, new_len: uint) { + pub fn truncate(&mut self, new_len: usize) { assert!(is_code_point_boundary(self, new_len)); self.bytes.truncate(new_len) } @@ -463,7 +463,7 @@ impl Wtf8 { /// Return the length, in WTF-8 bytes. #[inline] - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.bytes.len() } @@ -474,7 +474,7 @@ impl Wtf8 { /// /// Panics if `position` is beyond the end of the string. #[inline] - pub fn ascii_byte_at(&self, position: uint) -> u8 { + pub fn ascii_byte_at(&self, position: usize) -> u8 { match self.bytes[position] { ascii_byte @ 0x00 ... 0x7F => ascii_byte, _ => 0xFF @@ -488,7 +488,7 @@ impl Wtf8 { /// Panics if `position` is not at a code point boundary, /// or is beyond the end of the string. #[inline] - pub fn code_point_at(&self, position: uint) -> CodePoint { + pub fn code_point_at(&self, position: usize) -> CodePoint { let (code_point, _) = self.code_point_range_at(position); code_point } @@ -501,7 +501,7 @@ impl Wtf8 { /// Panics if `position` is not at a code point boundary, /// or is beyond the end of the string. #[inline] - pub fn code_point_range_at(&self, position: uint) -> (CodePoint, uint) { + pub fn code_point_range_at(&self, position: usize) -> (CodePoint, usize) { let (c, n) = char_range_at_raw(&self.bytes, position); (CodePoint { value: c }, n) } @@ -570,7 +570,7 @@ impl Wtf8 { } #[inline] - fn next_surrogate(&self, mut pos: uint) -> Option<(uint, u16)> { + fn next_surrogate(&self, mut pos: usize) -> Option<(usize, u16)> { let mut iter = self.bytes[pos..].iter(); loop { let b = match iter.next() { @@ -792,7 +792,7 @@ fn decode_surrogate_pair(lead: u16, trail: u16) -> char { /// Copied from core::str::StrPrelude::is_char_boundary #[inline] -pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { +pub fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool { if index == slice.len() { return true; } match slice.bytes.get(index) { None => false, @@ -802,17 +802,17 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { /// Copied from core::str::raw::slice_unchecked #[inline] -pub unsafe fn slice_unchecked(s: &Wtf8, begin: uint, end: uint) -> &Wtf8 { +pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { // memory layout of an &[u8] and &Wtf8 are the same mem::transmute(slice::from_raw_parts( - s.bytes.as_ptr().offset(begin as int), + s.bytes.as_ptr().offset(begin as isize), end - begin )) } /// Copied from core::str::raw::slice_error_fail #[inline(never)] -pub fn slice_error_fail(s: &Wtf8, begin: uint, end: uint) -> ! { +pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! { assert!(begin <= end); panic!("index {} and/or {} in `{:?}` do not lie on character boundary", begin, end, s); @@ -835,7 +835,7 @@ impl<'a> Iterator for Wtf8CodePoints<'a> { } #[inline] - fn size_hint(&self) -> (uint, Option) { + fn size_hint(&self) -> (usize, Option) { let (len, _) = self.bytes.size_hint(); (len.saturating_add(3) / 4, Some(len)) } @@ -869,7 +869,7 @@ impl<'a> Iterator for EncodeWide<'a> { } #[inline] - fn size_hint(&self) -> (uint, Option) { + fn size_hint(&self) -> (usize, Option) { let (low, high) = self.code_points.size_hint(); // every code point gets either one u16 or two u16, // so this iterator is between 1 or 2 times as diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index 7db64cfb936..b46d390826c 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -128,7 +128,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { // skipping the first one as it is write itself let iter = (1..cnt).map(|i| { - print(w, i as int, buf[i], buf[i]) + print(w, i as isize, buf[i], buf[i]) }); result::fold(iter, (), |_, _| ()) } @@ -138,7 +138,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { // tracing pub fn write(w: &mut Write) -> io::Result<()> { struct Context<'a> { - idx: int, + idx: isize, writer: &'a mut (Write+'a), last_error: Option, } @@ -222,7 +222,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { } #[cfg(any(target_os = "macos", target_os = "ios"))] -fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, _symaddr: *mut libc::c_void) -> io::Result<()> { use intrinsics; #[repr(C)] @@ -248,7 +248,7 @@ fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, } #[cfg(not(any(target_os = "macos", target_os = "ios")))] -fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, symaddr: *mut libc::c_void) -> io::Result<()> { use env; use ffi::AsOsStr; @@ -441,7 +441,7 @@ fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, } // Finally, after all that work above, we can emit a symbol. -fn output(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn output(w: &mut Write, idx: isize, addr: *mut libc::c_void, s: Option<&[u8]>) -> io::Result<()> { try!(write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH)); match s.and_then(|s| str::from_utf8(s).ok()) { diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 4e9f9c80a18..2514d4bf4a3 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -167,7 +167,7 @@ extern { #[cfg(any(target_os = "macos", target_os = "ios"))] mod select { - pub const FD_SETSIZE: uint = 1024; + pub const FD_SETSIZE: usize = 1024; #[repr(C)] pub struct fd_set { @@ -175,7 +175,7 @@ mod select { } pub fn fd_set(set: &mut fd_set, fd: i32) { - set.fds_bits[(fd / 32) as uint] |= 1 << ((fd % 32) as uint); + set.fds_bits[(fd / 32) as usize] |= 1 << ((fd % 32) as usize); } } @@ -198,7 +198,7 @@ mod select { } pub fn fd_set(set: &mut fd_set, fd: i32) { - let fd = fd as uint; + let fd = fd as usize; set.fds_bits[fd / usize::BITS as usize] |= 1 << (fd % usize::BITS as usize); } } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 327ff3953aa..2569653811f 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -42,7 +42,7 @@ impl FileDesc { FileDesc { fd: fd, close_on_drop: close_on_drop } } - pub fn read(&self, buf: &mut [u8]) -> IoResult { + pub fn read(&self, buf: &mut [u8]) -> IoResult { let ret = retry(|| unsafe { libc::read(self.fd(), buf.as_mut_ptr() as *mut libc::c_void, @@ -53,7 +53,7 @@ impl FileDesc { } else if ret < 0 { Err(super::last_error()) } else { - Ok(ret as uint) + Ok(ret as usize) } } pub fn write(&self, buf: &[u8]) -> IoResult<()> { @@ -181,7 +181,7 @@ pub fn open(path: &Path, fm: FileMode, fa: FileAccess) -> IoResult { } } -pub fn mkdir(p: &Path, mode: uint) -> IoResult<()> { +pub fn mkdir(p: &Path, mode: usize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) }) } @@ -204,13 +204,13 @@ pub fn readdir(p: &Path) -> IoResult> { } let size = unsafe { rust_dirent_t_size() }; - let mut buf = Vec::::with_capacity(size as uint); + let mut buf = Vec::::with_capacity(size as usize); let ptr = buf.as_mut_ptr() as *mut dirent_t; let p = try!(CString::new(p.as_vec())); let dir_ptr = unsafe {opendir(p.as_ptr())}; - if dir_ptr as uint != 0 { + if dir_ptr as usize != 0 { let mut paths = vec!(); let mut entry_ptr = ptr::null_mut(); while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } { @@ -239,7 +239,7 @@ pub fn rename(old: &Path, new: &Path) -> IoResult<()> { }) } -pub fn chmod(p: &Path, mode: uint) -> IoResult<()> { +pub fn chmod(p: &Path, mode: usize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(retry(|| unsafe { libc::chmod(p.as_ptr(), mode as libc::mode_t) @@ -251,7 +251,7 @@ pub fn rmdir(p: &Path) -> IoResult<()> { mkerr_libc(unsafe { libc::rmdir(p.as_ptr()) }) } -pub fn chown(p: &Path, uid: int, gid: int) -> IoResult<()> { +pub fn chown(p: &Path, uid: isize, gid: isize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(retry(|| unsafe { libc::chown(p.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) @@ -265,7 +265,7 @@ pub fn readlink(p: &Path) -> IoResult { if len == -1 { len = 1024; // FIXME: read PATH_MAX from C ffi? } - let mut buf: Vec = Vec::with_capacity(len as uint); + let mut buf: Vec = Vec::with_capacity(len as usize); match unsafe { libc::readlink(p, buf.as_ptr() as *mut libc::c_char, len as libc::size_t) as libc::c_int @@ -273,7 +273,7 @@ pub fn readlink(p: &Path) -> IoResult { -1 => Err(super::last_error()), n => { assert!(n > 0); - unsafe { buf.set_len(n as uint); } + unsafe { buf.set_len(n as usize); } Ok(Path::new(buf)) } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index c73d30d543a..724156d81d8 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -199,13 +199,13 @@ pub fn current_exe() -> io::Result { 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } - let mut v: Vec = Vec::with_capacity(sz as uint); + let mut v: Vec = Vec::with_capacity(sz as usize); let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, v.as_mut_ptr() as *mut libc::c_void, &mut sz, ptr::null_mut(), 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } - v.set_len(sz as uint - 1); // chop off trailing NUL + v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } } @@ -249,10 +249,10 @@ pub fn current_exe() -> io::Result { let mut sz: u32 = 0; _NSGetExecutablePath(ptr::null_mut(), &mut sz); if sz == 0 { return Err(io::Error::last_os_error()); } - let mut v: Vec = Vec::with_capacity(sz as uint); + let mut v: Vec = Vec::with_capacity(sz as usize); let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); if err != 0 { return Err(io::Error::last_os_error()); } - v.set_len(sz as uint - 1); // chop off trailing NUL + v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } } diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index daa981720f6..f0071295bf2 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -151,7 +151,7 @@ impl UnixStream { ret } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult { let fd = self.fd(); let dolock = || self.lock_nonblocking(); let doread = |nb| unsafe { @@ -167,7 +167,7 @@ impl UnixStream { pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe { + let dowrite = |nb: bool, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::send(fd, buf as *const _, diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index df0e8de3ff1..0d35ace185d 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -49,11 +49,11 @@ impl Process { self.pid } - pub unsafe fn kill(&self, signal: int) -> IoResult<()> { + pub unsafe fn kill(&self, signal: isize) -> IoResult<()> { Process::killpid(self.pid, signal) } - pub unsafe fn killpid(pid: pid_t, signal: int) -> IoResult<()> { + pub unsafe fn killpid(pid: pid_t, signal: isize) -> IoResult<()> { let r = libc::funcs::posix88::signal::kill(pid, signal as c_int); mkerr_libc(r) } @@ -454,7 +454,7 @@ impl Process { // with process timeouts, but libgreen should get there first // (currently libuv doesn't handle old signal handlers). if drain(read_fd) { - let i: uint = unsafe { mem::transmute(old.sa_handler) }; + let i: usize = unsafe { mem::transmute(old.sa_handler) }; if i != 0 { assert!(old.sa_flags & c::SA_SIGINFO == 0); (old.sa_handler)(c::SIGCHLD); @@ -618,8 +618,8 @@ fn translate_status(status: c_int) -> ProcessExit { } if imp::WIFEXITED(status) { - ExitStatus(imp::WEXITSTATUS(status) as int) + ExitStatus(imp::WEXITSTATUS(status) as isize) } else { - ExitSignal(imp::WTERMSIG(status) as int) + ExitSignal(imp::WTERMSIG(status) as isize) } } diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 35706682047..6887095c53a 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -60,7 +60,7 @@ mod imp { // This is initialized in init() and only read from after - static mut PAGE_SIZE: uint = 0; + static mut PAGE_SIZE: usize = 0; #[no_stack_check] unsafe extern fn signal_handler(signum: libc::c_int, @@ -82,7 +82,7 @@ mod imp { stack::record_sp_limit(0); let guard = thread_info::stack_guard(); - let addr = (*info).si_addr as uint; + let addr = (*info).si_addr as usize; if guard == 0 || addr < guard - PAGE_SIZE || addr >= guard { term(signum); @@ -101,7 +101,7 @@ mod imp { panic!("failed to get page size"); } - PAGE_SIZE = psize as uint; + PAGE_SIZE = psize as usize; let mut action: sigaction = mem::zeroed(); action.sa_flags = SA_SIGINFO | SA_ONSTACK; diff --git a/src/libstd/sys/unix/sync.rs b/src/libstd/sys/unix/sync.rs index c7d704922cb..3c05fd602be 100644 --- a/src/libstd/sys/unix/sync.rs +++ b/src/libstd/sys/unix/sync.rs @@ -66,24 +66,24 @@ mod os { #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_MUTEX_SIZE__: uint = 56; + const __PTHREAD_MUTEX_SIZE__: usize = 56; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_MUTEX_SIZE__: uint = 40; + const __PTHREAD_MUTEX_SIZE__: usize = 40; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_COND_SIZE__: uint = 40; + const __PTHREAD_COND_SIZE__: usize = 40; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_COND_SIZE__: uint = 24; + const __PTHREAD_COND_SIZE__: usize = 24; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_RWLOCK_SIZE__: uint = 192; + const __PTHREAD_RWLOCK_SIZE__: usize = 192; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_RWLOCK_SIZE__: uint = 124; + const __PTHREAD_RWLOCK_SIZE__: usize = 124; const _PTHREAD_MUTEX_SIG_INIT: libc::c_long = 0x32AAABA7; const _PTHREAD_COND_SIG_INIT: libc::c_long = 0x3CB0B1BB; @@ -125,15 +125,15 @@ mod os { // minus 8 because we have an 'align' field #[cfg(target_arch = "x86_64")] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 40 - 8; #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 24 - 8; #[cfg(target_arch = "aarch64")] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 48 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 48 - 8; #[cfg(any(target_arch = "x86_64", target_arch = "x86", @@ -142,18 +142,18 @@ mod os { target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; + const __SIZEOF_PTHREAD_COND_T: usize = 48 - 8; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __SIZEOF_PTHREAD_RWLOCK_T: uint = 56 - 8; + const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56 - 8; #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_RWLOCK_T: uint = 32 - 8; + const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 - 8; #[repr(C)] pub struct pthread_mutex_t { diff --git a/src/libstd/sys/unix/tcp.rs b/src/libstd/sys/unix/tcp.rs index 2a6994824c7..a9f2198208b 100644 --- a/src/libstd/sys/unix/tcp.rs +++ b/src/libstd/sys/unix/tcp.rs @@ -64,7 +64,7 @@ impl TcpListener { pub fn fd(&self) -> sock_t { self.inner.fd() } - pub fn listen(self, backlog: int) -> IoResult { + pub fn listen(self, backlog: isize) -> IoResult { match unsafe { libc::listen(self.fd(), backlog as libc::c_int) } { -1 => Err(last_net_error()), _ => { diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index b6d2aca9a52..d9a162302fc 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -69,7 +69,7 @@ pub trait Callback { } pub struct Timer { - id: uint, + id: usize, inner: Option>, } @@ -78,7 +78,7 @@ pub struct Inner { interval: u64, repeat: bool, target: u64, - id: uint, + id: usize, } pub enum Req { @@ -87,7 +87,7 @@ pub enum Req { // Remove a timer based on its id and then send it back on the channel // provided - RemoveTimer(uint, Sender>), + RemoveTimer(usize, Sender>), } // returns the current time (in milliseconds) @@ -121,7 +121,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { // signals the first requests in the queue, possible re-enqueueing it. fn signal(active: &mut Vec>, - dead: &mut Vec<(uint, Box)>) { + dead: &mut Vec<(usize, Box)>) { if active.is_empty() { return } let mut timer = active.remove(0); @@ -216,7 +216,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { impl Timer { pub fn new() -> IoResult { - // See notes above regarding using int return value + // See notes above regarding using isize return value // instead of () HELPER.boot(|| {}, helper); @@ -244,7 +244,7 @@ impl Timer { tv_nsec: ((ms % 1000) * 1000000) as libc::c_long, }; while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) } != 0 { - if os::errno() as int != libc::EINTR as int { + if os::errno() as isize != libc::EINTR as isize { panic!("failed to sleep, but not because of EINTR?"); } } diff --git a/src/libstd/sys/unix/tty.rs b/src/libstd/sys/unix/tty.rs index e4973a8f9f3..2f6fd713bfb 100644 --- a/src/libstd/sys/unix/tty.rs +++ b/src/libstd/sys/unix/tty.rs @@ -46,7 +46,7 @@ impl TTY { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult { self.fd.read(buf) } pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { @@ -56,7 +56,7 @@ impl TTY { Err(sys_common::unimpl()) } - pub fn get_winsize(&mut self) -> IoResult<(int, int)> { + pub fn get_winsize(&mut self) -> IoResult<(isize, isize)> { unsafe { #[repr(C)] struct winsize { @@ -74,7 +74,7 @@ impl TTY { detail: None, }) } else { - Ok((size.ws_col as int, size.ws_row as int)) + Ok((size.ws_col as isize, size.ws_row as isize)) } } } diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index ffa4b37b487..509205a20b1 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -63,7 +63,7 @@ type StackWalk64Fn = *mut libc::c_void, *mut libc::c_void, *mut libc::c_void, *mut libc::c_void) -> libc::BOOL; -const MAX_SYM_NAME: uint = 2000; +const MAX_SYM_NAME: usize = 2000; const IMAGE_FILE_MACHINE_I386: libc::DWORD = 0x014c; const IMAGE_FILE_MACHINE_IA64: libc::DWORD = 0x0200; const IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664; @@ -138,7 +138,7 @@ struct KDHELP64 { mod arch { use libc; - const MAXIMUM_SUPPORTED_EXTENSION: uint = 512; + const MAXIMUM_SUPPORTED_EXTENSION: usize = 512; #[repr(C)] pub struct CONTEXT { diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index e7a01478908..3330130c770 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -42,7 +42,7 @@ impl FileDesc { FileDesc { fd: fd, close_on_drop: close_on_drop } } - pub fn read(&self, buf: &mut [u8]) -> IoResult { + pub fn read(&self, buf: &mut [u8]) -> IoResult { let mut read = 0; let ret = unsafe { libc::ReadFile(self.handle(), buf.as_ptr() as libc::LPVOID, @@ -50,7 +50,7 @@ impl FileDesc { ptr::null_mut()) }; if ret != 0 { - Ok(read as uint) + Ok(read as usize) } else { Err(super::last_error()) } @@ -67,8 +67,8 @@ impl FileDesc { ptr::null_mut()) }; if ret != 0 { - remaining -= amt as uint; - cur = unsafe { cur.offset(amt as int) }; + remaining -= amt as usize; + cur = unsafe { cur.offset(amt as isize) }; } else { return Err(super::last_error()) } @@ -234,7 +234,7 @@ pub fn open(path: &Path, fm: FileMode, fa: FileAccess) -> IoResult { } } -pub fn mkdir(p: &Path, _mode: uint) -> IoResult<()> { +pub fn mkdir(p: &Path, _mode: usize) -> IoResult<()> { let p = try!(to_utf16(p)); super::mkerr_winbool(unsafe { // FIXME: turn mode into something useful? #2623 @@ -308,11 +308,11 @@ pub fn unlink(p: &Path) -> IoResult<()> { }; if stat.perm.intersects(old_io::USER_WRITE) { return Err(e) } - match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as uint) { + match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as usize) { Ok(()) => do_unlink(&p_utf16), Err(..) => { // Try to put it back as we found it - let _ = chmod(p, stat.perm.bits() as uint); + let _ = chmod(p, stat.perm.bits() as usize); Err(e) } } @@ -331,7 +331,7 @@ pub fn rename(old: &Path, new: &Path) -> IoResult<()> { }) } -pub fn chmod(p: &Path, mode: uint) -> IoResult<()> { +pub fn chmod(p: &Path, mode: usize) -> IoResult<()> { let p = try!(to_utf16(p)); mkerr_libc(unsafe { libc::wchmod(p.as_ptr(), mode as libc::c_int) @@ -343,7 +343,7 @@ pub fn rmdir(p: &Path) -> IoResult<()> { super::mkerr_winbool(unsafe { libc::RemoveDirectoryW(p.as_ptr()) }) } -pub fn chown(_p: &Path, _uid: int, _gid: int) -> IoResult<()> { +pub fn chown(_p: &Path, _uid: isize, _gid: isize) -> IoResult<()> { // libuv has this as a no-op, so seems like this should as well? Ok(()) } diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 17fdd6755c6..064c003bd15 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -115,7 +115,7 @@ impl Event { initial_state as libc::BOOL, ptr::null()) }; - if event as uint == 0 { + if event as usize == 0 { Err(super::last_error()) } else { Ok(Event(event)) @@ -181,7 +181,7 @@ unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE { } pub fn await(handle: libc::HANDLE, deadline: u64, - events: &[libc::HANDLE]) -> IoResult { + events: &[libc::HANDLE]) -> IoResult { use libc::consts::os::extra::{WAIT_FAILED, WAIT_TIMEOUT, WAIT_OBJECT_0}; // If we've got a timeout, use WaitForSingleObject in tandem with CancelIo @@ -204,7 +204,7 @@ pub fn await(handle: libc::HANDLE, deadline: u64, let _ = c::CancelIo(handle); Err(sys_common::timeout("operation timed out")) }, - n => Ok((n - WAIT_OBJECT_0) as uint) + n => Ok((n - WAIT_OBJECT_0) as usize) } } @@ -314,7 +314,7 @@ impl UnixStream { // `WaitNamedPipe` function, and this is indicated with an error // code of ERROR_PIPE_BUSY. let code = unsafe { libc::GetLastError() }; - if code as int != libc::ERROR_PIPE_BUSY as int { + if code as isize != libc::ERROR_PIPE_BUSY as isize { return Err(super::last_error()) } @@ -362,7 +362,7 @@ impl UnixStream { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult { if self.read.is_none() { self.read = Some(try!(Event::new(true, false))); } @@ -390,7 +390,7 @@ impl UnixStream { &mut bytes_read, &mut overlapped) }; - if ret != 0 { return Ok(bytes_read as uint) } + if ret != 0 { return Ok(bytes_read as usize) } // If our errno doesn't say that the I/O is pending, then we hit some // legitimate error and return immediately. @@ -418,7 +418,7 @@ impl UnixStream { }; // If we succeeded, or we failed for some reason other than // CancelIoEx, return immediately - if ret != 0 { return Ok(bytes_read as uint) } + if ret != 0 { return Ok(bytes_read as usize) } if os::errno() != libc::ERROR_OPERATION_ABORTED as i32 { return Err(super::last_error()) } @@ -487,7 +487,7 @@ impl UnixStream { return Err(super::last_error()) } if !wait_succeeded.is_ok() { - let amt = offset + bytes_written as uint; + let amt = offset + bytes_written as usize; return if amt > 0 { Err(IoError { kind: old_io::ShortWrite(amt), @@ -504,7 +504,7 @@ impl UnixStream { continue // retry } } - offset += bytes_written as uint; + offset += bytes_written as usize; } Ok(()) } diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index e08a6e6b3cd..297f6e173ab 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -63,11 +63,11 @@ impl Process { self.pid } - pub unsafe fn kill(&self, signal: int) -> IoResult<()> { + pub unsafe fn kill(&self, signal: isize) -> IoResult<()> { Process::killpid(self.pid, signal) } - pub unsafe fn killpid(pid: pid_t, signal: int) -> IoResult<()> { + pub unsafe fn killpid(pid: pid_t, signal: isize) -> IoResult<()> { let handle = libc::OpenProcess(libc::PROCESS_TERMINATE | libc::PROCESS_QUERY_INFORMATION, libc::FALSE, pid as libc::DWORD); @@ -309,7 +309,7 @@ impl Process { } if status != STILL_ACTIVE { assert!(CloseHandle(process) != 0); - return Ok(ExitStatus(status as int)); + return Ok(ExitStatus(status as isize)); } let interval = if deadline == 0 { INFINITE @@ -394,7 +394,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String { } } - fn append_char_at(cmd: &mut String, arg: &[char], i: uint) { + fn append_char_at(cmd: &mut String, arg: &[char], i: usize) { match arg[i] { '"' => { // Escape quotes. @@ -415,7 +415,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String { } } - fn backslash_run_ends_in_quote(s: &[char], mut i: uint) -> bool { + fn backslash_run_ends_in_quote(s: &[char], mut i: usize) -> bool { while i < s.len() && s[i] == '\\' { i += 1; } diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index b0410701ee1..79b7de4f341 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -31,7 +31,7 @@ impl Drop for Handler { } // This is initialized in init() and only read from after -static mut PAGE_SIZE: uint = 0; +static mut PAGE_SIZE: usize = 0; #[no_stack_check] extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG { @@ -56,7 +56,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> L pub unsafe fn init() { let mut info = mem::zeroed(); libc::GetSystemInfo(&mut info); - PAGE_SIZE = info.dwPageSize as uint; + PAGE_SIZE = info.dwPageSize as usize; if AddVectoredExceptionHandler(0, vectored_handler) == ptr::null_mut() { panic!("failed to install exception handler"); @@ -96,7 +96,7 @@ pub type PVECTORED_EXCEPTION_HANDLER = extern "system" pub type ULONG = libc::c_ulong; const EXCEPTION_CONTINUE_SEARCH: LONG = 0; -const EXCEPTION_MAXIMUM_PARAMETERS: uint = 15; +const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15; const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd; extern "system" { diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index 6e46bf97d1b..2ac8ac10aa9 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -77,7 +77,7 @@ impl TcpListener { pub fn socket(&self) -> sock_t { self.sock } - pub fn listen(self, backlog: int) -> IoResult { + pub fn listen(self, backlog: isize) -> IoResult { match unsafe { libc::listen(self.socket(), backlog as libc::c_int) } { -1 => Err(last_net_error()), diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index d1d4ad90081..98e4a737c7b 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -25,8 +25,8 @@ use time::Duration; pub type rust_thread = HANDLE; pub mod guard { - pub unsafe fn main() -> uint { 0 } - pub unsafe fn current() -> uint { 0 } + pub unsafe fn main() -> usize { 0 } + pub unsafe fn current() -> usize { 0 } pub unsafe fn init() {} } diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index c908c791247..cbabab8acb7 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -139,7 +139,7 @@ unsafe fn init_dtors() { let dtors = DTORS; DTORS = 1 as *mut _; Box::from_raw(dtors); - assert!(DTORS as uint == 1); // can't re-init after destructing + assert!(DTORS as usize == 1); // can't re-init after destructing DTOR_LOCK.unlock(); }); if res.is_ok() { @@ -152,8 +152,8 @@ unsafe fn init_dtors() { unsafe fn register_dtor(key: Key, dtor: Dtor) { DTOR_LOCK.lock(); init_dtors(); - assert!(DTORS as uint != 0); - assert!(DTORS as uint != 1, + assert!(DTORS as usize != 0); + assert!(DTORS as usize != 1, "cannot create new TLS keys after the main thread has exited"); (*DTORS).push((key, dtor)); DTOR_LOCK.unlock(); @@ -162,8 +162,8 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) { unsafe fn unregister_dtor(key: Key) -> bool { DTOR_LOCK.lock(); init_dtors(); - assert!(DTORS as uint != 0); - assert!(DTORS as uint != 1, + assert!(DTORS as usize != 0); + assert!(DTORS as usize != 1, "cannot unregister destructors after the main thread has exited"); let ret = { let dtors = &mut *DTORS; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 9bcae926eea..8856cc26b2e 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -91,13 +91,13 @@ fn helper(input: libc::HANDLE, messages: Receiver, _: ()) { } } else { let remove = { - match &mut chans[idx as uint - 1] { + match &mut chans[idx as usize - 1] { &mut (ref mut c, oneshot) => { c.call(); oneshot } } }; if remove { - drop(objs.remove(idx as uint)); - drop(chans.remove(idx as uint - 1)); + drop(objs.remove(idx as usize)); + drop(chans.remove(idx as usize - 1)); } } } diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 52f4cce4aa3..38faabf3276 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -92,7 +92,7 @@ impl TTY { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult { // Read more if the buffer is empty if self.utf8.eof() { let mut utf16: Vec = repeat(0u16).take(0x1000).collect(); @@ -105,7 +105,7 @@ impl TTY { 0 => return Err(super::last_error()), _ => (), }; - utf16.truncate(num as uint); + utf16.truncate(num as usize); let utf8 = match String::from_utf16(&utf16) { Ok(utf8) => utf8.into_bytes(), Err(..) => return Err(invalid_encoding()), @@ -149,12 +149,12 @@ impl TTY { } } - pub fn get_winsize(&mut self) -> IoResult<(int, int)> { + pub fn get_winsize(&mut self) -> IoResult<(isize, isize)> { let mut info: CONSOLE_SCREEN_BUFFER_INFO = unsafe { mem::zeroed() }; match unsafe { GetConsoleScreenBufferInfo(self.handle, &mut info as *mut _) } { 0 => Err(super::last_error()), - _ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as int, - (info.srWindow.Bottom + 1 - info.srWindow.Top) as int)), + _ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as isize, + (info.srWindow.Bottom + 1 - info.srWindow.Top) as isize)), } } } -- cgit 1.4.1-3-g733a5 From e7525cf6200e5b62a4b1a2f3131f68d946fb331e Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Thu, 26 Mar 2015 13:39:23 -0700 Subject: Revise use of conversion traits This commit revises `path` and `os_str` to use blanket impls for `From` on reference types. This both cuts down on the number of required impls, and means that you can pass through e.g. `T: AsRef` to `PathBuf::from` without an intermediate call to `as_ref`. It also makes a FIXME note for later generalizing the blanket impls for `AsRef` and `AsMut` to use `Deref`/`DerefMut`, once it is possible to do so. --- src/libcore/convert.rs | 16 ++++++++++++++++ src/libstd/ffi/os_str.rs | 20 +++----------------- src/libstd/path.rs | 40 ++++++---------------------------------- src/libstd/sys/unix/os_str.rs | 4 ---- src/libstd/sys/windows/os_str.rs | 4 ---- 5 files changed, 25 insertions(+), 59 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 65a226d37cb..21f9b1f5513 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -69,6 +69,14 @@ impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a mut T where T: AsRef { } } +// FIXME (#23442): replace the above impls for &/&mut with the following more general one: +// // As lifts over Deref +// impl AsRef for D where D::Target: AsRef { +// fn as_ref(&self) -> &U { +// self.deref().as_ref() +// } +// } + // AsMut implies Into impl<'a, T: ?Sized, U: ?Sized> Into<&'a mut U> for &'a mut T where T: AsMut { fn into(self) -> &'a mut U { @@ -83,6 +91,14 @@ impl<'a, T: ?Sized, U: ?Sized> AsMut for &'a mut T where T: AsMut { } } +// FIXME (#23442): replace the above impl for &mut with the following more general one: +// // AsMut lifts over DerefMut +// impl AsMut for D where D::Target: AsMut { +// fn as_mut(&mut self) -> &mut U { +// self.deref_mut().as_mut() +// } +// } + // From implies Into impl Into for T where U: From { fn into(self) -> U { diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 5851c6e2998..24844ad0961 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -113,23 +113,9 @@ impl From for OsString { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a String> for OsString { - fn from(s: &'a String) -> OsString { - OsString { inner: Buf::from_str(s) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a str> for OsString { - fn from(s: &'a str) -> OsString { - OsString { inner: Buf::from_str(s) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a OsStr> for OsString { - fn from(s: &'a OsStr) -> OsString { - OsString { inner: s.inner.to_owned() } +impl<'a, T: ?Sized + AsRef> From<&'a T> for OsString { + fn from(s: &'a T) -> OsString { + s.as_ref().to_os_string() } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 50f79967f55..58d3ae9f7cf 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1038,23 +1038,16 @@ impl PathBuf { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a Path> for PathBuf { - fn from(s: &'a Path) -> PathBuf { - s.to_path_buf() +impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { + fn from(s: &'a T) -> PathBuf { + PathBuf::from(s.as_ref().to_os_string()) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a str> for PathBuf { - fn from(s: &'a str) -> PathBuf { - PathBuf::from(OsString::from(s)) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a String> for PathBuf { - fn from(s: &'a String) -> PathBuf { - PathBuf::from(OsString::from(s)) +impl From for PathBuf { + fn from(s: OsString) -> PathBuf { + PathBuf { inner: s } } } @@ -1065,27 +1058,6 @@ impl From for PathBuf { } } -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a OsStr> for PathBuf { - fn from(s: &'a OsStr) -> PathBuf { - PathBuf::from(OsString::from(s)) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a OsString> for PathBuf { - fn from(s: &'a OsString) -> PathBuf { - PathBuf::from(s.to_os_string()) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl From for PathBuf { - fn from(s: OsString) -> PathBuf { - PathBuf { inner: s } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl> iter::FromIterator

for PathBuf { fn from_iter>(iter: I) -> PathBuf { diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index 3b8d18d87a0..69d876a48a4 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -46,10 +46,6 @@ impl Buf { Buf { inner: s.into_bytes() } } - pub fn from_str(s: &str) -> Buf { - Buf { inner: s.as_bytes().to_vec() } - } - pub fn as_slice(&self) -> &Slice { unsafe { mem::transmute(&*self.inner) } } diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs index ad1e6c4b0e7..91905ae7489 100644 --- a/src/libstd/sys/windows/os_str.rs +++ b/src/libstd/sys/windows/os_str.rs @@ -45,10 +45,6 @@ impl Buf { Buf { inner: Wtf8Buf::from_string(s) } } - pub fn from_str(s: &str) -> Buf { - Buf { inner: Wtf8Buf::from_str(s) } - } - pub fn as_slice(&self) -> &Slice { unsafe { mem::transmute(self.inner.as_slice()) } } -- cgit 1.4.1-3-g733a5 From 6acf385c9674a359b5b45f6e127521dd1515668c Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Mon, 23 Mar 2015 13:42:48 -0400 Subject: Updated std::dynamic_lib to use std::path. --- src/librustc/plugin/load.rs | 5 ---- src/libstd/dynamic_lib.rs | 52 ++++++++++++++++++------------------- src/libstd/sys/windows/backtrace.rs | 3 +-- 3 files changed, 26 insertions(+), 34 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index 6fd74479f75..752e71bc191 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -18,10 +18,6 @@ use std::borrow::ToOwned; use std::dynamic_lib::DynamicLibrary; use std::env; use std::mem; - -#[allow(deprecated)] -use std::old_path; - use std::path::PathBuf; use syntax::ast; use syntax::codemap::{Span, COMMAND_LINE_SP}; @@ -110,7 +106,6 @@ impl<'a> PluginLoader<'a> { symbol: String) -> PluginRegistrarFun { // Make sure the path contains a / or the linker will search for it. let path = env::current_dir().unwrap().join(&path); - let path = old_path::Path::new(path.to_str().unwrap()); let lib = match DynamicLibrary::open(Some(&path)) { Ok(lib) => lib, diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 085bf01612d..a7329ce4e29 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -14,16 +14,15 @@ #![unstable(feature = "std_misc")] #![allow(missing_docs)] -#![allow(deprecated)] // will be addressed by #23197 use prelude::v1::*; use env; -use ffi::CString; +use ffi::{AsOsStr, CString, OsString}; use mem; -use old_path::{Path, GenericPath}; -use os; -use str; +use path::{Path, PathBuf}; +#[cfg(not(target_os = "android"))] use os; +#[cfg(not(target_os = "android"))] use str; pub struct DynamicLibrary { handle: *mut u8 @@ -54,7 +53,7 @@ impl DynamicLibrary { /// Lazily open a dynamic library. When passed None it gives a /// handle to the calling process pub fn open(filename: Option<&Path>) -> Result { - let maybe_library = dl::open(filename.map(|path| path.as_vec())); + let maybe_library = dl::open(filename.map(|path| path.as_os_str())); // The dynamic library must not be constructed if there is // an error opening the library so the destructor does not @@ -68,19 +67,17 @@ impl DynamicLibrary { /// Prepends a path to this process's search path for dynamic libraries pub fn prepend_search_path(path: &Path) { let mut search_path = DynamicLibrary::search_path(); - search_path.insert(0, path.clone()); - let newval = DynamicLibrary::create_path(&search_path); - env::set_var(DynamicLibrary::envvar(), - str::from_utf8(&newval).unwrap()); + search_path.insert(0, path.to_path_buf()); + env::set_var(DynamicLibrary::envvar(), &DynamicLibrary::create_path(&search_path)); } /// From a slice of paths, create a new vector which is suitable to be an /// environment variable for this platforms dylib search path. - pub fn create_path(path: &[Path]) -> Vec { - let mut newvar = Vec::new(); + pub fn create_path(path: &[PathBuf]) -> OsString { + let mut newvar = OsString::new(); for (i, path) in path.iter().enumerate() { if i > 0 { newvar.push(DynamicLibrary::separator()); } - newvar.push_all(path.as_vec()); + newvar.push(path); } return newvar; } @@ -97,15 +94,15 @@ impl DynamicLibrary { } } - fn separator() -> u8 { - if cfg!(windows) {b';'} else {b':'} + fn separator() -> &'static str { + if cfg!(windows) { ";" } else { ":" } } /// Returns the current search path for dynamic libraries being used by this /// process - pub fn search_path() -> Vec { + pub fn search_path() -> Vec { match env::var_os(DynamicLibrary::envvar()) { - Some(var) => os::split_paths(var.to_str().unwrap()), + Some(var) => env::split_paths(&var).collect(), None => Vec::new(), } } @@ -134,8 +131,8 @@ mod test { use super::*; use prelude::v1::*; use libc; - use old_path::Path; use mem; + use path::Path; #[test] #[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379 @@ -192,12 +189,13 @@ mod test { mod dl { use prelude::v1::*; - use ffi::{CString, CStr}; + use ffi::{CStr, OsStr}; use str; use libc; + use os::unix::prelude::*; use ptr; - pub fn open(filename: Option<&[u8]>) -> Result<*mut u8, String> { + pub fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> { check_for_errors_in(|| { unsafe { match filename { @@ -210,8 +208,8 @@ mod dl { const LAZY: libc::c_int = 1; - unsafe fn open_external(filename: &[u8]) -> *mut u8 { - let s = CString::new(filename).unwrap(); + unsafe fn open_external(filename: &OsStr) -> *mut u8 { + let s = filename.to_cstring().unwrap(); dlopen(s.as_ptr(), LAZY) as *mut u8 } @@ -264,21 +262,22 @@ mod dl { #[cfg(target_os = "windows")] mod dl { + use ffi::OsStr; use iter::IteratorExt; use libc; use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED; use ops::FnOnce; use os; + use os::windows::prelude::*; use option::Option::{self, Some, None}; use ptr; use result::Result; use result::Result::{Ok, Err}; - use str; use string::String; use vec::Vec; use sys::c::compat::kernel32::SetThreadErrorMode; - pub fn open(filename: Option<&[u8]>) -> Result<*mut u8, String> { + pub fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> { // disable "dll load failed" error dialog. let mut use_thread_mode = true; let prev_error_mode = unsafe { @@ -308,9 +307,8 @@ mod dl { let result = match filename { Some(filename) => { - let filename_str = str::from_utf8(filename).unwrap(); - let mut filename_str: Vec = filename_str.utf16_units().collect(); - filename_str.push(0); + let filename_str: Vec<_> = + filename.encode_wide().chain(Some(0).into_iter()).collect(); let result = unsafe { LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) }; diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index ffa4b37b487..fd16bbcf574 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -23,7 +23,6 @@ //! this takes the route of using StackWalk64 in order to walk the stack. #![allow(dead_code)] -#![allow(deprecated)] // for old path for dynamic lib use prelude::v1::*; use io::prelude::*; @@ -34,7 +33,7 @@ use intrinsics; use io; use libc; use mem; -use old_path::Path; +use path::Path; use ptr; use str; use sync::{StaticMutex, MUTEX_INIT}; -- cgit 1.4.1-3-g733a5 From cbce6bfbdb140561add2ff258b305e7c7f2ad5c6 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Sat, 28 Mar 2015 02:23:20 -0700 Subject: cleanup: Remove unused braces in use statements --- src/liballoc/arc.rs | 2 +- src/libcollections/btree/map.rs | 2 +- src/libcollections/vec.rs | 2 +- src/libcore/option.rs | 2 +- src/librand/distributions/range.rs | 2 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/metadata/loader.rs | 2 +- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/check_match.rs | 2 +- src/librustc/middle/infer/bivariate.rs | 8 ++++---- src/librustc/middle/infer/combine.rs | 2 +- src/librustc/middle/infer/equate.rs | 8 ++++---- src/librustc/middle/infer/glb.rs | 2 +- src/librustc/middle/infer/lattice.rs | 2 +- src/librustc/middle/infer/lub.rs | 4 ++-- src/librustc/middle/infer/mod.rs | 4 ++-- src/librustc/middle/infer/sub.rs | 6 +++--- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/middle/pat_util.rs | 2 +- src/librustc/middle/region.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/middle/traits/coherence.rs | 2 +- src/librustc/middle/traits/fulfill.rs | 2 +- src/librustc/middle/traits/select.rs | 8 ++++---- src/librustc/middle/ty.rs | 2 +- src/librustc/plugin/registry.rs | 2 +- src/librustc/util/nodemap.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_borrowck/borrowck/fragments.rs | 4 ++-- src/librustc_borrowck/borrowck/gather_loans/mod.rs | 2 +- src/librustc_borrowck/graphviz.rs | 2 +- src/librustc_driver/driver.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_trans/trans/base.rs | 2 +- src/librustc_trans/trans/basic_block.rs | 2 +- src/librustc_trans/trans/callee.rs | 2 +- src/librustc_trans/trans/closure.rs | 2 +- src/librustc_trans/trans/context.rs | 2 +- src/librustc_trans/trans/datum.rs | 2 +- src/librustc_trans/trans/expr.rs | 2 +- src/librustc_trans/trans/foreign.rs | 4 ++-- src/librustc_trans/trans/tvec.rs | 2 +- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 2 +- src/librustc_typeck/check/implicator.rs | 2 +- src/librustc_typeck/check/method/mod.rs | 4 ++-- src/librustc_typeck/check/method/probe.rs | 2 +- src/librustc_typeck/check/vtable.rs | 2 +- src/librustc_typeck/check/wf.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 10 +++++----- src/librustc_typeck/coherence/overlap.rs | 4 ++-- src/librustc_typeck/collect.rs | 2 +- src/libserialize/json.rs | 2 +- src/libstd/collections/hash/bench.rs | 2 +- src/libstd/old_io/net/addrinfo.rs | 2 +- src/libstd/old_io/tempfile.rs | 2 +- src/libstd/sync/future.rs | 2 +- src/libstd/sys/windows/tty.rs | 2 +- src/libsyntax/ast_map/blocks.rs | 2 +- src/libsyntax/ext/concat_idents.rs | 2 +- src/libsyntax/ext/deriving/rand.rs | 2 +- src/libsyntax/parse/lexer/mod.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/util/parser_testing.rs | 4 ++-- src/libtest/lib.rs | 2 +- src/test/run-make/sepcomp-cci-copies/foo.rs | 2 +- src/test/run-pass/builtin-superkinds-in-metadata.rs | 2 +- src/test/run-pass/issue-3424.rs | 2 +- src/test/run-pass/overloaded-calls-zero-args.rs | 2 +- 72 files changed, 94 insertions(+), 94 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index b5d16d29272..1607fd34c51 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -76,7 +76,7 @@ use core::prelude::*; use core::atomic; use core::atomic::Ordering::{Relaxed, Release, Acquire, SeqCst}; use core::fmt; -use core::cmp::{Ordering}; +use core::cmp::Ordering; use core::default::Default; use core::mem::{min_align_of, size_of}; use core::mem; diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 04a692cc3ae..a4b7abde5c8 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -24,7 +24,7 @@ use core::default::Default; use core::fmt::Debug; use core::hash::{Hash, Hasher}; use core::iter::{Map, FromIterator, IntoIterator}; -use core::ops::{Index}; +use core::ops::Index; use core::{iter, fmt, mem, usize}; use Bound::{self, Included, Excluded, Unbounded}; diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index e71077c96c7..f6647fb27ee 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -52,7 +52,7 @@ use core::prelude::*; use alloc::boxed::Box; use alloc::heap::{EMPTY, allocate, reallocate, deallocate}; use core::cmp::max; -use core::cmp::{Ordering}; +use core::cmp::Ordering; use core::default::Default; use core::fmt; use core::hash::{self, Hash}; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a565b137cc8..3ffbb0b7539 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -148,7 +148,7 @@ use self::Option::*; use clone::Clone; use cmp::{Eq, Ord}; use default::Default; -use iter::{ExactSizeIterator}; +use iter::ExactSizeIterator; use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, IntoIterator}; use mem; use ops::{Deref, FnOnce}; diff --git a/src/librand/distributions/range.rs b/src/librand/distributions/range.rs index a682fa85841..fab80b8425a 100644 --- a/src/librand/distributions/range.rs +++ b/src/librand/distributions/range.rs @@ -14,7 +14,7 @@ // this is surprisingly complicated to be both generic & correct -use core::prelude::{PartialOrd}; +use core::prelude::PartialOrd; use core::num::Int; use core::num::wrapping::WrappingOps; diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index fa8d0b2a56e..211b2568985 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -22,7 +22,7 @@ use metadata::cstore; use metadata::decoder; use metadata::tyencode; use middle::def; -use middle::ty::{lookup_item_type}; +use middle::ty::lookup_item_type; use middle::ty::{self, Ty}; use middle::stability; use util::nodemap::{FnvHashMap, NodeMap, NodeSet}; diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 80fc3769453..35313080c39 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -212,7 +212,7 @@ //! no means all of the necessary details. Take a look at the rest of //! metadata::loader or metadata::creader for all the juicy details! -use back::archive::{METADATA_FILENAME}; +use back::archive::METADATA_FILENAME; use back::svh::Svh; use session::Session; use session::search_paths::PathKind; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 801350e8a1e..40e15ec67bb 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -50,7 +50,7 @@ use rbml::writer::Encoder; use rbml; use serialize; use serialize::{Decodable, Decoder, DecoderHelpers, Encodable}; -use serialize::{EncoderHelpers}; +use serialize::EncoderHelpers; #[cfg(test)] use std::io::Cursor; #[cfg(test)] use syntax::parse; diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 97cd9456098..6923de7cad7 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -18,7 +18,7 @@ use middle::const_eval::{const_expr_to_pat, lookup_const_by_id}; use middle::def::*; use middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor, Init}; use middle::expr_use_visitor::{JustWrite, LoanCause, MutateMode}; -use middle::expr_use_visitor::{WriteAndRead}; +use middle::expr_use_visitor::WriteAndRead; use middle::expr_use_visitor as euv; use middle::mem_categorization::cmt; use middle::pat_util::*; diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/middle/infer/bivariate.rs index cedb30eebfd..17b0d788590 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/middle/infer/bivariate.rs @@ -25,13 +25,13 @@ //! In particular, it might be enough to say (A,B) are bivariant for //! all (A,B). -use middle::ty::{BuiltinBounds}; +use middle::ty::BuiltinBounds; use middle::ty::{self, Ty}; use middle::ty::TyVar; use middle::infer::combine::*; -use middle::infer::{cres}; -use middle::infer::type_variable::{BiTo}; -use util::ppaux::{Repr}; +use middle::infer::cres; +use middle::infer::type_variable::BiTo; +use util::ppaux::Repr; pub struct Bivariate<'f, 'tcx: 'f> { fields: CombineFields<'f, 'tcx> diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 930e95d1f93..9aa17b2b1d9 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -46,7 +46,7 @@ use middle::subst; use middle::subst::{ErasedRegions, NonerasedRegions, Substs}; use middle::ty::{FloatVar, FnSig, IntVar, TyVar}; use middle::ty::{IntType, UintType}; -use middle::ty::{BuiltinBounds}; +use middle::ty::BuiltinBounds; use middle::ty::{self, Ty}; use middle::ty_fold; use middle::ty_fold::{TypeFolder, TypeFoldable}; diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/middle/infer/equate.rs index c2b73bca858..59ed2dfd24f 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/middle/infer/equate.rs @@ -11,10 +11,10 @@ use middle::ty::{self, Ty}; use middle::ty::TyVar; use middle::infer::combine::*; -use middle::infer::{cres}; -use middle::infer::{Subtype}; -use middle::infer::type_variable::{EqTo}; -use util::ppaux::{Repr}; +use middle::infer::cres; +use middle::infer::Subtype; +use middle::infer::type_variable::EqTo; +use util::ppaux::Repr; pub struct Equate<'f, 'tcx: 'f> { fields: CombineFields<'f, 'tcx> diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/middle/infer/glb.rs index e17155a2ae6..3b83d37f582 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/middle/infer/glb.rs @@ -11,7 +11,7 @@ use super::combine::*; use super::lattice::*; use super::higher_ranked::HigherRankedRelations; -use super::{cres}; +use super::cres; use super::Subtype; use middle::ty::{self, Ty}; diff --git a/src/librustc/middle/infer/lattice.rs b/src/librustc/middle/infer/lattice.rs index 121e5405f26..9c764628c14 100644 --- a/src/librustc/middle/infer/lattice.rs +++ b/src/librustc/middle/infer/lattice.rs @@ -34,7 +34,7 @@ use super::combine::*; use super::glb::Glb; use super::lub::Lub; -use middle::ty::{TyVar}; +use middle::ty::TyVar; use middle::ty::{self, Ty}; use util::ppaux::Repr; diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/middle/infer/lub.rs index be814b2acc1..5000ab32ff6 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/middle/infer/lub.rs @@ -11,8 +11,8 @@ use super::combine::*; use super::higher_ranked::HigherRankedRelations; use super::lattice::*; -use super::{cres}; -use super::{Subtype}; +use super::cres; +use super::Subtype; use middle::ty::{self, Ty}; use util::ppaux::Repr; diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 8bd3ca826a6..2107d1ee4c4 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -28,14 +28,14 @@ use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, UnconstrainedNumeric}; use middle::ty::replace_late_bound_regions; use middle::ty::{self, Ty}; use middle::ty_fold::{TypeFolder, TypeFoldable}; -use std::cell::{RefCell}; +use std::cell::RefCell; use std::fmt; use std::rc::Rc; use syntax::ast; use syntax::codemap; use syntax::codemap::Span; use util::nodemap::FnvHashMap; -use util::ppaux::{ty_to_string}; +use util::ppaux::ty_to_string; use util::ppaux::{Repr, UserString}; use self::combine::{Combine, Combineable, CombineFields}; diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs index 423fb86dc5c..5d23fe3f134 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/middle/infer/sub.rs @@ -9,14 +9,14 @@ // except according to those terms. use super::combine::*; -use super::{cres}; +use super::cres; use super::higher_ranked::HigherRankedRelations; -use super::{Subtype}; +use super::Subtype; use super::type_variable::{SubtypeOf, SupertypeOf}; use middle::ty::{self, Ty}; use middle::ty::TyVar; -use util::ppaux::{Repr}; +use util::ppaux::Repr; /// "Greatest lower bound" (common subtype) pub struct Sub<'f, 'tcx: 'f> { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bdcfc67f92b..ab894b236fe 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -75,7 +75,7 @@ use middle::check_const; use middle::def; use middle::region; use middle::ty::{self, Ty}; -use util::nodemap::{NodeMap}; +use util::nodemap::NodeMap; use util::ppaux::{Repr, UserString}; use syntax::ast::{MutImmutable, MutMutable}; diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 4f365beed21..12b56562c84 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -13,7 +13,7 @@ use middle::ty; use util::nodemap::FnvHashMap; use syntax::ast; -use syntax::ast_util::{walk_pat}; +use syntax::ast_util::walk_pat; use syntax::codemap::{Span, DUMMY_SP}; pub type PatIdMap = FnvHashMap; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index b4db3aba786..dbc879e59bc 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -25,7 +25,7 @@ use std::cell::RefCell; use syntax::codemap::{self, Span}; use syntax::{ast, visit}; use syntax::ast::{Block, Item, FnDecl, NodeId, Arm, Pat, Stmt, Expr, Local}; -use syntax::ast_util::{stmt_id}; +use syntax::ast_util::stmt_id; use syntax::ast_map; use syntax::ptr::P; use syntax::visit::{Visitor, FnKind}; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index e33a2553431..a3d71c989bf 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -28,7 +28,7 @@ use syntax::ast; use syntax::codemap::Span; use syntax::parse::token::special_idents; use syntax::parse::token; -use syntax::print::pprust::{lifetime_to_string}; +use syntax::print::pprust::lifetime_to_string; use syntax::visit; use syntax::visit::Visitor; use util::nodemap::NodeMap; diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 62b81f0ebe7..11d073ce72e 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -12,7 +12,7 @@ use super::Normalized; use super::SelectionContext; -use super::{ObligationCause}; +use super::ObligationCause; use super::PredicateObligation; use super::project; use super::util; diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 3d46f93914a..f7ff256744e 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::infer::{InferCtxt}; +use middle::infer::InferCtxt; use middle::ty::{self, RegionEscape, Ty}; use std::collections::HashSet; use std::default::Default; diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 0d6a1f7df5e..20863664871 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -21,16 +21,16 @@ use super::DerivedObligationCause; use super::project; use super::project::{normalize_with_depth, Normalized}; use super::{PredicateObligation, TraitObligation, ObligationCause}; -use super::{report_overflow_error}; +use super::report_overflow_error; use super::{ObligationCauseCode, BuiltinDerivedObligation, ImplDerivedObligation}; use super::{SelectionError, Unimplemented, OutputTypeParameterMismatch}; -use super::{Selection}; -use super::{SelectionResult}; +use super::Selection; +use super::SelectionResult; use super::{VtableBuiltin, VtableImpl, VtableParam, VtableClosure, VtableFnPointer, VtableObject, VtableDefaultImpl}; use super::{VtableImplData, VtableObjectData, VtableBuiltinData, VtableDefaultImplData}; use super::object_safety; -use super::{util}; +use super::util; use middle::fast_reject; use middle::subst::{Subst, Substs, TypeSpace, VecPerParamSpace}; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 23fba5ead22..9eb3eb56fa4 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -64,7 +64,7 @@ use util::ppaux::ty_to_string; use util::ppaux::{Repr, UserString}; use util::common::{memoized, ErrorReported}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; -use util::nodemap::{FnvHashMap}; +use util::nodemap::FnvHashMap; use arena::TypedArena; use std::borrow::{Borrow, Cow}; diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs index 78f7b3b91dd..a73ed04ac0a 100644 --- a/src/librustc/plugin/registry.rs +++ b/src/librustc/plugin/registry.rs @@ -15,7 +15,7 @@ use session::Session; use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT}; use syntax::ext::base::{IdentTT, Decorator, Modifier, MultiModifier, MacroRulesTT}; -use syntax::ext::base::{MacroExpanderFn}; +use syntax::ext::base::MacroExpanderFn; use syntax::codemap::Span; use syntax::parse::token; use syntax::ptr::P; diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index 0f69aa941a3..61d28e0ca1e 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -12,7 +12,7 @@ #![allow(non_snake_case)] -use std::collections::hash_state::{DefaultState}; +use std::collections::hash_state::DefaultState; use std::collections::{HashMap, HashSet}; use std::default::Default; use std::hash::{Hasher, Hash}; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 60540a9cfa6..452589a2407 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -21,7 +21,7 @@ use middle::ty::{mt, Ty, ParamTy}; use middle::ty::{ty_bool, ty_char, ty_struct, ty_enum}; use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn}; use middle::ty::{ty_param, ty_ptr, ty_rptr, ty_tup}; -use middle::ty::{ty_closure}; +use middle::ty::ty_closure; use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer}; use middle::ty; use middle::ty_fold::TypeFoldable; diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index f3abcb4376c..a13d1d1112a 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -15,10 +15,10 @@ use self::Fragment::*; use borrowck::InteriorKind::{InteriorField, InteriorElement}; -use borrowck::{LoanPath}; +use borrowck::LoanPath; use borrowck::LoanPathKind::{LpVar, LpUpvar, LpDowncast, LpExtend}; use borrowck::LoanPathElem::{LpDeref, LpInterior}; -use borrowck::move_data::{InvalidMovePathIndex}; +use borrowck::move_data::InvalidMovePathIndex; use borrowck::move_data::{MoveData, MovePathIndex}; use rustc::middle::ty; use rustc::middle::mem_categorization as mc; diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 7d77eb23b6e..bbdec402bdc 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -22,7 +22,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty; -use rustc::util::ppaux::{Repr}; +use rustc::util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; use syntax::visit; diff --git a/src/librustc_borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs index a2c9930c0ed..94c18d7d003 100644 --- a/src/librustc_borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -20,7 +20,7 @@ use rustc::middle::cfg::graphviz as cfg_dot; use borrowck; use borrowck::{BorrowckCtxt, LoanPath}; use dot; -use rustc::middle::cfg::{CFGIndex}; +use rustc::middle::cfg::CFGIndex; use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; use rustc::middle::dataflow; use std::rc::Rc; diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 4c654cbf27d..d4b4165d2f9 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -39,7 +39,7 @@ use std::path::{Path, PathBuf}; use syntax::ast; use syntax::ast_map; use syntax::attr; -use syntax::attr::{AttrMetaMethods}; +use syntax::attr::AttrMetaMethods; use syntax::diagnostics; use syntax::parse; use syntax::parse::token; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 8b57a48f3ce..12e6d122605 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -35,7 +35,7 @@ use middle::ty::{self, Ty}; use middle::{def, pat_util, stability}; use middle::const_eval::{eval_const_expr_partial, const_int, const_uint}; use middle::cfg; -use util::ppaux::{ty_to_string}; +use util::ppaux::ty_to_string; use util::nodemap::{FnvHashMap, NodeSet}; use lint::{Level, Context, LintPass, LintArray, Lint}; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 2e7fe91365a..eb3589fa78b 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -43,7 +43,7 @@ use rustc::middle::privacy::{ExternalExports, ExportedItems, PublicItems}; use rustc::middle::ty::{MethodTypeParam, MethodStatic}; use rustc::middle::ty::{MethodCall, MethodMap, MethodOrigin, MethodParam}; use rustc::middle::ty::{MethodStaticClosure, MethodObject}; -use rustc::middle::ty::{MethodTraitObject}; +use rustc::middle::ty::MethodTraitObject; use rustc::middle::ty::{self, Ty}; use rustc::util::nodemap::{NodeMap, NodeSet}; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index e62300098f6..5bff5479e2e 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -47,7 +47,7 @@ use syntax::ast::StructVariantKind; use syntax::ast::TupleVariantKind; use syntax::ast::UnnamedField; use syntax::ast::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple}; -use syntax::ast::{Visibility}; +use syntax::ast::Visibility; use syntax::ast; use syntax::ast_util::local_def; use syntax::attr::AttrMetaMethods; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 5bf561c218d..3508c6289ca 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -77,7 +77,7 @@ use syntax::ast::{TraitRef, Ty, TyBool, TyChar, TyF32}; use syntax::ast::{TyF64, TyFloat, TyIs, TyI8, TyI16, TyI32, TyI64, TyInt}; use syntax::ast::{TyPath, TyPtr}; use syntax::ast::{TyRptr, TyStr, TyUs, TyU8, TyU16, TyU32, TyU64, TyUint}; -use syntax::ast::{TypeImplItem}; +use syntax::ast::TypeImplItem; use syntax::ast; use syntax::ast_map; use syntax::ast_util::{local_def, walk_pat}; diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 2f944e49b15..f842c011258 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -30,7 +30,7 @@ pub use self::ValueOrigin::*; use super::CrateTranslation; use super::ModuleTranslation; -use back::link::{mangle_exported_name}; +use back::link::mangle_exported_name; use back::{link, abi}; use lint; use llvm::{AttrHelper, BasicBlockRef, Linkage, ValueRef, Vector, get_param}; diff --git a/src/librustc_trans/trans/basic_block.rs b/src/librustc_trans/trans/basic_block.rs index f11c3154274..a0aca17538f 100644 --- a/src/librustc_trans/trans/basic_block.rs +++ b/src/librustc_trans/trans/basic_block.rs @@ -9,7 +9,7 @@ // except according to those terms. use llvm; -use llvm::{BasicBlockRef}; +use llvm::BasicBlockRef; use trans::value::{Users, Value}; use std::iter::{Filter, Map}; diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index e7911d5cc19..e33ec29017c 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -21,7 +21,7 @@ pub use self::CallArgs::*; use arena::TypedArena; use back::link; use session; -use llvm::{ValueRef}; +use llvm::ValueRef; use llvm::get_param; use llvm; use metadata::csearch; diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index 5a48b8e4bce..c1aade3663e 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -24,7 +24,7 @@ use trans::expr; use trans::monomorphize::{self, MonoId}; use trans::type_of::*; use middle::ty::{self, ClosureTyper}; -use middle::subst::{Substs}; +use middle::subst::Substs; use session::config::FullDebugInfo; use util::ppaux::Repr; diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 6614d538971..ce96df3c29d 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -10,7 +10,7 @@ use llvm; use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef}; -use llvm::{TargetData}; +use llvm::TargetData; use llvm::mk_target_data; use metadata::common::LinkMeta; use middle::def::ExportMap; diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index 15738d1e61a..969c614cee0 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -113,7 +113,7 @@ use trans::expr; use trans::tvec; use trans::type_of; use middle::ty::{self, Ty}; -use util::ppaux::{ty_to_string}; +use util::ppaux::ty_to_string; use std::fmt; use syntax::ast; diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index ba8de6da42f..17b4b536df5 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -73,7 +73,7 @@ use trans::tvec; use trans::type_of; use middle::ty::{struct_fields, tup_fields}; use middle::ty::{AdjustDerefRef, AdjustReifyFnPointer, AdjustUnsafeFnPointer, AutoUnsafe}; -use middle::ty::{AutoPtr}; +use middle::ty::AutoPtr; use middle::ty::{self, Ty}; use middle::ty::MethodCall; use util::common::indenter; diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index dfc7e7f604f..e87a5865df0 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -9,7 +9,7 @@ // except according to those terms. -use back::{link}; +use back::link; use llvm::{ValueRef, CallConv, get_param}; use llvm; use middle::weak_lang_items; @@ -35,7 +35,7 @@ use syntax::abi::{RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System}; use syntax::codemap::Span; use syntax::parse::token::{InternedString, special_idents}; use syntax::parse::token; -use syntax::{ast}; +use syntax::ast; use syntax::{attr, ast_map}; use syntax::print::pprust; use util::ppaux::Repr; diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 6a35a1a55b6..dec5263484d 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -12,7 +12,7 @@ use back::abi; use llvm; -use llvm::{ValueRef}; +use llvm::ValueRef; use trans::base::*; use trans::base; use trans::build::*; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index e8da19efa06..8f1a67723cb 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -12,7 +12,7 @@ use middle::const_eval; use middle::def; use middle::infer; use middle::pat_util::{PatIdMap, pat_id_map, pat_is_binding, pat_is_const}; -use middle::subst::{Substs}; +use middle::subst::Substs; use middle::ty::{self, Ty}; use check::{check_expr, check_expr_has_type, check_expr_with_expectation}; use check::{check_expr_coercable_to_type, demand, FnCtxt, Expectation}; diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 1e1d7e09260..1c5f2c56078 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -15,7 +15,7 @@ use middle::subst::{self, Subst, Substs, VecPerParamSpace}; use util::ppaux::{self, Repr}; use syntax::ast; -use syntax::codemap::{Span}; +use syntax::codemap::Span; use syntax::parse::token; use super::assoc; diff --git a/src/librustc_typeck/check/implicator.rs b/src/librustc_typeck/check/implicator.rs index 6b4a7761d0a..a4a18c7cfde 100644 --- a/src/librustc_typeck/check/implicator.rs +++ b/src/librustc_typeck/check/implicator.rs @@ -12,7 +12,7 @@ use astconv::object_region_bounds; use middle::infer::{InferCtxt, GenericKind}; -use middle::subst::{Substs}; +use middle::subst::Substs; use middle::traits; use middle::ty::{self, ToPolyTraitRef, Ty}; use middle::ty_fold::{TypeFoldable, TypeFolder}; diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 7ef2db2c28d..ff0413f1765 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -11,7 +11,7 @@ //! Method lookup: the secret sauce of Rust. See `README.md`. use astconv::AstConv; -use check::{FnCtxt}; +use check::FnCtxt; use check::vtable; use check::vtable::select_new_fcx_obligations; use middle::def; @@ -24,7 +24,7 @@ use middle::infer; use util::ppaux::Repr; use std::rc::Rc; -use syntax::ast::{DefId}; +use syntax::ast::DefId; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index b95e0ce8cb3..d7fd36a6f8d 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::{MethodError}; +use super::MethodError; use super::MethodIndex; use super::{CandidateSource,ImplSource,TraitSource}; use super::suggest; diff --git a/src/librustc_typeck/check/vtable.rs b/src/librustc_typeck/check/vtable.rs index 2858dc9b569..40295954cf6 100644 --- a/src/librustc_typeck/check/vtable.rs +++ b/src/librustc_typeck/check/vtable.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use check::{FnCtxt}; +use check::FnCtxt; use middle::traits::{self, ObjectSafetyViolation, MethodViolationCode}; use middle::traits::{Obligation, ObligationCause}; use middle::traits::report_fulfillment_errors; diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index adbf4c6b210..6f1747a7d09 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -22,7 +22,7 @@ use util::ppaux::{Repr, UserString}; use std::collections::HashSet; use syntax::ast; -use syntax::ast_util::{local_def}; +use syntax::ast_util::local_def; use syntax::attr; use syntax::codemap::Span; use syntax::parse::token::{self, special_idents}; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index ffd99ff2eec..eaf07a3ef13 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -27,13 +27,13 @@ use middle::ty::{ty_param, TypeScheme, ty_ptr}; use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup}; use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int}; use middle::ty::{ty_uint, ty_closure, ty_uniq, ty_bare_fn}; -use middle::ty::{ty_projection}; +use middle::ty::ty_projection; use middle::ty; use CrateCtxt; use middle::infer::combine::Combine; use middle::infer::InferCtxt; -use middle::infer::{new_infer_ctxt}; -use std::collections::{HashSet}; +use middle::infer::new_infer_ctxt; +use std::collections::HashSet; use std::cell::RefCell; use std::rc::Rc; use syntax::ast::{Crate, DefId}; @@ -42,8 +42,8 @@ use syntax::ast::{LOCAL_CRATE, TraitRef}; use syntax::ast; use syntax::ast_map::NodeItem; use syntax::ast_map; -use syntax::ast_util::{local_def}; -use syntax::codemap::{Span}; +use syntax::ast_util::local_def; +use syntax::codemap::Span; use syntax::parse::token; use syntax::visit; use util::nodemap::{DefIdMap, FnvHashMap}; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 466d00b348b..f8ca51b9e49 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -14,8 +14,8 @@ use middle::traits; use middle::ty; use middle::infer::{self, new_infer_ctxt}; -use syntax::ast::{DefId}; -use syntax::ast::{LOCAL_CRATE}; +use syntax::ast::DefId; +use syntax::ast::LOCAL_CRATE; use syntax::ast; use syntax::ast_util; use syntax::visit; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 5816fe58bc9..6257e645fb7 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -91,7 +91,7 @@ use syntax::ast; use syntax::ast_map; use syntax::ast_util::local_def; use syntax::codemap::Span; -use syntax::parse::token::{special_idents}; +use syntax::parse::token::special_idents; use syntax::parse::token; use syntax::ptr::P; use syntax::visit; diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 0d6ed91d529..5f2101a4790 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -202,7 +202,7 @@ use self::InternalStackElement::*; use std::collections::{HashMap, BTreeMap}; use std::io::prelude::*; use std::io; -use std::mem::{swap}; +use std::mem::swap; use std::num::FpCategory as Fp; use std::ops::Index; use std::str::FromStr; diff --git a/src/libstd/collections/hash/bench.rs b/src/libstd/collections/hash/bench.rs index ca506e8c36f..ac21ae0f0aa 100644 --- a/src/libstd/collections/hash/bench.rs +++ b/src/libstd/collections/hash/bench.rs @@ -14,7 +14,7 @@ extern crate test; use prelude::v1::*; use self::test::Bencher; -use iter::{range_inclusive}; +use iter::range_inclusive; #[bench] fn new_drop(b : &mut Bencher) { diff --git a/src/libstd/old_io/net/addrinfo.rs b/src/libstd/old_io/net/addrinfo.rs index 2b7506b5c34..7c362b5a044 100644 --- a/src/libstd/old_io/net/addrinfo.rs +++ b/src/libstd/old_io/net/addrinfo.rs @@ -20,7 +20,7 @@ pub use self::Flag::*; pub use self::Protocol::*; use iter::IteratorExt; -use old_io::{IoResult}; +use old_io::IoResult; use old_io::net::ip::{SocketAddr, IpAddr}; use option::Option; use option::Option::{Some, None}; diff --git a/src/libstd/old_io/tempfile.rs b/src/libstd/old_io/tempfile.rs index c0f6ddaaef7..eebe28e045e 100644 --- a/src/libstd/old_io/tempfile.rs +++ b/src/libstd/old_io/tempfile.rs @@ -12,7 +12,7 @@ #![allow(deprecated)] // rand use env; -use iter::{IteratorExt}; +use iter::IteratorExt; use old_io::{fs, IoError, IoErrorKind, IoResult}; use old_io; use ops::Drop; diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 3c7fecb7515..b2afe28fed4 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -38,7 +38,7 @@ use core::mem::replace; use self::FutureState::*; use sync::mpsc::{Receiver, channel}; -use thunk::{Thunk}; +use thunk::Thunk; use thread; /// A type encapsulating the result of a computation which may not be complete diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 52f4cce4aa3..6b999f466cf 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -42,7 +42,7 @@ use super::c::{ENABLE_INSERT_MODE, ENABLE_LINE_INPUT}; use super::c::{ENABLE_PROCESSED_INPUT, ENABLE_QUICK_EDIT_MODE}; use super::c::CONSOLE_SCREEN_BUFFER_INFO; use super::c::{ReadConsoleW, WriteConsoleW, GetConsoleMode, SetConsoleMode}; -use super::c::{GetConsoleScreenBufferInfo}; +use super::c::GetConsoleScreenBufferInfo; fn invalid_encoding() -> IoError { IoError { diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs index 16a339cdcb5..1994ca70bbb 100644 --- a/src/libsyntax/ast_map/blocks.rs +++ b/src/libsyntax/ast_map/blocks.rs @@ -26,7 +26,7 @@ pub use self::Code::*; use abi; use ast::{Block, FnDecl, NodeId}; use ast; -use ast_map::{Node}; +use ast_map::Node; use ast_map; use codemap::Span; use visit; diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index e350ce61017..5d07c36c929 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -14,7 +14,7 @@ use ext::base::*; use ext::base; use feature_gate; use parse::token; -use parse::token::{str_to_ident}; +use parse::token::str_to_ident; use ptr::P; pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 8a764fded6f..631e5f979d9 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -12,7 +12,7 @@ use ast; use ast::{MetaItem, Item, Expr}; use codemap::Span; use ext::base::ExtCtxt; -use ext::build::{AstBuilder}; +use ext::build::AstBuilder; use ext::deriving::generic::*; use ext::deriving::generic::ty::*; use ptr::P; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0843713681b..51d5fa531d5 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -14,7 +14,7 @@ use codemap; use diagnostic::SpanHandler; use ext::tt::transcribe::tt_next_token; use parse::token; -use parse::token::{str_to_ident}; +use parse::token::str_to_ident; use std::borrow::{IntoCow, Cow}; use std::char; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 786970ce252..c1369d7c2e6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -11,7 +11,7 @@ pub use self::PathParsingMode::*; use abi; -use ast::{BareFnTy}; +use ast::BareFnTy; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{Public, Unsafety}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index 9b570c2b1fe..ec608646327 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -9,9 +9,9 @@ // except according to those terms. use ast; -use parse::{new_parse_sess}; +use parse::new_parse_sess; use parse::{ParseSess,string_to_filemap,filemap_to_tts}; -use parse::{new_parser_from_source_str}; +use parse::new_parser_from_source_str; use parse::parser::Parser; use parse::token; use ptr::P; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index c48c7e413d0..5372b2041bc 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -78,7 +78,7 @@ use std::io::prelude::*; use std::io; use std::iter::repeat; use std::num::{Float, Int}; -use std::path::{PathBuf}; +use std::path::PathBuf; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; use std::thread; diff --git a/src/test/run-make/sepcomp-cci-copies/foo.rs b/src/test/run-make/sepcomp-cci-copies/foo.rs index b0642b64cda..474ae8d8bb9 100644 --- a/src/test/run-make/sepcomp-cci-copies/foo.rs +++ b/src/test/run-make/sepcomp-cci-copies/foo.rs @@ -9,7 +9,7 @@ // except according to those terms. extern crate cci_lib; -use cci_lib::{cci_fn}; +use cci_lib::cci_fn; fn call1() -> uint { cci_fn() diff --git a/src/test/run-pass/builtin-superkinds-in-metadata.rs b/src/test/run-pass/builtin-superkinds-in-metadata.rs index e38a7bac67a..717348652ed 100644 --- a/src/test/run-pass/builtin-superkinds-in-metadata.rs +++ b/src/test/run-pass/builtin-superkinds-in-metadata.rs @@ -17,7 +17,7 @@ extern crate trait_superkinds_in_metadata; use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare}; -use trait_superkinds_in_metadata::{RequiresCopy}; +use trait_superkinds_in_metadata::RequiresCopy; use std::marker; #[derive(Copy)] diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index ecce97a3013..29d963bb704 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -13,7 +13,7 @@ #![allow(unknown_features)] #![feature(unboxed_closures, old_path, std_misc)] -use std::old_path::{Path}; +use std::old_path::Path; use std::old_path; use std::result; use std::thunk::Thunk; diff --git a/src/test/run-pass/overloaded-calls-zero-args.rs b/src/test/run-pass/overloaded-calls-zero-args.rs index 110109018db..8df4adf6713 100644 --- a/src/test/run-pass/overloaded-calls-zero-args.rs +++ b/src/test/run-pass/overloaded-calls-zero-args.rs @@ -12,7 +12,7 @@ #![feature(unboxed_closures, core)] -use std::ops::{FnMut}; +use std::ops::FnMut; struct S { x: i32, -- cgit 1.4.1-3-g733a5 From 6b7c5b9f08bba3b58d322322f630c6f7be5c7cfe Mon Sep 17 00:00:00 2001 From: Valerii Hiora Date: Sat, 28 Mar 2015 17:18:03 +0200 Subject: iOS: int/uint fallout --- src/libstd/sys/unix/backtrace.rs | 4 ++-- src/libstd/sys/unix/os.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index b46d390826c..99a554a835f 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -122,9 +122,9 @@ pub fn write(w: &mut Write) -> io::Result<()> { try!(writeln!(w, "stack backtrace:")); // 100 lines should be enough - const SIZE: uint = 100; + const SIZE: usize = 100; let mut buf: [*mut libc::c_void; SIZE] = unsafe {mem::zeroed()}; - let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as uint}; + let cnt = unsafe { backtrace(buf.as_mut_ptr(), SIZE as libc::c_int) as usize}; // skipping the first one as it is write itself let iter = (1..cnt).map(|i| { diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 724156d81d8..fab443feebd 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -339,7 +339,7 @@ pub fn args() -> Args { let info = objc_msgSend(klass, process_info_sel); let args = objc_msgSend(info, arguments_sel); - let cnt: int = mem::transmute(objc_msgSend(args, count_sel)); + let cnt: usize = mem::transmute(objc_msgSend(args, count_sel)); for i in (0..cnt) { let tmp = objc_msgSend(args, object_at_sel, i); let utf_c_str: *const libc::c_char = -- cgit 1.4.1-3-g733a5 From d502f4221fd5472c4a7905cdc3c59533e9612822 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 11 Mar 2015 22:41:24 -0700 Subject: Remove IteratorExt All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change] --- src/libcollections/linked_list.rs | 2 +- src/libcollections/slice.rs | 5 +- src/libcollections/str.rs | 2 +- src/libcollections/vec_deque.rs | 2 +- src/libcollectionstest/bench.rs | 2 +- src/libcore/fmt/float.rs | 2 +- src/libcore/fmt/mod.rs | 2 +- src/libcore/fmt/num.rs | 2 +- src/libcore/iter.rs | 183 ++++++++++++++++++----------------- src/libcore/num/mod.rs | 2 +- src/libcore/option.rs | 2 +- src/libcore/prelude.rs | 2 +- src/libcore/result.rs | 3 +- src/libcore/str/mod.rs | 4 +- src/libstd/collections/hash/map.rs | 2 +- src/libstd/collections/hash/set.rs | 4 +- src/libstd/collections/hash/table.rs | 2 +- src/libstd/dynamic_lib.rs | 2 +- src/libstd/ffi/c_str.rs | 2 +- src/libstd/io/mod.rs | 2 +- src/libstd/old_io/buffered.rs | 2 +- src/libstd/old_io/mem.rs | 2 +- src/libstd/old_io/mod.rs | 2 +- src/libstd/old_io/net/addrinfo.rs | 2 +- src/libstd/old_io/net/ip.rs | 2 +- src/libstd/old_io/tempfile.rs | 2 +- src/libstd/old_path/mod.rs | 2 +- src/libstd/old_path/posix.rs | 4 +- src/libstd/old_path/windows.rs | 4 +- src/libstd/os.rs | 2 +- src/libstd/prelude/v1.rs | 2 +- src/libstd/rand/mod.rs | 2 +- src/libstd/sys/windows/process2.rs | 2 +- 33 files changed, 130 insertions(+), 129 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index 908c78a17f4..5b392c87652 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -951,7 +951,7 @@ impl Hash for LinkedList { #[cfg(test)] mod test { use std::clone::Clone; - use std::iter::{Iterator, IteratorExt}; + use std::iter::Iterator; use std::option::Option::{Some, None, self}; use std::rand; use std::thread; diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 83e632e6c96..ba1ab75de80 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -76,7 +76,6 @@ //! iterators. //! * Further methods that return iterators are `.split()`, `.splitn()`, //! `.chunks()`, `.windows()` and more. - #![doc(primitive = "slice")] #![stable(feature = "rust1", since = "1.0.0")] @@ -85,7 +84,7 @@ use core::convert::AsRef; use core::clone::Clone; use core::cmp::Ordering::{self, Greater, Less}; use core::cmp::{self, Ord, PartialEq}; -use core::iter::{Iterator, IteratorExt}; +use core::iter::Iterator; use core::iter::MultiplicativeIterator; use core::marker::Sized; use core::mem::size_of; @@ -131,7 +130,7 @@ mod hack { use alloc::boxed::Box; use core::clone::Clone; #[cfg(test)] - use core::iter::{Iterator, IteratorExt}; + use core::iter::Iterator; use core::mem; #[cfg(test)] use core::option::Option::{Some, None}; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index aaa73badcac..0665abc9e95 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -58,7 +58,7 @@ use self::DecompositionType::*; use core::clone::Clone; use core::iter::AdditiveIterator; -use core::iter::{Iterator, IteratorExt, Extend}; +use core::iter::{Iterator, Extend}; use core::option::Option::{self, Some, None}; use core::result::Result; use core::str as core_str; diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 944908e7b4e..8f3f4e6b890 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -1785,7 +1785,7 @@ impl fmt::Debug for VecDeque { #[cfg(test)] mod test { - use core::iter::{IteratorExt, self}; + use core::iter::{Iterator, self}; use core::option::Option::Some; use test; diff --git a/src/libcollectionstest/bench.rs b/src/libcollectionstest/bench.rs index 2396a577589..e883b07dc5a 100644 --- a/src/libcollectionstest/bench.rs +++ b/src/libcollectionstest/bench.rs @@ -66,7 +66,7 @@ macro_rules! map_find_rand_bench { ($name: ident, $n: expr, $map: ident) => ( #[bench] pub fn $name(b: &mut ::test::Bencher) { - use std::iter::IteratorExt; + use std::iter::Iterator; use std::rand::Rng; use std::rand; use std::vec::Vec; diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index ee2951602c7..6e82b18abc6 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -17,7 +17,7 @@ pub use self::SignFormat::*; use char; use char::CharExt; use fmt; -use iter::IteratorExt; +use iter::Iterator; use num::{cast, Float, ToPrimitive}; use num::FpCategory as Fp; use ops::FnOnce; diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index aa0d0a1539a..a3de23bd7f3 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -15,7 +15,7 @@ use any; use cell::{Cell, RefCell, Ref, RefMut, BorrowState}; use char::CharExt; -use iter::{Iterator, IteratorExt}; +use iter::Iterator; use marker::{Copy, PhantomData, Sized}; use mem; use option::Option; diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 49da99b97cb..974252a92af 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -15,7 +15,7 @@ #![allow(unsigned_negation)] use fmt; -use iter::IteratorExt; +use iter::Iterator; use num::{Int, cast}; use slice::SliceExt; use str; diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index da89dda3af1..bb057c553db 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -71,6 +71,8 @@ use option::Option::{Some, None}; use marker::Sized; use usize; +fn _assert_is_object_safe(_: &Iterator) {} + /// An interface for dealing with "external iterators". These types of iterators /// can be resumed at any time as all state is stored internally as opposed to /// being located on the call stack. @@ -101,62 +103,7 @@ pub trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn size_hint(&self) -> (usize, Option) { (0, None) } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I { - type Item = I::Item; - fn next(&mut self) -> Option { (**self).next() } - fn size_hint(&self) -> (usize, Option) { (**self).size_hint() } -} - -/// Conversion from an `Iterator` -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \ - built from an iterator over elements of type `{A}`"] -pub trait FromIterator { - /// Build a container with elements from something iterable. - #[stable(feature = "rust1", since = "1.0.0")] - fn from_iter>(iterator: T) -> Self; -} - -/// Conversion into an `Iterator` -#[stable(feature = "rust1", since = "1.0.0")] -pub trait IntoIterator { - /// The type of the elements being iterated - #[stable(feature = "rust1", since = "1.0.0")] - type Item; - - /// A container for iterating over elements of type Item - #[stable(feature = "rust1", since = "1.0.0")] - type IntoIter: Iterator; - - /// Consumes `Self` and returns an iterator over it - #[stable(feature = "rust1", since = "1.0.0")] - fn into_iter(self) -> Self::IntoIter; -} -#[stable(feature = "rust1", since = "1.0.0")] -impl IntoIterator for I { - type Item = I::Item; - type IntoIter = I; - - fn into_iter(self) -> I { - self - } -} - -/// A type growable from an `Iterator` implementation -#[stable(feature = "rust1", since = "1.0.0")] -pub trait Extend { - /// Extend a container with the elements yielded by an arbitrary iterator - #[stable(feature = "rust1", since = "1.0.0")] - fn extend>(&mut self, iterable: T); -} - -/// An extension trait providing numerous methods applicable to all iterators. -#[stable(feature = "rust1", since = "1.0.0")] -pub trait IteratorExt: Iterator + Sized { /// Counts the number of elements in this iterator. /// /// # Examples @@ -167,7 +114,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn count(self) -> usize { + fn count(self) -> usize where Self: Sized { self.fold(0, |cnt, _x| cnt + 1) } @@ -181,7 +128,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn last(self) -> Option { + fn last(self) -> Option where Self: Sized { let mut last = None; for x in self { last = Some(x); } last @@ -200,7 +147,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn nth(&mut self, mut n: usize) -> Option { + fn nth(&mut self, mut n: usize) -> Option where Self: Sized { for x in self.by_ref() { if n == 0 { return Some(x) } n -= 1; @@ -225,7 +172,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn chain(self, other: U) -> Chain where - U: Iterator, + Self: Sized, U: Iterator, { Chain{a: self, b: other, flag: false} } @@ -260,7 +207,7 @@ pub trait IteratorExt: Iterator + Sized { /// both produce the same output. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn zip(self, other: U) -> Zip { + fn zip(self, other: U) -> Zip where Self: Sized { Zip{a: self, b: other} } @@ -279,7 +226,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn map(self, f: F) -> Map where - F: FnMut(Self::Item) -> B, + Self: Sized, F: FnMut(Self::Item) -> B, { Map{iter: self, f: f} } @@ -299,7 +246,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn filter

(self, predicate: P) -> Filter where - P: FnMut(&Self::Item) -> bool, + Self: Sized, P: FnMut(&Self::Item) -> bool, { Filter{iter: self, predicate: predicate} } @@ -319,7 +266,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn filter_map(self, f: F) -> FilterMap where - F: FnMut(Self::Item) -> Option, + Self: Sized, F: FnMut(Self::Item) -> Option, { FilterMap { iter: self, f: f } } @@ -341,7 +288,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn enumerate(self) -> Enumerate { + fn enumerate(self) -> Enumerate where Self: Sized { Enumerate{iter: self, count: 0} } @@ -365,7 +312,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn peekable(self) -> Peekable { + fn peekable(self) -> Peekable where Self: Sized { Peekable{iter: self, peeked: None} } @@ -386,7 +333,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn skip_while

(self, predicate: P) -> SkipWhile where - P: FnMut(&Self::Item) -> bool, + Self: Sized, P: FnMut(&Self::Item) -> bool, { SkipWhile{iter: self, flag: false, predicate: predicate} } @@ -407,7 +354,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn take_while

(self, predicate: P) -> TakeWhile where - P: FnMut(&Self::Item) -> bool, + Self: Sized, P: FnMut(&Self::Item) -> bool, { TakeWhile{iter: self, flag: false, predicate: predicate} } @@ -426,7 +373,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn skip(self, n: usize) -> Skip { + fn skip(self, n: usize) -> Skip where Self: Sized { Skip{iter: self, n: n} } @@ -445,7 +392,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn take(self, n: usize) -> Take { + fn take(self, n: usize) -> Take where Self: Sized, { Take{iter: self, n: n} } @@ -472,7 +419,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn scan(self, initial_state: St, f: F) -> Scan - where F: FnMut(&mut St, Self::Item) -> Option, + where Self: Sized, F: FnMut(&mut St, Self::Item) -> Option, { Scan{iter: self, f: f, state: initial_state} } @@ -495,7 +442,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn flat_map(self, f: F) -> FlatMap - where U: Iterator, F: FnMut(Self::Item) -> U, + where Self: Sized, U: Iterator, F: FnMut(Self::Item) -> U, { FlatMap{iter: self, f: f, frontiter: None, backiter: None } } @@ -529,7 +476,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn fuse(self) -> Fuse { + fn fuse(self) -> Fuse where Self: Sized { Fuse{iter: self, done: false} } @@ -555,7 +502,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn inspect(self, f: F) -> Inspect where - F: FnMut(&Self::Item), + Self: Sized, F: FnMut(&Self::Item), { Inspect{iter: self, f: f} } @@ -575,7 +522,7 @@ pub trait IteratorExt: Iterator + Sized { /// assert!(it.next() == Some(5)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn by_ref(&mut self) -> &mut Self { self } + fn by_ref(&mut self) -> &mut Self where Self: Sized { self } /// Loops through the entire iterator, collecting all of the elements into /// a container implementing `FromIterator`. @@ -590,7 +537,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn collect>(self) -> B { + fn collect>(self) -> B where Self: Sized { FromIterator::from_iter(self) } @@ -609,6 +556,7 @@ pub trait IteratorExt: Iterator + Sized { #[unstable(feature = "core", reason = "recently added as part of collections reform")] fn partition(self, mut f: F) -> (B, B) where + Self: Sized, B: Default + Extend, F: FnMut(&Self::Item) -> bool { @@ -638,7 +586,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn fold(self, init: B, mut f: F) -> B where - F: FnMut(B, Self::Item) -> B, + Self: Sized, F: FnMut(B, Self::Item) -> B, { let mut accum = init; for x in self { @@ -658,7 +606,9 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn all(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool { + fn all(&mut self, mut f: F) -> bool where + Self: Sized, F: FnMut(Self::Item) -> bool + { for x in self.by_ref() { if !f(x) { return false; } } true } @@ -679,7 +629,10 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn any(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool { + fn any(&mut self, mut f: F) -> bool where + Self: Sized, + F: FnMut(Self::Item) -> bool + { for x in self.by_ref() { if f(x) { return true; } } false } @@ -699,6 +652,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn find

(&mut self, mut predicate: P) -> Option where + Self: Sized, P: FnMut(&Self::Item) -> bool, { for x in self.by_ref() { @@ -722,6 +676,7 @@ pub trait IteratorExt: Iterator + Sized { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn position

(&mut self, mut predicate: P) -> Option where + Self: Sized, P: FnMut(Self::Item) -> bool, { let mut i = 0; @@ -752,7 +707,7 @@ pub trait IteratorExt: Iterator + Sized { #[stable(feature = "rust1", since = "1.0.0")] fn rposition

(&mut self, mut predicate: P) -> Option where P: FnMut(Self::Item) -> bool, - Self: ExactSizeIterator + DoubleEndedIterator + Self: Sized + ExactSizeIterator + DoubleEndedIterator { let mut i = self.len(); @@ -775,7 +730,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn max(self) -> Option where Self::Item: Ord + fn max(self) -> Option where Self: Sized, Self::Item: Ord { self.fold(None, |max, x| { match max { @@ -795,7 +750,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn min(self) -> Option where Self::Item: Ord + fn min(self) -> Option where Self: Sized, Self::Item: Ord { self.fold(None, |min, x| { match min { @@ -837,7 +792,7 @@ pub trait IteratorExt: Iterator + Sized { /// assert!(a.iter().min_max() == MinMax(&1, &1)); /// ``` #[unstable(feature = "core", reason = "return type may change")] - fn min_max(mut self) -> MinMaxResult where Self::Item: Ord + fn min_max(mut self) -> MinMaxResult where Self: Sized, Self::Item: Ord { let (mut min, mut max) = match self.next() { None => return NoElements, @@ -897,6 +852,7 @@ pub trait IteratorExt: Iterator + Sized { #[unstable(feature = "core", reason = "may want to produce an Ordering directly; see #15311")] fn max_by(self, mut f: F) -> Option where + Self: Sized, F: FnMut(&Self::Item) -> B, { self.fold(None, |max: Option<(Self::Item, B)>, x| { @@ -928,6 +884,7 @@ pub trait IteratorExt: Iterator + Sized { #[unstable(feature = "core", reason = "may want to produce an Ordering directly; see #15311")] fn min_by(self, mut f: F) -> Option where + Self: Sized, F: FnMut(&Self::Item) -> B, { self.fold(None, |min: Option<(Self::Item, B)>, x| { @@ -957,7 +914,7 @@ pub trait IteratorExt: Iterator + Sized { /// `std::usize::MAX` elements of the original iterator. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn rev(self) -> Rev { + fn rev(self) -> Rev where Self: Sized { Rev{iter: self} } @@ -979,7 +936,7 @@ pub trait IteratorExt: Iterator + Sized { fn unzip(self) -> (FromA, FromB) where FromA: Default + Extend, FromB: Default + Extend, - Self: Iterator, + Self: Sized + Iterator, { struct SizeHint(usize, Option, marker::PhantomData); impl Iterator for SizeHint { @@ -1010,7 +967,7 @@ pub trait IteratorExt: Iterator + Sized { /// converting an Iterator<&T> to an Iterator. #[stable(feature = "rust1", since = "1.0.0")] fn cloned<'a, T: 'a>(self) -> Cloned - where Self: Iterator, T: Clone + where Self: Sized + Iterator, T: Clone { Cloned { it: self } } @@ -1028,7 +985,7 @@ pub trait IteratorExt: Iterator + Sized { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] - fn cycle(self) -> Cycle where Self: Clone { + fn cycle(self) -> Cycle where Self: Sized + Clone { Cycle{orig: self.clone(), iter: self} } @@ -1036,7 +993,7 @@ pub trait IteratorExt: Iterator + Sized { #[unstable(feature = "core", reason = "uncertain about placement or widespread use")] fn reverse_in_place<'a, T: 'a>(&mut self) where - Self: Iterator + DoubleEndedIterator + Self: Sized + Iterator + DoubleEndedIterator { loop { match (self.next(), self.next_back()) { @@ -1048,7 +1005,55 @@ pub trait IteratorExt: Iterator + Sized { } #[stable(feature = "rust1", since = "1.0.0")] -impl IteratorExt for I where I: Iterator {} +impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I { + type Item = I::Item; + fn next(&mut self) -> Option { (**self).next() } + fn size_hint(&self) -> (usize, Option) { (**self).size_hint() } +} + +/// Conversion from an `Iterator` +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \ + built from an iterator over elements of type `{A}`"] +pub trait FromIterator { + /// Build a container with elements from something iterable. + #[stable(feature = "rust1", since = "1.0.0")] + fn from_iter>(iterator: T) -> Self; +} + +/// Conversion into an `Iterator` +#[stable(feature = "rust1", since = "1.0.0")] +pub trait IntoIterator { + /// The type of the elements being iterated + #[stable(feature = "rust1", since = "1.0.0")] + type Item; + + /// A container for iterating over elements of type Item + #[stable(feature = "rust1", since = "1.0.0")] + type IntoIter: Iterator; + + /// Consumes `Self` and returns an iterator over it + #[stable(feature = "rust1", since = "1.0.0")] + fn into_iter(self) -> Self::IntoIter; +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl IntoIterator for I { + type Item = I::Item; + type IntoIter = I; + + fn into_iter(self) -> I { + self + } +} + +/// A type growable from an `Iterator` implementation +#[stable(feature = "rust1", since = "1.0.0")] +pub trait Extend { + /// Extend a container with the elements yielded by an arbitrary iterator + #[stable(feature = "rust1", since = "1.0.0")] + fn extend>(&mut self, iterable: T); +} /// A range iterator able to yield elements from both ends /// @@ -1256,7 +1261,7 @@ impl_multiplicative! { usize, 1 } impl_multiplicative! { f32, 1.0 } impl_multiplicative! { f64, 1.0 } -/// `MinMaxResult` is an enum returned by `min_max`. See `IteratorOrdExt::min_max` for more detail. +/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for more detail. #[derive(Clone, PartialEq, Debug)] #[unstable(feature = "core", reason = "unclear whether such a fine-grained result is widely useful")] diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 745a1213ad5..dc98bb8e603 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -23,7 +23,7 @@ use cmp::{PartialEq, Eq, PartialOrd, Ord}; use error::Error; use fmt; use intrinsics; -use iter::IteratorExt; +use iter::Iterator; use marker::Copy; use mem::size_of; use ops::{Add, Sub, Mul, Div, Rem, Neg}; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b3bb4a980eb..cd82936b0b3 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -149,7 +149,7 @@ use clone::Clone; use cmp::{Eq, Ord}; use default::Default; use iter::ExactSizeIterator; -use iter::{Iterator, IteratorExt, DoubleEndedIterator, FromIterator, IntoIterator}; +use iter::{Iterator, DoubleEndedIterator, FromIterator, IntoIterator}; use mem; use ops::FnOnce; use result::Result::{Ok, Err}; diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 424829939b9..448b90c0dbd 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -37,7 +37,7 @@ pub use char::CharExt; pub use clone::Clone; pub use cmp::{PartialEq, PartialOrd, Eq, Ord}; pub use convert::{AsRef, AsMut, Into, From}; -pub use iter::{Extend, IteratorExt}; +pub use iter::Extend; pub use iter::{Iterator, DoubleEndedIterator}; pub use iter::{ExactSizeIterator}; pub use option::Option::{self, Some, None}; diff --git a/src/libcore/result.rs b/src/libcore/result.rs index c7e166b49be..eff04dd5903 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -243,8 +243,7 @@ use self::Result::{Ok, Err}; use clone::Clone; use fmt; -use iter::{Iterator, IteratorExt, DoubleEndedIterator, - FromIterator, ExactSizeIterator, IntoIterator}; +use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator}; use ops::{FnMut, FnOnce}; use option::Option::{self, None, Some}; #[allow(deprecated)] diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 13075fd5ee9..189cf3d3498 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -25,7 +25,7 @@ use default::Default; use error::Error; use fmt; use iter::ExactSizeIterator; -use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator}; +use iter::{Map, Iterator, DoubleEndedIterator}; use marker::Sized; use mem; #[allow(deprecated)] @@ -1237,7 +1237,7 @@ Section: Trait implementations mod traits { use cmp::{Ordering, Ord, PartialEq, PartialOrd, Eq}; use cmp::Ordering::{Less, Equal, Greater}; - use iter::IteratorExt; + use iter::Iterator; use option::Option; use option::Option::Some; use ops; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index f9e1cb877b6..9e229a28279 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -20,7 +20,7 @@ use cmp::{max, Eq, PartialEq}; use default::Default; use fmt::{self, Debug}; use hash::{Hash, SipHasher}; -use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map}; +use iter::{self, Iterator, ExactSizeIterator, IntoIterator, FromIterator, Extend, Map}; use marker::Sized; use mem::{self, replace}; use ops::{Deref, FnMut, FnOnce, Index}; diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 0933b4f662a..34b905595b7 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -18,9 +18,7 @@ use default::Default; use fmt::Debug; use fmt; use hash::Hash; -use iter::{ - Iterator, IntoIterator, ExactSizeIterator, IteratorExt, FromIterator, Map, Chain, Extend, -}; +use iter::{Iterator, IntoIterator, ExactSizeIterator, FromIterator, Map, Chain, Extend}; use ops::{BitOr, BitAnd, BitXor, Sub}; use option::Option::{Some, None, self}; diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 710f0fe19db..8f659334538 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -15,7 +15,7 @@ use self::BucketState::*; use clone::Clone; use cmp; use hash::{Hash, Hasher}; -use iter::{Iterator, IteratorExt, ExactSizeIterator, count}; +use iter::{Iterator, ExactSizeIterator, count}; use marker::{Copy, Send, Sync, Sized, self}; use mem::{min_align_of, size_of}; use mem; diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index b96fe94dd2e..d8a95133d94 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -261,7 +261,7 @@ mod dl { #[cfg(target_os = "windows")] mod dl { use ffi::OsStr; - use iter::IteratorExt; + use iter::Iterator; use libc; use libc::consts::os::extra::ERROR_CALL_NOT_IMPLEMENTED; use ops::FnOnce; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 8b19d160172..a00f7708025 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -15,7 +15,7 @@ use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; use error::{Error, FromError}; use fmt; use io; -use iter::IteratorExt; +use iter::Iterator; use libc; use mem; #[allow(deprecated)] diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 5d62f1341e3..be0b3687bad 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -16,7 +16,7 @@ use cmp; use unicode::str as core_str; use error as std_error; use fmt; -use iter::{self, Iterator, IteratorExt, Extend}; +use iter::{self, Iterator, Extend}; use marker::Sized; use ops::{Drop, FnOnce}; use option::Option::{self, Some, None}; diff --git a/src/libstd/old_io/buffered.rs b/src/libstd/old_io/buffered.rs index 502f414d50b..b8b7df75003 100644 --- a/src/libstd/old_io/buffered.rs +++ b/src/libstd/old_io/buffered.rs @@ -15,7 +15,7 @@ use cmp; use fmt; use old_io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult}; -use iter::{IteratorExt, ExactSizeIterator, repeat}; +use iter::{Iterator, ExactSizeIterator, repeat}; use ops::Drop; use option::Option; use option::Option::{Some, None}; diff --git a/src/libstd/old_io/mem.rs b/src/libstd/old_io/mem.rs index 76a448c4aae..5f20c383bb7 100644 --- a/src/libstd/old_io/mem.rs +++ b/src/libstd/old_io/mem.rs @@ -400,7 +400,7 @@ mod test { extern crate test as test_crate; use old_io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek, Buffer}; use prelude::v1::{Ok, Err, Vec, AsSlice}; - use prelude::v1::IteratorExt; + use prelude::v1::Iterator; use old_io; use iter::repeat; use self::test_crate::Bencher; diff --git a/src/libstd/old_io/mod.rs b/src/libstd/old_io/mod.rs index aaa55c5d1d9..df8ac78f7e5 100644 --- a/src/libstd/old_io/mod.rs +++ b/src/libstd/old_io/mod.rs @@ -268,7 +268,7 @@ use default::Default; use error::Error; use fmt; use isize; -use iter::{Iterator, IteratorExt}; +use iter::Iterator; use marker::{PhantomFn, Sized}; use mem::transmute; use ops::FnOnce; diff --git a/src/libstd/old_io/net/addrinfo.rs b/src/libstd/old_io/net/addrinfo.rs index 6237bb97f3e..739439ebd15 100644 --- a/src/libstd/old_io/net/addrinfo.rs +++ b/src/libstd/old_io/net/addrinfo.rs @@ -19,7 +19,7 @@ pub use self::SocketType::*; pub use self::Flag::*; pub use self::Protocol::*; -use iter::IteratorExt; +use iter::Iterator; use old_io::IoResult; use old_io::net::ip::{SocketAddr, IpAddr}; use option::Option; diff --git a/src/libstd/old_io/net/ip.rs b/src/libstd/old_io/net/ip.rs index ba3578f7425..26e1bb6550b 100644 --- a/src/libstd/old_io/net/ip.rs +++ b/src/libstd/old_io/net/ip.rs @@ -21,7 +21,7 @@ use boxed::Box; use fmt; use old_io::{self, IoResult, IoError}; use old_io::net; -use iter::{Iterator, IteratorExt}; +use iter::Iterator; use ops::{FnOnce, FnMut}; use option::Option; use option::Option::{None, Some}; diff --git a/src/libstd/old_io/tempfile.rs b/src/libstd/old_io/tempfile.rs index 572cfa1395d..0a2cc517a06 100644 --- a/src/libstd/old_io/tempfile.rs +++ b/src/libstd/old_io/tempfile.rs @@ -12,7 +12,7 @@ #![allow(deprecated)] // rand use env; -use iter::IteratorExt; +use iter::Iterator; use old_io::{fs, IoError, IoErrorKind, IoResult}; use old_io; use ops::Drop; diff --git a/src/libstd/old_path/mod.rs b/src/libstd/old_path/mod.rs index 50bda04b5d0..c405df2824e 100644 --- a/src/libstd/old_path/mod.rs +++ b/src/libstd/old_path/mod.rs @@ -70,7 +70,7 @@ use core::marker::Sized; use ffi::CString; use clone::Clone; use fmt; -use iter::IteratorExt; +use iter::Iterator; use option::Option; use option::Option::{None, Some}; use str; diff --git a/src/libstd/old_path/posix.rs b/src/libstd/old_path/posix.rs index 67bfe2bd770..bbc1756bee6 100644 --- a/src/libstd/old_path/posix.rs +++ b/src/libstd/old_path/posix.rs @@ -16,7 +16,7 @@ use fmt; use hash; use old_io::Writer; use iter::{AdditiveIterator, Extend}; -use iter::{Iterator, IteratorExt, Map}; +use iter::{Iterator, Map}; use marker::Sized; use option::Option::{self, Some, None}; use result::Result::{self, Ok, Err}; @@ -444,13 +444,13 @@ mod tests { use super::*; use clone::Clone; - use iter::IteratorExt; use option::Option::{self, Some, None}; use old_path::GenericPath; use slice::AsSlice; use str::{self, Str}; use string::ToString; use vec::Vec; + use iter::Iterator; macro_rules! t { (s: $path:expr, $exp:expr) => ( diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs index 869a8127301..bd67855bf1b 100644 --- a/src/libstd/old_path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -21,7 +21,7 @@ use fmt; use hash; use old_io::Writer; use iter::{AdditiveIterator, Extend}; -use iter::{Iterator, IteratorExt, Map, repeat}; +use iter::{Iterator, Map, repeat}; use mem; use option::Option::{self, Some, None}; use result::Result::{self, Ok, Err}; @@ -1126,7 +1126,7 @@ mod tests { use super::*; use clone::Clone; - use iter::IteratorExt; + use iter::Iterator; use option::Option::{self, Some, None}; use old_path::GenericPath; use slice::AsSlice; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 2e8521cc94b..e19c734b8a3 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -43,7 +43,7 @@ use env; use error::{FromError, Error}; use ffi::{OsString, OsStr}; use fmt; -use iter::{Iterator, IteratorExt}; +use iter::Iterator; use libc::{c_void, c_int, c_char}; use libc; use marker::{Copy, Send}; diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs index 6e12ac1a226..611dd85a71b 100644 --- a/src/libstd/prelude/v1.rs +++ b/src/libstd/prelude/v1.rs @@ -36,7 +36,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use iter::ExactSizeIterator; #[stable(feature = "rust1", since = "1.0.0")] -#[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend}; +#[doc(no_inline)] pub use iter::{Iterator, Extend}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] pub use option::Option::{self, Some, None}; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index cfd4e17c021..fad57323d34 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -231,7 +231,7 @@ use cell::RefCell; use clone::Clone; use old_io::IoResult; -use iter::{Iterator, IteratorExt}; +use iter::Iterator; use mem; use rc::Rc; use result::Result::{Ok, Err}; diff --git a/src/libstd/sys/windows/process2.rs b/src/libstd/sys/windows/process2.rs index 4c2777459dd..9e9bb86446e 100644 --- a/src/libstd/sys/windows/process2.rs +++ b/src/libstd/sys/windows/process2.rs @@ -127,7 +127,7 @@ impl Process { use env::split_paths; use mem; - use iter::IteratorExt; + use iter::Iterator; // To have the spawning semantics of unix/windows stay the same, we need to // read the *child's* PATH if one is provided. See #15149 for more details. -- cgit 1.4.1-3-g733a5