trait Foo {}
trait Bar<T> {}
-fn sendable_foo(f: Box<Foo:Send>) { /* ... */ }
-fn shareable_bar<T: Share>(b: &Bar<T>: Share) { /* ... */ }
+fn sendable_foo(f: Box<Foo + Send>) { /* ... */ }
+fn shareable_bar<T: Share>(b: &Bar<T> + Share) { /* ... */ }
~~~
When no colon is specified (such as the type `~Foo`), it is inferred that the
}
impl fmt::Show for BitvSet {
- #[cfg(stage0)]
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(fmt, r"\{"));
- let mut first = true;
- for n in self.iter() {
- if !first {
- try!(write!(fmt, ", "));
- }
- try!(write!(fmt, "{}", n));
- first = false;
- }
- write!(fmt, r"\}")
- }
- #[cfg(not(stage0))]
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "{{"));
let mut first = true;
}
impl<V: fmt::Show> fmt::Show for SmallIntMap<V> {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, r"\{"));
-
- for (i, (k, v)) in self.iter().enumerate() {
- if i != 0 { try!(write!(f, ", ")); }
- try!(write!(f, "{}: {}", k, *v));
- }
-
- write!(f, r"\}")
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{{"));
}
impl<K: Ord + Show, V: Show> Show for TreeMap<K, V> {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, r"\{"));
-
- for (i, (k, v)) in self.iter().enumerate() {
- if i != 0 { try!(write!(f, ", ")); }
- try!(write!(f, "{}: {}", *k, *v));
- }
-
- write!(f, r"\}")
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{{"));
}
impl<T: Ord + Show> Show for TreeSet<T> {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, r"\{"));
-
- for (i, x) in self.iter().enumerate() {
- if i != 0 { try!(write!(f, ", ")); }
- try!(write!(f, "{}", *x));
- }
-
- write!(f, r"\}")
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{{"));
}
impl<T: Copy + Show> Show for Cell<T> {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut Formatter) -> Result {
- write!(f, r"Cell \{ value: {} \}", self.get())
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut Formatter) -> Result {
write!(f, "Cell {{ value: {} }}", self.get())
}
//! these can be statically allocated and are slightly optimized for the runtime
-#[cfg(stage0)]
-use option::Option;
-
#[doc(hidden)]
pub enum Piece<'a> {
String(&'a str),
pub struct Argument<'a> {
pub position: Position,
pub format: FormatSpec,
- #[cfg(stage0)]
- pub method: Option<uint>,
}
#[doc(hidden)]
fn visit_char(&mut self) -> bool;
- #[cfg(stage0)]
- fn visit_estr_box(&mut self) -> bool;
- #[cfg(stage0)]
- fn visit_estr_uniq(&mut self) -> bool;
fn visit_estr_slice(&mut self) -> bool;
fn visit_estr_fixed(&mut self, n: uint, sz: uint, align: uint) -> bool;
fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
- #[cfg(stage0)]
- fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
- #[cfg(stage0)]
- fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool;
fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
mtbl: uint, inner: *TyDesc) -> bool;
true
}
- #[cfg(stage0)]
- fn visit_estr_box(&mut self) -> bool {
- true
- }
-
- #[cfg(stage0)]
- fn visit_estr_uniq(&mut self) -> bool {
- false
- }
-
fn visit_estr_slice(&mut self) -> bool {
self.align_to::<&'static str>();
if ! self.inner.visit_estr_slice() { return false; }
true
}
- #[cfg(stage0)]
- fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
- true
- }
-
- #[cfg(stage0)]
- fn visit_evec_uniq(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
- false
- }
-
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.align_to::<&'static [u8]>();
if ! self.inner.visit_evec_slice(mtbl, inner) { return false; }
})
}
- #[cfg(stage0)]
- fn visit_estr_box(&mut self) -> bool {
- false
- }
-
- #[cfg(stage0)]
- fn visit_estr_uniq(&mut self) -> bool {
- false
- }
-
fn visit_estr_slice(&mut self) -> bool {
self.get::<&str>(|this, s| this.write_escaped_slice(*s))
}
})
}
- #[cfg(stage0)]
- fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
- true
- }
-
- #[cfg(stage0)]
- fn visit_evec_uniq(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
- true
- }
-
fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.get::<raw::Slice<()>>(|this, s| {
try!(this, this.writer.write(['&' as u8]));
use std::rt::exclusive::Exclusive;
/// This is the only exported function from this module.
-pub fn event_loop() -> Box<EventLoop:Send> {
- box BasicLoop::new() as Box<EventLoop:Send>
+pub fn event_loop() -> Box<EventLoop + Send> {
+ box BasicLoop::new() as Box<EventLoop + Send>
}
struct BasicLoop {
- work: Vec<proc():Send>, // pending work
- remotes: Vec<(uint, Box<Callback:Send>)>,
+ work: Vec<proc(): Send>, // pending work
+ remotes: Vec<(uint, Box<Callback + Send>)>,
next_remote: uint,
messages: Arc<Exclusive<Vec<Message>>>,
- idle: Option<Box<Callback:Send>>,
+ idle: Option<Box<Callback + Send>>,
idle_active: Option<Arc<atomics::AtomicBool>>,
}
}
// FIXME: Seems like a really weird requirement to have an event loop provide.
- fn pausable_idle_callback(&mut self, cb: Box<Callback:Send>)
- -> Box<PausableIdleCallback:Send> {
+ fn pausable_idle_callback(&mut self, cb: Box<Callback + Send>)
+ -> Box<PausableIdleCallback + Send> {
rtassert!(self.idle.is_none());
self.idle = Some(cb);
let a = Arc::new(atomics::AtomicBool::new(true));
self.idle_active = Some(a.clone());
- box BasicPausable { active: a } as Box<PausableIdleCallback:Send>
+ box BasicPausable { active: a } as Box<PausableIdleCallback + Send>
}
- fn remote_callback(&mut self, f: Box<Callback:Send>)
- -> Box<RemoteCallback:Send> {
+ fn remote_callback(&mut self, f: Box<Callback + Send>)
+ -> Box<RemoteCallback + Send> {
let id = self.next_remote;
self.next_remote += 1;
self.remotes.push((id, f));
box BasicRemote::new(self.messages.clone(), id) as
- Box<RemoteCallback:Send>
+ Box<RemoteCallback + Send>
}
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory> { None }
/// The return value is used as the process return code. 0 on success, 101 on
/// error.
pub fn start(argc: int, argv: **u8,
- event_loop_factory: fn() -> Box<rtio::EventLoop:Send>,
+ event_loop_factory: fn() -> Box<rtio::EventLoop + Send>,
main: proc():Send) -> int {
rt::init(argc, argv);
let mut main = Some(main);
///
/// This function will not return until all schedulers in the associated pool
/// have returned.
-pub fn run(event_loop_factory: fn() -> Box<rtio::EventLoop:Send>,
+pub fn run(event_loop_factory: fn() -> Box<rtio::EventLoop + Send>,
main: proc():Send) -> int {
// Create a scheduler pool and spawn the main task into this pool. We will
// get notified over a channel when the main task exits.
pub threads: uint,
/// A factory function used to create new event loops. If this is not
/// specified then the default event loop factory is used.
- pub event_loop_factory: fn() -> Box<rtio::EventLoop:Send>,
+ pub event_loop_factory: fn() -> Box<rtio::EventLoop + Send>,
}
impl PoolConfig {
stack_pool: StackPool,
deque_pool: deque::BufferPool<Box<task::GreenTask>>,
sleepers: SleeperList,
- factory: fn() -> Box<rtio::EventLoop:Send>,
+ factory: fn() -> Box<rtio::EventLoop + Send>,
task_state: TaskState,
tasks_done: Receiver<()>,
}
/// A fast XorShift rng for scheduler use
rng: XorShiftRng,
/// A toggleable idle callback
- idle_callback: Option<Box<PausableIdleCallback:Send>>,
+ idle_callback: Option<Box<PausableIdleCallback + Send>>,
/// A countdown that starts at a random value and is decremented
/// every time a yield check is performed. When it hits 0 a task
/// will yield.
// destroyed before it's actually destroyed.
/// The event loop used to drive the scheduler and perform I/O
- pub event_loop: Box<EventLoop:Send>,
+ pub event_loop: Box<EventLoop + Send>,
}
/// An indication of how hard to work on a given operation, the difference
// * Initialization Functions
pub fn new(pool_id: uint,
- event_loop: Box<EventLoop:Send>,
+ event_loop: Box<EventLoop + Send>,
work_queue: deque::Worker<Box<GreenTask>>,
work_queues: Vec<deque::Stealer<Box<GreenTask>>>,
sleeper_list: SleeperList,
}
pub fn new_special(pool_id: uint,
- event_loop: Box<EventLoop:Send>,
+ event_loop: Box<EventLoop + Send>,
work_queue: deque::Worker<Box<GreenTask>>,
work_queues: Vec<deque::Stealer<Box<GreenTask>>>,
sleeper_list: SleeperList,
pub fn bootstrap(mut ~self) {
// Build an Idle callback.
- let cb = box SchedRunner as Box<Callback:Send>;
+ let cb = box SchedRunner as Box<Callback + Send>;
self.idle_callback = Some(self.event_loop.pausable_idle_callback(cb));
// Create a task for the scheduler with an empty context.
// mutable reference to the event_loop to give it the "run"
// command.
unsafe {
- let event_loop: *mut Box<EventLoop:Send> = &mut self.event_loop;
+ let event_loop: *mut Box<EventLoop + Send> = &mut self.event_loop;
// Our scheduler must be in the task before the event loop
// is started.
stask.put_with_sched(self);
}
pub struct SchedHandle {
- remote: Box<RemoteCallback:Send>,
+ remote: Box<RemoteCallback + Send>,
queue: msgq::Producer<SchedMessage>,
pub sched_id: uint
}
/// Error log level
pub static ERROR: u32 = 1;
-local_data_key!(local_logger: Box<Logger:Send>)
+local_data_key!(local_logger: Box<Logger + Send>)
/// A trait used to represent an interface to a task-local logger. Each task
/// can have its own custom logger which can respond to logging messages
// frob the slot while we're doing the logging. This will destroy any logger
// set during logging.
let mut logger = local_logger.replace(None).unwrap_or_else(|| {
- box DefaultLogger { handle: io::stderr() } as Box<Logger:Send>
+ box DefaultLogger { handle: io::stderr() } as Box<Logger + Send>
});
logger.log(&LogRecord {
level: LogLevel(level),
/// Replaces the task-local logger with the specified logger, returning the old
/// logger.
-pub fn set_logger(logger: Box<Logger:Send>) -> Option<Box<Logger:Send>> {
+pub fn set_logger(logger: Box<Logger + Send>) -> Option<Box<Logger + Send>> {
local_logger.replace(Some(logger))
}
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
self.inner_write(buf)
}
- fn clone(&self) -> Box<rtio::RtioPipe:Send> {
- box FileDesc { inner: self.inner.clone() } as Box<rtio::RtioPipe:Send>
+ fn clone(&self) -> Box<rtio::RtioPipe + Send> {
+ box FileDesc { inner: self.inner.clone() } as Box<rtio::RtioPipe + Send>
}
// Only supported on named pipes currently. Note that this doesn't have an
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
self.inner_write(buf)
}
- fn clone(&self) -> Box<rtio::RtioPipe:Send> {
- box FileDesc { inner: self.inner.clone() } as Box<rtio::RtioPipe:Send>
+ fn clone(&self) -> Box<rtio::RtioPipe + Send> {
+ box FileDesc { inner: self.inner.clone() } as Box<rtio::RtioPipe + Send>
}
// Only supported on named pipes currently. Note that this doesn't have an
// networking
fn tcp_connect(&mut self, addr: rtio::SocketAddr,
timeout: Option<u64>)
- -> IoResult<Box<rtio::RtioTcpStream:Send>>
+ -> IoResult<Box<rtio::RtioTcpStream + Send>>
{
net::TcpStream::connect(addr, timeout).map(|s| {
- box s as Box<rtio::RtioTcpStream:Send>
+ box s as Box<rtio::RtioTcpStream + Send>
})
}
fn tcp_bind(&mut self, addr: rtio::SocketAddr)
- -> IoResult<Box<rtio::RtioTcpListener:Send>> {
+ -> IoResult<Box<rtio::RtioTcpListener + Send>> {
net::TcpListener::bind(addr).map(|s| {
- box s as Box<rtio::RtioTcpListener:Send>
+ box s as Box<rtio::RtioTcpListener + Send>
})
}
fn udp_bind(&mut self, addr: rtio::SocketAddr)
- -> IoResult<Box<rtio::RtioUdpSocket:Send>> {
+ -> IoResult<Box<rtio::RtioUdpSocket + Send>> {
net::UdpSocket::bind(addr).map(|u| {
- box u as Box<rtio::RtioUdpSocket:Send>
+ box u as Box<rtio::RtioUdpSocket + Send>
})
}
fn unix_bind(&mut self, path: &CString)
- -> IoResult<Box<rtio::RtioUnixListener:Send>> {
+ -> IoResult<Box<rtio::RtioUnixListener + Send>> {
pipe::UnixListener::bind(path).map(|s| {
- box s as Box<rtio::RtioUnixListener:Send>
+ box s as Box<rtio::RtioUnixListener + Send>
})
}
fn unix_connect(&mut self, path: &CString,
- timeout: Option<u64>) -> IoResult<Box<rtio::RtioPipe:Send>> {
+ timeout: Option<u64>) -> IoResult<Box<rtio::RtioPipe + Send>> {
pipe::UnixStream::connect(path, timeout).map(|s| {
- box s as Box<rtio::RtioPipe:Send>
+ box s as Box<rtio::RtioPipe + Send>
})
}
fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
// filesystem operations
fn fs_from_raw_fd(&mut self, fd: c_int, close: rtio::CloseBehavior)
- -> Box<rtio::RtioFileStream:Send> {
+ -> Box<rtio::RtioFileStream + Send> {
let close = match close {
rtio::CloseSynchronously | rtio::CloseAsynchronously => true,
rtio::DontClose => false
};
- box file::FileDesc::new(fd, close) as Box<rtio::RtioFileStream:Send>
+ box file::FileDesc::new(fd, close) as Box<rtio::RtioFileStream + Send>
}
fn fs_open(&mut self, path: &CString, fm: rtio::FileMode,
fa: rtio::FileAccess)
- -> IoResult<Box<rtio::RtioFileStream:Send>>
+ -> IoResult<Box<rtio::RtioFileStream + Send>>
{
- file::open(path, fm, fa).map(|fd| box fd as Box<rtio::RtioFileStream:Send>)
+ file::open(path, fm, fa).map(|fd| box fd as Box<rtio::RtioFileStream + Send>)
}
fn fs_unlink(&mut self, path: &CString) -> IoResult<()> {
file::unlink(path)
}
// misc
- fn timer_init(&mut self) -> IoResult<Box<rtio::RtioTimer:Send>> {
- timer::Timer::new().map(|t| box t as Box<rtio::RtioTimer:Send>)
+ fn timer_init(&mut self) -> IoResult<Box<rtio::RtioTimer + Send>> {
+ timer::Timer::new().map(|t| box t as Box<rtio::RtioTimer + Send>)
}
fn spawn(&mut self, cfg: rtio::ProcessConfig)
- -> IoResult<(Box<rtio::RtioProcess:Send>,
- Vec<Option<Box<rtio::RtioPipe:Send>>>)> {
+ -> IoResult<(Box<rtio::RtioProcess + Send>,
+ Vec<Option<Box<rtio::RtioPipe + Send>>>)> {
process::Process::spawn(cfg).map(|(p, io)| {
- (box p as Box<rtio::RtioProcess:Send>,
+ (box p as Box<rtio::RtioProcess + Send>,
io.move_iter().map(|p| p.map(|p| {
- box p as Box<rtio::RtioPipe:Send>
+ box p as Box<rtio::RtioPipe + Send>
})).collect())
})
}
fn kill(&mut self, pid: libc::pid_t, signum: int) -> IoResult<()> {
process::Process::kill(pid, signum)
}
- fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<rtio::RtioPipe:Send>> {
- Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioPipe:Send>)
+ fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<rtio::RtioPipe + Send>> {
+ Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioPipe + Send>)
}
fn tty_open(&mut self, fd: c_int, _readable: bool)
- -> IoResult<Box<rtio::RtioTTY:Send>> {
+ -> IoResult<Box<rtio::RtioTTY + Send>> {
#[cfg(unix)] use ERROR = libc::ENOTTY;
#[cfg(windows)] use ERROR = libc::ERROR_INVALID_HANDLE;
if unsafe { libc::isatty(fd) } != 0 {
- Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioTTY:Send>)
+ Ok(box file::FileDesc::new(fd, true) as Box<rtio::RtioTTY + Send>)
} else {
Err(IoError {
code: ERROR as uint,
}
}
fn signal(&mut self, _signal: int, _cb: Box<rtio::Callback>)
- -> IoResult<Box<rtio::RtioSignal:Send>> {
+ -> IoResult<Box<rtio::RtioSignal + Send>> {
Err(unimpl())
}
}
self.set_keepalive(None)
}
- fn clone(&self) -> Box<rtio::RtioTcpStream:Send> {
+ fn clone(&self) -> Box<rtio::RtioTcpStream + Send> {
box TcpStream {
inner: self.inner.clone(),
read_deadline: 0,
write_deadline: 0,
- } as Box<rtio::RtioTcpStream:Send>
+ } as Box<rtio::RtioTcpStream + Send>
}
fn close_write(&mut self) -> IoResult<()> {
}
impl rtio::RtioTcpListener for TcpListener {
- fn listen(~self) -> IoResult<Box<rtio::RtioTcpAcceptor:Send>> {
+ fn listen(~self) -> IoResult<Box<rtio::RtioTcpAcceptor + Send>> {
self.native_listen(128).map(|a| {
- box a as Box<rtio::RtioTcpAcceptor:Send>
+ box a as Box<rtio::RtioTcpAcceptor + Send>
})
}
}
}
impl rtio::RtioTcpAcceptor for TcpAcceptor {
- fn accept(&mut self) -> IoResult<Box<rtio::RtioTcpStream:Send>> {
- self.native_accept().map(|s| box s as Box<rtio::RtioTcpStream:Send>)
+ fn accept(&mut self) -> IoResult<Box<rtio::RtioTcpStream + Send>> {
+ self.native_accept().map(|s| box s as Box<rtio::RtioTcpStream + Send>)
}
fn accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) }
self.set_broadcast(false)
}
- fn clone(&self) -> Box<rtio::RtioUdpSocket:Send> {
+ fn clone(&self) -> Box<rtio::RtioUdpSocket + Send> {
box UdpSocket {
inner: self.inner.clone(),
read_deadline: 0,
write_deadline: 0,
- } as Box<rtio::RtioUdpSocket:Send>
+ } as Box<rtio::RtioUdpSocket + Send>
}
fn set_timeout(&mut self, timeout: Option<u64>) {
}
}
- fn clone(&self) -> Box<rtio::RtioPipe:Send> {
- box UnixStream::new(self.inner.clone()) as Box<rtio::RtioPipe:Send>
+ fn clone(&self) -> Box<rtio::RtioPipe + Send> {
+ box UnixStream::new(self.inner.clone()) as Box<rtio::RtioPipe + Send>
}
fn close_write(&mut self) -> IoResult<()> {
}
impl rtio::RtioUnixListener for UnixListener {
- fn listen(~self) -> IoResult<Box<rtio::RtioUnixAcceptor:Send>> {
+ fn listen(~self) -> IoResult<Box<rtio::RtioUnixAcceptor + Send>> {
self.native_listen(128).map(|a| {
- box a as Box<rtio::RtioUnixAcceptor:Send>
+ box a as Box<rtio::RtioUnixAcceptor + Send>
})
}
}
}
impl rtio::RtioUnixAcceptor for UnixAcceptor {
- fn accept(&mut self) -> IoResult<Box<rtio::RtioPipe:Send>> {
- self.native_accept().map(|s| box s as Box<rtio::RtioPipe:Send>)
+ fn accept(&mut self) -> IoResult<Box<rtio::RtioPipe + Send>> {
+ self.native_accept().map(|s| box s as Box<rtio::RtioPipe + Send>)
}
fn set_timeout(&mut self, timeout: Option<u64>) {
self.deadline = timeout.map(|a| ::io::timer::now() + a).unwrap_or(0);
Ok(())
}
- fn clone(&self) -> Box<rtio::RtioPipe:Send> {
+ fn clone(&self) -> Box<rtio::RtioPipe + Send> {
box UnixStream {
inner: self.inner.clone(),
read: None,
write: None,
read_deadline: 0,
write_deadline: 0,
- } as Box<rtio::RtioPipe:Send>
+ } as Box<rtio::RtioPipe + Send>
}
fn close_read(&mut self) -> IoResult<()> {
}
impl rtio::RtioUnixListener for UnixListener {
- fn listen(~self) -> IoResult<Box<rtio::RtioUnixAcceptor:Send>> {
+ fn listen(~self) -> IoResult<Box<rtio::RtioUnixAcceptor + Send>> {
self.native_listen().map(|a| {
- box a as Box<rtio::RtioUnixAcceptor:Send>
+ box a as Box<rtio::RtioUnixAcceptor + Send>
})
}
}
}
impl rtio::RtioUnixAcceptor for UnixAcceptor {
- fn accept(&mut self) -> IoResult<Box<rtio::RtioPipe:Send>> {
- self.native_accept().map(|s| box s as Box<rtio::RtioPipe:Send>)
+ fn accept(&mut self) -> IoResult<Box<rtio::RtioPipe + Send>> {
+ self.native_accept().map(|s| box s as Box<rtio::RtioPipe + Send>)
}
fn set_timeout(&mut self, timeout: Option<u64>) {
self.deadline = timeout.map(|i| i + ::io::timer::now()).unwrap_or(0);
}
struct Inner {
- cb: Option<Box<rtio::Callback:Send>>,
+ cb: Option<Box<rtio::Callback + Send>>,
interval: u64,
repeat: bool,
target: u64,
Timer::sleep(msecs);
}
- fn oneshot(&mut self, msecs: u64, cb: Box<rtio::Callback:Send>) {
+ fn oneshot(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) {
let now = now();
let mut inner = self.inner();
unsafe { HELPER.send(NewTimer(inner)); }
}
- fn period(&mut self, msecs: u64, cb: Box<rtio::Callback:Send>) {
+ fn period(&mut self, msecs: u64, cb: Box<rtio::Callback + Send>) {
let now = now();
let mut inner = self.inner();
}
pub enum Req {
- NewTimer(libc::HANDLE, Box<Callback:Send>, bool),
+ NewTimer(libc::HANDLE, Box<Callback + Send>, bool),
RemoveTimer(libc::HANDLE, Sender<()>),
}
let _ = unsafe { imp::WaitForSingleObject(self.obj, libc::INFINITE) };
}
- fn oneshot(&mut self, msecs: u64, cb: Box<Callback:Send>) {
+ fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>) {
self.remove();
// see above for the calculation
self.on_worker = true;
}
- fn period(&mut self, msecs: u64, cb: Box<Callback:Send>) {
+ fn period(&mut self, msecs: u64, cb: Box<Callback + Send>) {
self.remove();
// see above for the calculation
let closer =
match self.pos('}') {
Some(i) => i,
- #[cfg(stage0)]
- None => return self.err(format!(
- "Missing '\\}' for unclosed '\\{' at position {}",
- self.chari).as_slice()),
- #[cfg(not(stage0))]
None => return self.err(format!(
"Missing '}}' for unclosed '{{' at position {}",
self.chari).as_slice()),
let start = self.chari + 2;
let closer =
match self.pos('}') {
- #[cfg(stage0)]
- None => {
- return self.err(format!("Missing '\\}' for unclosed \
- '\\{' at position {}",
- start).as_slice())
- }
- #[cfg(not(stage0))]
None => {
return self.err(format!("Missing '}}' for unclosed \
'{{' at position {}",
}
impl<'a> Context<'a> {
- #[cfg(stage0)]
- fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
- if !self.has_feature(feature) {
- self.sess.span_err(span, explain);
- self.sess.span_note(span, format!("add \\#![feature({})] to the \
- crate attributes to enable",
- feature).as_slice());
- }
- }
- #[cfg(not(stage0))]
fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
if !self.has_feature(feature) {
self.sess.span_err(span, explain);
pub fn with_version(krate: &str) -> Option<(InternedString, ast::StrStyle)> {
match option_env!("CFG_DISABLE_INJECT_STD_VERSION") {
Some("1") => None,
- #[cfg(stage0)]
- _ => {
- Some((token::intern_and_get_ident(format!("{}\\#{}",
- krate,
- VERSION).as_slice()),
- ast::CookedStr))
- }
- #[cfg(not(stage0))]
_ => {
Some((token::intern_and_get_ident(format!("{}#{}",
krate,
}
match self.root {
&None => {}
- #[cfg(stage0)]
- &Some(ref r) => {
- for (i, path) in r.paths().iter().enumerate() {
- self.sess.fileline_note(self.span,
- format!("crate `{}` path \\#{}: {}",
- r.ident, i+1, path.display()).as_slice());
- }
- }
- #[cfg(not(stage0))]
&Some(ref r) => {
for (i, path) in r.paths().iter().enumerate() {
self.sess.fileline_note(self.span,
flavor,
self.crate_id.name).as_slice());
self.sess.span_note(self.span,
- format!(r"candidate \#1: {}",
+ format!(r"candidate #1: {}",
ret.get_ref()
.display()).as_slice());
error = 1;
if error > 0 {
error += 1;
self.sess.span_note(self.span,
- format!(r"candidate \#{}: {}", error,
+ format!(r"candidate #{}: {}", error,
lib.display()).as_slice());
continue
}
pub type abbrev_map = RefCell<HashMap<ty::t, ty_abbrev>>;
-#[cfg(stage0)]
-pub fn enc_ty(w: &mut MemWriter, cx: &ctxt, t: ty::t) {
- match cx.abbrevs.borrow_mut().find(&t) {
- Some(a) => { w.write(a.s.as_bytes()); return; }
- None => {}
- }
- let pos = w.tell().unwrap();
- enc_sty(w, cx, &ty::get(t).sty);
- let end = w.tell().unwrap();
- let len = end - pos;
- fn estimate_sz(u: u64) -> u64 {
- let mut n = u;
- let mut len = 0;
- while n != 0 { len += 1; n = n >> 4; }
- return len;
- }
- let abbrev_len = 3 + estimate_sz(pos) + estimate_sz(len);
- if abbrev_len < len {
- // I.e. it's actually an abbreviation.
- cx.abbrevs.borrow_mut().insert(t, ty_abbrev {
- s: format!("\\#{:x}:{:x}\\#", pos, len)
- });
- }
-}
-#[cfg(not(stage0))]
pub fn enc_ty(w: &mut MemWriter, cx: &ctxt, t: ty::t) {
match cx.abbrevs.borrow_mut().find(&t) {
Some(a) => { w.write(a.s.as_bytes()); return; }
let mut note = None;
let msg = match src {
- #[cfg(stage0)]
- Default => {
- format!("{}, \\#[{}({})] on by default", msg,
- level_to_str(level), lint_str)
- },
- #[cfg(not(stage0))]
Default => {
format!("{}, #[{}({})] on by default", msg,
level_to_str(level), lint_str)
}
impl Repr for cmt_ {
- #[cfg(stage0)]
- fn repr(&self, tcx: &ty::ctxt) -> String {
- format!("\\{{} id:{} m:{:?} ty:{}\\}",
- self.cat.repr(tcx),
- self.id,
- self.mutbl,
- self.ty.repr(tcx))
- }
- #[cfg(not(stage0))]
fn repr(&self, tcx: &ty::ctxt) -> String {
format!("{{{} id:{} m:{:?} ty:{}}}",
self.cat.repr(tcx),
InteriorField(NamedField(fld)) => {
token::get_name(fld).get().to_str()
}
- #[cfg(stage0)]
- InteriorField(PositionalField(i)) => format!("\\#{:?}", i),
- #[cfg(not(stage0))]
InteriorField(PositionalField(i)) => format!("#{:?}", i),
InteriorElement(_) => "[]".to_string(),
}
let msg = match name {
NamedField(name) => format!("field `{}` of {} is private",
token::get_ident(name), struct_desc),
- #[cfg(stage0)]
- UnnamedField(idx) => format!("field \\#{} of {} is private",
- idx + 1, struct_desc),
- #[cfg(not(stage0))]
UnnamedField(idx) => format!("field #{} of {} is private",
idx + 1, struct_desc),
};
for (&key, &binding_0) in map_0.iter() {
match map_i.find(&key) {
- #[cfg(stage0)]
- None => {
- self.resolve_error(
- p.span,
- format!("variable `{}` from pattern \\#1 is \
- not bound in pattern \\#{}",
- token::get_name(key),
- i + 1).as_slice());
- }
- #[cfg(not(stage0))]
None => {
self.resolve_error(
p.span,
token::get_name(key),
i + 1).as_slice());
}
- #[cfg(stage0)]
- Some(binding_i) => {
- if binding_0.binding_mode != binding_i.binding_mode {
- self.resolve_error(
- binding_i.span,
- format!("variable `{}` is bound with different \
- mode in pattern \\#{} than in pattern \\#1",
- token::get_name(key),
- i + 1).as_slice());
- }
- }
- #[cfg(not(stage0))]
Some(binding_i) => {
if binding_0.binding_mode != binding_i.binding_mode {
self.resolve_error(
// structs, which wouldn't result in this error.)
match self.with_no_errors(|this|
this.resolve_path(expr.id, path, TypeNS, false)) {
- #[cfg(stage0)]
- Some((DefTy(struct_id), _))
- if self.structs.contains_key(&struct_id) => {
- self.resolve_error(expr.span,
- format!("`{}` is a structure name, but \
- this expression \
- uses it like a function name",
- wrong_name).as_slice());
-
- self.session.span_note(expr.span,
- format!("Did you mean to write: \
- `{} \\{ /* fields */ \\}`?",
- wrong_name).as_slice());
-
- }
- #[cfg(not(stage0))]
Some((DefTy(struct_id), _))
if self.structs.contains_key(&struct_id) => {
self.resolve_error(expr.span,
}
impl VecTypes {
- #[cfg(stage0)]
- pub fn to_str(&self, ccx: &CrateContext) -> String {
- format!("VecTypes \\{unit_ty={}, llunit_ty={}, \
- llunit_size={}, llunit_alloc_size={}\\}",
- ty_to_str(ccx.tcx(), self.unit_ty),
- ccx.tn.type_to_str(self.llunit_ty),
- ccx.tn.val_to_str(self.llunit_size),
- self.llunit_alloc_size)
- }
- #[cfg(not(stage0))]
pub fn to_str(&self, ccx: &CrateContext) -> String {
format!("VecTypes {{unit_ty={}, llunit_ty={}, \
llunit_size={}, llunit_alloc_size={}}}",
}
impl fmt::Show for TyVid {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{
- write!(f, "<generic \\#{}>", self.to_uint())
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{
write!(f, "<generic #{}>", self.to_uint())
}
}
impl fmt::Show for IntVid {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "<generic integer \\#{}>", self.to_uint())
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<generic integer #{}>", self.to_uint())
}
}
impl fmt::Show for FloatVid {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "<generic float \\#{}>", self.to_uint())
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<generic float #{}>", self.to_uint())
}
}
}
- #[cfg(stage0)]
- fn report_static_candidate(&self, idx: uint, did: DefId) {
- let span = if did.krate == ast::LOCAL_CRATE {
- self.tcx().map.span(did.node)
- } else {
- self.span
- };
- self.tcx().sess.span_note(
- span,
- format!("candidate \\#{} is `{}`",
- idx + 1u,
- ty::item_path_str(self.tcx(), did)).as_slice());
- }
-
- #[cfg(stage0)]
- fn report_param_candidate(&self, idx: uint, did: DefId) {
- self.tcx().sess.span_note(
- self.span,
- format!("candidate \\#{} derives from the bound `{}`",
- idx + 1u,
- ty::item_path_str(self.tcx(), did)).as_slice());
- }
-
- #[cfg(stage0)]
- fn report_trait_candidate(&self, idx: uint, did: DefId) {
- self.tcx().sess.span_note(
- self.span,
- format!("candidate \\#{} derives from the type of the receiver, \
- which is the trait `{}`",
- idx + 1u,
- ty::item_path_str(self.tcx(), did)).as_slice());
- }
-
- #[cfg(not(stage0))]
fn report_static_candidate(&self, idx: uint, did: DefId) {
let span = if did.krate == ast::LOCAL_CRATE {
self.tcx().map.span(did.node)
ty::item_path_str(self.tcx(), did)).as_slice());
}
- #[cfg(not(stage0))]
fn report_param_candidate(&self, idx: uint, did: DefId) {
self.tcx().sess.span_note(
self.span,
ty::item_path_str(self.tcx(), did)).as_slice());
}
- #[cfg(not(stage0))]
fn report_trait_candidate(&self, idx: uint, did: DefId) {
self.tcx().sess.span_note(
self.span,
}
impl<T:InferStr> InferStr for Bounds<T> {
- #[cfg(stage0)]
- fn inf_str(&self, cx: &InferCtxt) -> String {
- format!("\\{{} <: {}\\}", self.lb.inf_str(cx), self.ub.inf_str(cx))
- }
- #[cfg(not(stage0))]
fn inf_str(&self, cx: &InferCtxt) -> String {
format!("{{{} <: {}}}", self.lb.inf_str(cx), self.ub.inf_str(cx))
}
ReFree(ref fr) => {
let prefix = match fr.bound_region {
- #[cfg(stage0)]
- BrAnon(idx) => {
- format!("the anonymous lifetime \\#{} defined on", idx + 1)
- }
- #[cfg(not(stage0))]
BrAnon(idx) => {
format!("the anonymous lifetime #{} defined on", idx + 1)
}
Some(def) => token::get_ident(def.ident).get().to_string(),
// This can only happen when a type mismatch error happens and
// the actual type has more type parameters than the expected one.
- #[cfg(stage0)]
- None => format!("<generic \\#{}>", id),
- #[cfg(not(stage0))]
None => format!("<generic #{}>", id),
};
if !cx.sess.verbose() {
}
impl Repr for ty::ty_param_bounds_and_ty {
- #[cfg(stage0)]
- fn repr(&self, tcx: &ctxt) -> String {
- format!("ty_param_bounds_and_ty \\{generics: {}, ty: {}\\}",
- self.generics.repr(tcx),
- self.ty.repr(tcx))
- }
- #[cfg(not(stage0))]
fn repr(&self, tcx: &ctxt) -> String {
format!("ty_param_bounds_and_ty {{generics: {}, ty: {}}}",
self.generics.repr(tcx),
}
impl Repr for ty::BareFnTy {
- #[cfg(stage0)]
- fn repr(&self, tcx: &ctxt) -> String {
- format!("BareFnTy \\{fn_style: {:?}, abi: {}, sig: {}\\}",
- self.fn_style,
- self.abi.to_str(),
- self.sig.repr(tcx))
- }
- #[cfg(not(stage0))]
fn repr(&self, tcx: &ctxt) -> String {
format!("BareFnTy {{fn_style: {:?}, abi: {}, sig: {}}}",
self.fn_style,
}
impl Repr for typeck::MethodCallee {
- #[cfg(stage0)]
- fn repr(&self, tcx: &ctxt) -> String {
- format!("MethodCallee \\{origin: {}, ty: {}, {}\\}",
- self.origin.repr(tcx),
- self.ty.repr(tcx),
- self.substs.repr(tcx))
- }
- #[cfg(not(stage0))]
fn repr(&self, tcx: &ctxt) -> String {
format!("MethodCallee {{origin: {}, ty: {}, {}}}",
self.origin.repr(tcx),
impl fmt::Show for clean::Lifetime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(f.write("'".as_bytes()));
try!(f.write(self.get_ref().as_bytes()));
Ok(())
}
// span when we see the ']'.
t::POUND => {
is_attribute = true;
- try!(write!(out, r"<span class='attribute'>\#"));
+ try!(write!(out, r"<span class='attribute'>#"));
continue
}
t::RBRACKET => {
<dd>Move up in search results</dd>
<dt>↓</dt>
<dd>Move down in search results</dd>
- <dt>&\#9166;</dt>
+ <dt>⏎</dt>
<dd>Go to active search result</dd>
</dl>
</div>
};
// Render the HTML
- let text = format!(r#"<h{lvl} id="{id}" class='section-header'><a
- href="\#{id}">{sec}{}</a></h{lvl}>"#,
+ let text = format!(r##"<h{lvl} id="{id}" class='section-header'><a
+ href="#{id}">{sec}{}</a></h{lvl}>"##,
s, lvl = level, id = id,
sec = if sec.len() == 0 {
sec.to_string()
// recursively format this table of contents (the
// `{children}` is the key).
try!(write!(fmt,
- "\n<li><a href=\"\\#{id}\">{num} {name}</a>{children}</li>",
+ "\n<li><a href=\"#{id}\">{num} {name}</a>{children}</li>",
id = entry.id,
num = entry.sec_number, name = entry.name,
children = entry.children))
let old = io::stdio::set_stderr(box w1);
spawn(proc() {
let mut p = io::ChanReader::new(rx);
- let mut err = old.unwrap_or(box io::stderr() as Box<Writer:Send>);
+ let mut err = old.unwrap_or(box io::stderr() as Box<Writer + Send>);
io::util::copy(&mut p, &mut err).unwrap();
});
let emitter = diagnostic::EmitterWriter::new(box w2);
// a proper map.
#[doc(hidden)]
pub type Map = Vec<Option<(*u8, TLSValue, uint)>>;
-type TLSValue = Box<LocalData:Send>;
+type TLSValue = Box<LocalData + Send>;
// Gets the map from the runtime. Lazily initialises if not done so already.
unsafe fn get_local_map() -> Option<&mut Map> {
// anything.
let newval = data.map(|d| {
let d = box d as Box<LocalData>;
- let d: Box<LocalData:Send> = unsafe { mem::transmute(d) };
+ let d: Box<LocalData + Send> = unsafe { mem::transmute(d) };
(keyval, d, 0)
});
// pointer part of the trait, (as ~T), and then use
// compiler coercions to achieve a '&' pointer.
let ptr = unsafe {
- let data = data as *Box<LocalData:Send> as *raw::TraitObject;
+ let data = data as *Box<LocalData + Send> as *raw::TraitObject;
&mut *((*data).data as *mut T)
};
Ref { _ptr: ptr, _index: pos, _nosend: marker::NoSend, _key: self }
pub trait EventLoop {
fn run(&mut self);
- fn callback(&mut self, arg: proc():Send);
- fn pausable_idle_callback(&mut self, Box<Callback:Send>)
- -> Box<PausableIdleCallback:Send>;
- fn remote_callback(&mut self, Box<Callback:Send>)
- -> Box<RemoteCallback:Send>;
+ fn callback(&mut self, arg: proc(): Send);
+ fn pausable_idle_callback(&mut self, Box<Callback + Send>)
+ -> Box<PausableIdleCallback + Send>;
+ fn remote_callback(&mut self, Box<Callback + Send>)
+ -> Box<RemoteCallback + Send>;
/// The asynchronous I/O services. Not all event loops may provide one.
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory>;
pub trait IoFactory {
// networking
fn tcp_connect(&mut self, addr: SocketAddr,
- timeout: Option<u64>) -> IoResult<Box<RtioTcpStream:Send>>;
+ timeout: Option<u64>) -> IoResult<Box<RtioTcpStream + Send>>;
fn tcp_bind(&mut self, addr: SocketAddr)
- -> IoResult<Box<RtioTcpListener:Send>>;
+ -> IoResult<Box<RtioTcpListener + Send>>;
fn udp_bind(&mut self, addr: SocketAddr)
- -> IoResult<Box<RtioUdpSocket:Send>>;
+ -> IoResult<Box<RtioUdpSocket + Send>>;
fn unix_bind(&mut self, path: &CString)
- -> IoResult<Box<RtioUnixListener:Send>>;
+ -> IoResult<Box<RtioUnixListener + Send>>;
fn unix_connect(&mut self, path: &CString,
- timeout: Option<u64>) -> IoResult<Box<RtioPipe:Send>>;
+ timeout: Option<u64>) -> IoResult<Box<RtioPipe + Send>>;
fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
hint: Option<AddrinfoHint>)
-> IoResult<Vec<AddrinfoInfo>>;
// filesystem operations
fn fs_from_raw_fd(&mut self, fd: c_int, close: CloseBehavior)
- -> Box<RtioFileStream:Send>;
+ -> Box<RtioFileStream + Send>;
fn fs_open(&mut self, path: &CString, fm: FileMode, fa: FileAccess)
- -> IoResult<Box<RtioFileStream:Send>>;
+ -> IoResult<Box<RtioFileStream + Send>>;
fn fs_unlink(&mut self, path: &CString) -> IoResult<()>;
fn fs_stat(&mut self, path: &CString) -> IoResult<FileStat>;
fn fs_mkdir(&mut self, path: &CString, mode: uint) -> IoResult<()>;
IoResult<()>;
// misc
- fn timer_init(&mut self) -> IoResult<Box<RtioTimer:Send>>;
+ fn timer_init(&mut self) -> IoResult<Box<RtioTimer + Send>>;
fn spawn(&mut self, cfg: ProcessConfig)
- -> IoResult<(Box<RtioProcess:Send>,
- Vec<Option<Box<RtioPipe:Send>>>)>;
+ -> IoResult<(Box<RtioProcess + Send>,
+ Vec<Option<Box<RtioPipe + Send>>>)>;
fn kill(&mut self, pid: libc::pid_t, signal: int) -> IoResult<()>;
- fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<RtioPipe:Send>>;
+ fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<RtioPipe + Send>>;
fn tty_open(&mut self, fd: c_int, readable: bool)
- -> IoResult<Box<RtioTTY:Send>>;
- fn signal(&mut self, signal: int, cb: Box<Callback:Send>)
- -> IoResult<Box<RtioSignal:Send>>;
+ -> IoResult<Box<RtioTTY + Send>>;
+ fn signal(&mut self, signal: int, cb: Box<Callback + Send>)
+ -> IoResult<Box<RtioSignal + Send>>;
}
pub trait RtioTcpListener : RtioSocket {
- fn listen(~self) -> IoResult<Box<RtioTcpAcceptor:Send>>;
+ fn listen(~self) -> IoResult<Box<RtioTcpAcceptor + Send>>;
}
pub trait RtioTcpAcceptor : RtioSocket {
- fn accept(&mut self) -> IoResult<Box<RtioTcpStream:Send>>;
+ fn accept(&mut self) -> IoResult<Box<RtioTcpStream + Send>>;
fn accept_simultaneously(&mut self) -> IoResult<()>;
fn dont_accept_simultaneously(&mut self) -> IoResult<()>;
fn set_timeout(&mut self, timeout: Option<u64>);
fn nodelay(&mut self) -> IoResult<()>;
fn keepalive(&mut self, delay_in_seconds: uint) -> IoResult<()>;
fn letdie(&mut self) -> IoResult<()>;
- fn clone(&self) -> Box<RtioTcpStream:Send>;
+ fn clone(&self) -> Box<RtioTcpStream + Send>;
fn close_write(&mut self) -> IoResult<()>;
fn close_read(&mut self) -> IoResult<()>;
fn set_timeout(&mut self, timeout_ms: Option<u64>);
fn hear_broadcasts(&mut self) -> IoResult<()>;
fn ignore_broadcasts(&mut self) -> IoResult<()>;
- fn clone(&self) -> Box<RtioUdpSocket:Send>;
+ fn clone(&self) -> Box<RtioUdpSocket + Send>;
fn set_timeout(&mut self, timeout_ms: Option<u64>);
fn set_read_timeout(&mut self, timeout_ms: Option<u64>);
fn set_write_timeout(&mut self, timeout_ms: Option<u64>);
pub trait RtioTimer {
fn sleep(&mut self, msecs: u64);
- fn oneshot(&mut self, msecs: u64, cb: Box<Callback:Send>);
- fn period(&mut self, msecs: u64, cb: Box<Callback:Send>);
+ fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>);
+ fn period(&mut self, msecs: u64, cb: Box<Callback + Send>);
}
pub trait RtioFileStream {
pub trait RtioPipe {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>;
fn write(&mut self, buf: &[u8]) -> IoResult<()>;
- fn clone(&self) -> Box<RtioPipe:Send>;
+ fn clone(&self) -> Box<RtioPipe + Send>;
fn close_write(&mut self) -> IoResult<()>;
fn close_read(&mut self) -> IoResult<()>;
}
pub trait RtioUnixListener {
- fn listen(~self) -> IoResult<Box<RtioUnixAcceptor:Send>>;
+ fn listen(~self) -> IoResult<Box<RtioUnixAcceptor + Send>>;
}
pub trait RtioUnixAcceptor {
- fn accept(&mut self) -> IoResult<Box<RtioPipe:Send>>;
+ fn accept(&mut self) -> IoResult<Box<RtioPipe + Send>>;
fn set_timeout(&mut self, timeout: Option<u64>);
}
pub destroyed: bool,
pub name: Option<SendStr>,
- imp: Option<Box<Runtime:Send>>,
+ imp: Option<Box<Runtime + Send>>,
}
pub struct TaskOpts {
/// Invoke this procedure with the result of the task when it finishes.
- pub on_exit: Option<proc(Result):Send>,
+ pub on_exit: Option<proc(Result): Send>,
/// A name for the task-to-be, for identification in failure messages
pub name: Option<SendStr>,
/// The size of the stack for the spawned task
///
/// If you wish for this result's delivery to block until all
/// children tasks complete, recommend using a result future.
-pub type Result = ::core::result::Result<(), Box<Any:Send>>;
+pub type Result = ::core::result::Result<(), Box<Any + Send>>;
pub struct GarbageCollector;
pub struct LocalStorage(pub Option<local_data::Map>);
/// Per-task state related to task death, killing, failure, etc.
pub struct Death {
- pub on_exit: Option<proc(Result):Send>,
+ pub on_exit: Option<proc(Result): Send>,
}
pub struct BlockedTasks {
/// Inserts a runtime object into this task, transferring ownership to the
/// task. It is illegal to replace a previous runtime object in this task
/// with this argument.
- pub fn put_runtime(&mut self, ops: Box<Runtime:Send>) {
+ pub fn put_runtime(&mut self, ops: Box<Runtime + Send>) {
assert!(self.imp.is_none());
self.imp = Some(ops);
}
Ok(t) => Some(t),
Err(t) => {
let data = mem::transmute::<_, raw::TraitObject>(t).data;
- let obj: Box<Runtime:Send> =
+ let obj: Box<Runtime + Send> =
mem::transmute(raw::TraitObject {
vtable: vtable,
data: data,
/// Spawns a sibling to this task. The newly spawned task is configured with
/// the `opts` structure and will run `f` as the body of its code.
- pub fn spawn_sibling(mut ~self, opts: TaskOpts, f: proc():Send) {
+ pub fn spawn_sibling(mut ~self, opts: TaskOpts, f: proc(): Send) {
let ops = self.imp.take_unwrap();
ops.spawn_sibling(self, opts, f)
}
pub struct Unwinder {
unwinding: bool,
- cause: Option<Box<Any:Send>>
+ cause: Option<Box<Any + Send>>
}
struct Exception {
uwe: uw::_Unwind_Exception,
- cause: Option<Box<Any:Send>>,
+ cause: Option<Box<Any + Send>>,
}
-pub type Callback = fn(msg: &Any:Send, file: &'static str, line: uint);
+pub type Callback = fn(msg: &Any + Send, file: &'static str, line: uint);
// Variables used for invoking callbacks when a task starts to unwind.
//
/// guaranteed that a rust task is in place when invoking this function.
/// Unwinding twice can lead to resource leaks where some destructors are not
/// run.
-pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any:Send>> {
+pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
let closure: Closure = mem::transmute(f);
let ep = rust_try(try_fn, closure.code as *c_void,
closure.env as *c_void);
// An uninlined, unmangled function upon which to slap yer breakpoints
#[inline(never)]
#[no_mangle]
-fn rust_fail(cause: Box<Any:Send>) -> ! {
+fn rust_fail(cause: Box<Any + Send>) -> ! {
rtdebug!("begin_unwind()");
unsafe {
/// Do this split took the LLVM IR line counts of `fn main() { fail!()
/// }` from ~1900/3700 (-O/no opts) to 180/590.
#[inline(never)] #[cold] // this is the slow path, please never inline this
-fn begin_unwind_inner(msg: Box<Any:Send>,
+fn begin_unwind_inner(msg: Box<Any + Send>,
file: &'static str,
line: uint) -> ! {
// First, invoke call the user-defined callbacks triggered on task failure.
}
struct Payload {
- callback: Box<Callback:Send>,
+ callback: Box<Callback + Send>,
exit_flag: Arc<Exclusive<bool>>,
}
impl AsyncWatcher {
- pub fn new(loop_: &mut Loop, cb: Box<Callback:Send>) -> AsyncWatcher {
+ pub fn new(loop_: &mut Loop, cb: Box<Callback + Send>) -> AsyncWatcher {
let handle = UvHandle::alloc(None::<AsyncWatcher>, uvll::UV_ASYNC);
assert_eq!(unsafe {
uvll::uv_async_init(loop_.handle, handle, async_cb)
pub struct IdleWatcher {
handle: *uvll::uv_idle_t,
idle_flag: bool,
- callback: Box<Callback:Send>,
+ callback: Box<Callback + Send>,
}
impl IdleWatcher {
- pub fn new(loop_: &mut Loop, cb: Box<Callback:Send>) -> Box<IdleWatcher> {
+ pub fn new(loop_: &mut Loop, cb: Box<Callback + Send>) -> Box<IdleWatcher> {
let handle = UvHandle::alloc(None::<IdleWatcher>, uvll::UV_IDLE);
assert_eq!(unsafe {
uvll::uv_idle_init(loop_.handle, handle)
fn mk(v: uint) -> (Box<IdleWatcher>, Chan) {
let rc = Rc::new(RefCell::new((None, 0)));
let cb = box MyCallback(rc.clone(), v);
- let cb = cb as Box<Callback:>;
+ let cb = cb as Box<Callback>;
let cb = unsafe { mem::transmute(cb) };
(IdleWatcher::new(&mut local_loop().loop_, cb), rc)
}
/// // this code is running inside of a green task powered by libuv
/// }
/// ```
-pub fn event_loop() -> Box<rtio::EventLoop:Send> {
- box uvio::UvEventLoop::new() as Box<rtio::EventLoop:Send>
+pub fn event_loop() -> Box<rtio::EventLoop + Send> {
+ box uvio::UvEventLoop::new() as Box<rtio::EventLoop + Send>
}
/// A type that wraps a uv handle
pub struct TcpListener {
home: HomeHandle,
handle: *uvll::uv_pipe_t,
- outgoing: Sender<Result<Box<rtio::RtioTcpStream:Send>, IoError>>,
- incoming: Receiver<Result<Box<rtio::RtioTcpStream:Send>, IoError>>,
+ outgoing: Sender<Result<Box<rtio::RtioTcpStream + Send>, IoError>>,
+ incoming: Receiver<Result<Box<rtio::RtioTcpStream + Send>, IoError>>,
}
pub struct TcpAcceptor {
})
}
- fn clone(&self) -> Box<rtio::RtioTcpStream:Send> {
+ fn clone(&self) -> Box<rtio::RtioTcpStream + Send> {
box TcpWatcher {
handle: self.handle,
stream: StreamWatcher::new(self.handle),
refcount: self.refcount.clone(),
read_access: self.read_access.clone(),
write_access: self.write_access.clone(),
- } as Box<rtio::RtioTcpStream:Send>
+ } as Box<rtio::RtioTcpStream + Send>
}
fn close_read(&mut self) -> Result<(), IoError> {
}
impl rtio::RtioTcpListener for TcpListener {
- fn listen(~self) -> Result<Box<rtio::RtioTcpAcceptor:Send>, IoError> {
+ fn listen(~self) -> Result<Box<rtio::RtioTcpAcceptor + Send>, IoError> {
// create the acceptor object from ourselves
let mut acceptor = box TcpAcceptor {
listener: self,
let _m = acceptor.fire_homing_missile();
// FIXME: the 128 backlog should be configurable
match unsafe { uvll::uv_listen(acceptor.listener.handle, 128, listen_cb) } {
- 0 => Ok(acceptor as Box<rtio::RtioTcpAcceptor:Send>),
+ 0 => Ok(acceptor as Box<rtio::RtioTcpAcceptor + Send>),
n => Err(uv_error_to_io_error(UvError(n))),
}
}
});
let client = TcpWatcher::new_home(&loop_, tcp.home().clone());
assert_eq!(unsafe { uvll::uv_accept(server, client.handle) }, 0);
- Ok(box client as Box<rtio::RtioTcpStream:Send>)
+ Ok(box client as Box<rtio::RtioTcpStream + Send>)
}
n => Err(uv_error_to_io_error(UvError(n)))
};
}
impl rtio::RtioTcpAcceptor for TcpAcceptor {
- fn accept(&mut self) -> Result<Box<rtio::RtioTcpStream:Send>, IoError> {
+ fn accept(&mut self) -> Result<Box<rtio::RtioTcpStream + Send>, IoError> {
self.timeout.accept(&self.listener.incoming)
}
})
}
- fn clone(&self) -> Box<rtio::RtioUdpSocket:Send> {
+ fn clone(&self) -> Box<rtio::RtioUdpSocket + Send> {
box UdpWatcher {
handle: self.handle,
home: self.home.clone(),
write_access: self.write_access.clone(),
read_access: self.read_access.clone(),
blocked_sender: None,
- } as Box<rtio::RtioUdpSocket:Send>
+ } as Box<rtio::RtioUdpSocket + Send>
}
fn set_timeout(&mut self, timeout: Option<u64>) {
pub struct PipeListener {
home: HomeHandle,
pipe: *uvll::uv_pipe_t,
- outgoing: Sender<IoResult<Box<rtio::RtioPipe:Send>>>,
- incoming: Receiver<IoResult<Box<rtio::RtioPipe:Send>>>,
+ outgoing: Sender<IoResult<Box<rtio::RtioPipe + Send>>>,
+ incoming: Receiver<IoResult<Box<rtio::RtioPipe + Send>>>,
}
pub struct PipeAcceptor {
self.stream.write(buf, guard.can_timeout).map_err(uv_error_to_io_error)
}
- fn clone(&self) -> Box<rtio::RtioPipe:Send> {
+ fn clone(&self) -> Box<rtio::RtioPipe + Send> {
box PipeWatcher {
stream: StreamWatcher::new(self.stream.handle),
defused: false,
refcount: self.refcount.clone(),
read_access: self.read_access.clone(),
write_access: self.write_access.clone(),
- } as Box<rtio::RtioPipe:Send>
+ } as Box<rtio::RtioPipe + Send>
}
fn close_read(&mut self) -> IoResult<()> {
}
impl rtio::RtioUnixListener for PipeListener {
- fn listen(~self) -> IoResult<Box<rtio::RtioUnixAcceptor:Send>> {
+ fn listen(~self) -> IoResult<Box<rtio::RtioUnixAcceptor + Send>> {
// create the acceptor object from ourselves
let mut acceptor = box PipeAcceptor {
listener: self,
let _m = acceptor.fire_homing_missile();
// FIXME: the 128 backlog should be configurable
match unsafe { uvll::uv_listen(acceptor.listener.pipe, 128, listen_cb) } {
- 0 => Ok(acceptor as Box<rtio::RtioUnixAcceptor:Send>),
+ 0 => Ok(acceptor as Box<rtio::RtioUnixAcceptor + Send>),
n => Err(uv_error_to_io_error(UvError(n))),
}
}
});
let client = PipeWatcher::new_home(&loop_, pipe.home().clone(), false);
assert_eq!(unsafe { uvll::uv_accept(server, client.handle()) }, 0);
- Ok(box client as Box<rtio::RtioPipe:Send>)
+ Ok(box client as Box<rtio::RtioPipe + Send>)
}
n => Err(uv_error_to_io_error(UvError(n)))
};
// PipeAcceptor implementation and traits
impl rtio::RtioUnixAcceptor for PipeAcceptor {
- fn accept(&mut self) -> IoResult<Box<rtio::RtioPipe:Send>> {
+ fn accept(&mut self) -> IoResult<Box<rtio::RtioPipe + Send>> {
self.timeout.accept(&self.listener.incoming)
}
handle: *uvll::uv_signal_t,
home: HomeHandle,
- cb: Box<Callback:Send>,
+ cb: Box<Callback + Send>,
}
impl SignalWatcher {
- pub fn new(io: &mut UvIoFactory, signum: int, cb: Box<Callback:Send>)
+ pub fn new(io: &mut UvIoFactory, signum: int, cb: Box<Callback + Send>)
-> Result<Box<SignalWatcher>, UvError> {
let s = box SignalWatcher {
handle: UvHandle::alloc(None::<SignalWatcher>, uvll::UV_SIGNAL),
pub enum NextAction {
WakeTask,
- CallOnce(Box<Callback:Send>),
- CallMany(Box<Callback:Send>, uint),
+ CallOnce(Box<Callback + Send>),
+ CallMany(Box<Callback + Send>, uint),
}
impl TimerWatcher {
self.stop();
}
- fn oneshot(&mut self, msecs: u64, cb: Box<Callback:Send>) {
+ fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>) {
// similarly to the destructor, we must drop the previous action outside
// of the homing missile
let _prev_action = {
};
}
- fn period(&mut self, msecs: u64, cb: Box<Callback:Send>) {
+ fn period(&mut self, msecs: u64, cb: Box<Callback + Send>) {
// similarly to the destructor, we must drop the previous action outside
// of the homing missile
let _prev_action = {
IdleWatcher::onetime(&mut self.uvio.loop_, f);
}
- fn pausable_idle_callback(&mut self, cb: Box<rtio::Callback:Send>)
- -> Box<rtio::PausableIdleCallback:Send> {
+ fn pausable_idle_callback(&mut self, cb: Box<rtio::Callback + Send>)
+ -> Box<rtio::PausableIdleCallback + Send> {
IdleWatcher::new(&mut self.uvio.loop_, cb)
- as Box<rtio::PausableIdleCallback:Send>
+ as Box<rtio::PausableIdleCallback + Send>
}
- fn remote_callback(&mut self, f: Box<rtio::Callback:Send>)
- -> Box<rtio::RemoteCallback:Send> {
+ fn remote_callback(&mut self, f: Box<rtio::Callback + Send>)
+ -> Box<rtio::RemoteCallback + Send> {
box AsyncWatcher::new(&mut self.uvio.loop_, f) as
- Box<rtio::RemoteCallback:Send>
+ Box<rtio::RemoteCallback + Send>
}
fn io<'a>(&'a mut self) -> Option<&'a mut rtio::IoFactory> {
// NB: This blocks the task waiting on the connection.
// It would probably be better to return a future
fn tcp_connect(&mut self, addr: rtio::SocketAddr, timeout: Option<u64>)
- -> IoResult<Box<rtio::RtioTcpStream:Send>> {
+ -> IoResult<Box<rtio::RtioTcpStream + Send>> {
match TcpWatcher::connect(self, addr, timeout) {
- Ok(t) => Ok(box t as Box<rtio::RtioTcpStream:Send>),
+ Ok(t) => Ok(box t as Box<rtio::RtioTcpStream + Send>),
Err(e) => Err(uv_error_to_io_error(e)),
}
}
fn tcp_bind(&mut self, addr: rtio::SocketAddr)
- -> IoResult<Box<rtio::RtioTcpListener:Send>> {
+ -> IoResult<Box<rtio::RtioTcpListener + Send>> {
match TcpListener::bind(self, addr) {
- Ok(t) => Ok(t as Box<rtio::RtioTcpListener:Send>),
+ Ok(t) => Ok(t as Box<rtio::RtioTcpListener + Send>),
Err(e) => Err(uv_error_to_io_error(e)),
}
}
fn udp_bind(&mut self, addr: rtio::SocketAddr)
- -> IoResult<Box<rtio::RtioUdpSocket:Send>> {
+ -> IoResult<Box<rtio::RtioUdpSocket + Send>> {
match UdpWatcher::bind(self, addr) {
- Ok(u) => Ok(box u as Box<rtio::RtioUdpSocket:Send>),
+ Ok(u) => Ok(box u as Box<rtio::RtioUdpSocket + Send>),
Err(e) => Err(uv_error_to_io_error(e)),
}
}
- fn timer_init(&mut self) -> IoResult<Box<rtio::RtioTimer:Send>> {
- Ok(TimerWatcher::new(self) as Box<rtio::RtioTimer:Send>)
+ fn timer_init(&mut self) -> IoResult<Box<rtio::RtioTimer + Send>> {
+ Ok(TimerWatcher::new(self) as Box<rtio::RtioTimer + Send>)
}
fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
}
fn fs_from_raw_fd(&mut self, fd: c_int, close: rtio::CloseBehavior)
- -> Box<rtio::RtioFileStream:Send> {
+ -> Box<rtio::RtioFileStream + Send> {
box FileWatcher::new(self, fd, close) as
- Box<rtio::RtioFileStream:Send>
+ Box<rtio::RtioFileStream + Send>
}
fn fs_open(&mut self, path: &CString, fm: rtio::FileMode,
fa: rtio::FileAccess)
- -> IoResult<Box<rtio::RtioFileStream:Send>>
+ -> IoResult<Box<rtio::RtioFileStream + Send>>
{
let flags = match fm {
rtio::Open => 0,
};
match FsRequest::open(self, path, flags as int, mode as int) {
- Ok(fs) => Ok(box fs as Box<rtio::RtioFileStream:Send>),
+ Ok(fs) => Ok(box fs as Box<rtio::RtioFileStream + Send>),
Err(e) => Err(uv_error_to_io_error(e))
}
}
}
fn spawn(&mut self, cfg: ProcessConfig)
- -> IoResult<(Box<rtio::RtioProcess:Send>,
- Vec<Option<Box<rtio::RtioPipe:Send>>>)>
+ -> IoResult<(Box<rtio::RtioProcess + Send>,
+ Vec<Option<Box<rtio::RtioPipe + Send>>>)>
{
match Process::spawn(self, cfg) {
Ok((p, io)) => {
- Ok((p as Box<rtio::RtioProcess:Send>,
+ Ok((p as Box<rtio::RtioProcess + Send>,
io.move_iter().map(|i| i.map(|p| {
- box p as Box<rtio::RtioPipe:Send>
+ box p as Box<rtio::RtioPipe + Send>
})).collect()))
}
Err(e) => Err(uv_error_to_io_error(e)),
}
fn unix_bind(&mut self, path: &CString)
- -> IoResult<Box<rtio::RtioUnixListener:Send>> {
+ -> IoResult<Box<rtio::RtioUnixListener + Send>> {
match PipeListener::bind(self, path) {
- Ok(p) => Ok(p as Box<rtio::RtioUnixListener:Send>),
+ Ok(p) => Ok(p as Box<rtio::RtioUnixListener + Send>),
Err(e) => Err(uv_error_to_io_error(e)),
}
}
fn unix_connect(&mut self, path: &CString, timeout: Option<u64>)
- -> IoResult<Box<rtio::RtioPipe:Send>> {
+ -> IoResult<Box<rtio::RtioPipe + Send>> {
match PipeWatcher::connect(self, path, timeout) {
- Ok(p) => Ok(box p as Box<rtio::RtioPipe:Send>),
+ Ok(p) => Ok(box p as Box<rtio::RtioPipe + Send>),
Err(e) => Err(uv_error_to_io_error(e)),
}
}
fn tty_open(&mut self, fd: c_int, readable: bool)
- -> IoResult<Box<rtio::RtioTTY:Send>> {
+ -> IoResult<Box<rtio::RtioTTY + Send>> {
match TtyWatcher::new(self, fd, readable) {
- Ok(tty) => Ok(box tty as Box<rtio::RtioTTY:Send>),
+ Ok(tty) => Ok(box tty as Box<rtio::RtioTTY + Send>),
Err(e) => Err(uv_error_to_io_error(e))
}
}
fn pipe_open(&mut self, fd: c_int)
- -> IoResult<Box<rtio::RtioPipe:Send>>
+ -> IoResult<Box<rtio::RtioPipe + Send>>
{
match PipeWatcher::open(self, fd) {
- Ok(s) => Ok(box s as Box<rtio::RtioPipe:Send>),
+ Ok(s) => Ok(box s as Box<rtio::RtioPipe + Send>),
Err(e) => Err(uv_error_to_io_error(e))
}
}
- fn signal(&mut self, signum: int, cb: Box<rtio::Callback:Send>)
- -> IoResult<Box<rtio::RtioSignal:Send>>
+ fn signal(&mut self, signum: int, cb: Box<rtio::Callback + Send>)
+ -> IoResult<Box<rtio::RtioSignal + Send>>
{
match SignalWatcher::new(self, signum, cb) {
- Ok(s) => Ok(s as Box<rtio::RtioSignal:Send>),
+ Ok(s) => Ok(s as Box<rtio::RtioSignal + Send>),
Err(e) => Err(uv_error_to_io_error(e)),
}
}
_name: &str,
f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { f(self) }
- #[cfg(stage0)]
- fn emit_enum_variant(&mut self,
- name: &str,
- _id: uint,
- cnt: uint,
- f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
- // enums are encoded as strings or objects
- // Bunny => "Bunny"
- // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
- if cnt == 0 {
- write!(self.wr, "{}", escape_str(name))
- } else {
- try!(write!(self.wr, "\\{\"variant\":"));
- try!(write!(self.wr, "{}", escape_str(name)));
- try!(write!(self.wr, ",\"fields\":["));
- try!(f(self));
- write!(self.wr, "]\\}")
- }
- }
- #[cfg(not(stage0))]
fn emit_enum_variant(&mut self,
name: &str,
_id: uint,
self.emit_enum_variant_arg(idx, f)
}
- #[cfg(stage0)]
- fn emit_struct(&mut self,
- _: &str,
- _: uint,
- f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
- try!(write!(self.wr, r"\{"));
- try!(f(self));
- write!(self.wr, r"\}")
- }
- #[cfg(not(stage0))]
fn emit_struct(&mut self,
_: &str,
_: uint,
f(self)
}
- #[cfg(stage0)]
- fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
- try!(write!(self.wr, r"\{"));
- try!(f(self));
- write!(self.wr, r"\}")
- }
- #[cfg(not(stage0))]
fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult {
try!(write!(self.wr, "{{"));
try!(f(self));
}
- #[cfg(stage0)]
- fn emit_struct(&mut self,
- _: &str,
- len: uint,
- f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
- if len == 0 {
- write!(self.wr, "\\{\\}")
- } else {
- try!(write!(self.wr, "\\{"));
- self.indent += 2;
- try!(f(self));
- self.indent -= 2;
- write!(self.wr, "\n{}\\}", spaces(self.indent))
- }
- }
- #[cfg(not(stage0))]
fn emit_struct(&mut self,
_: &str,
len: uint,
f(self)
}
- #[cfg(stage0)]
- fn emit_map(&mut self,
- len: uint,
- f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
- if len == 0 {
- write!(self.wr, "\\{\\}")
- } else {
- try!(write!(self.wr, "\\{"));
- self.indent += 2;
- try!(f(self));
- self.indent -= 2;
- write!(self.wr, "\n{}\\}", spaces(self.indent))
- }
- }
- #[cfg(not(stage0))]
fn emit_map(&mut self,
len: uint,
f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult {
impl<K: Eq + Hash<S>, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {}
impl<K: Eq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H> {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, r"\{"));
-
- for (i, (k, v)) in self.iter().enumerate() {
- if i != 0 { try!(write!(f, ", ")); }
- try!(write!(f, "{}: {}", *k, *v));
- }
-
- write!(f, r"\}")
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{{"));
}
impl<T: Eq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, r"\{"));
-
- for (i, x) in self.iter().enumerate() {
- if i != 0 { try!(write!(f, ", ")); }
- try!(write!(f, "{}", *x));
- }
-
- write!(f, r"\}")
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{{"));
impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
/// Return a string that lists the key-value pairs from most-recently
/// used to least-recently used.
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, r"\{"));
- let mut cur = self.head;
- for i in range(0, self.len()) {
- if i > 0 { try!(write!(f, ", ")) }
- unsafe {
- cur = (*cur).next;
- try!(write!(f, "{}", (*cur).key));
- }
- try!(write!(f, ": "));
- unsafe {
- try!(write!(f, "{}", (*cur).value));
- }
- }
- write!(f, r"\}")
- }
- /// Return a string that lists the key-value pairs from most-recently
- /// used to least-recently used.
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{{"));
let mut cur = self.head;
use string::String;
// Defined in this module instead of io::stdio so that the unwinding
-local_data_key!(pub local_stderr: Box<Writer:Send>)
+local_data_key!(pub local_stderr: Box<Writer + Send>)
impl Writer for Stdio {
fn write(&mut self, bytes: &[u8]) -> IoResult<()> {
}
}
-pub fn on_fail(obj: &Any:Send, file: &'static str, line: uint) {
+pub fn on_fail(obj: &Any + Send, file: &'static str, line: uint) {
let msg = match obj.as_ref::<&'static str>() {
Some(s) => *s,
None => match obj.as_ref::<String>() {
/// configured at creation time, via the `FileAccess` parameter to
/// `File::open_mode()`.
pub struct File {
- fd: Box<rtio::RtioFileStream:Send>,
+ fd: Box<rtio::RtioFileStream + Send>,
path: Path,
last_nread: int,
}
/// drop(stream); // close the connection
/// ```
pub struct TcpStream {
- obj: Box<RtioTcpStream:Send>,
+ obj: Box<RtioTcpStream + Send>,
}
impl TcpStream {
- fn new(s: Box<RtioTcpStream:Send>) -> TcpStream {
+ fn new(s: Box<RtioTcpStream + Send>) -> TcpStream {
TcpStream { obj: s }
}
/// # }
/// ```
pub struct TcpListener {
- obj: Box<RtioTcpListener:Send>,
+ obj: Box<RtioTcpListener + Send>,
}
impl TcpListener {
/// a `TcpListener`'s `listen` method, and this object can be used to accept new
/// `TcpStream` instances.
pub struct TcpAcceptor {
- obj: Box<RtioTcpAcceptor:Send>,
+ obj: Box<RtioTcpAcceptor + Send>,
}
impl TcpAcceptor {
/// drop(socket); // close the socket
/// ```
pub struct UdpSocket {
- obj: Box<RtioUdpSocket:Send>,
+ obj: Box<RtioUdpSocket + Send>,
}
impl UdpSocket {
/// A stream which communicates over a named pipe.
pub struct UnixStream {
- obj: Box<RtioPipe:Send>,
+ obj: Box<RtioPipe + Send>,
}
impl UnixStream {
/// A value that can listen for incoming named pipe connection requests.
pub struct UnixListener {
/// The internal, opaque runtime Unix listener.
- obj: Box<RtioUnixListener:Send>,
+ obj: Box<RtioUnixListener + Send>,
}
impl UnixListener {
/// A value that can accept named pipe connections, returned from `listen()`.
pub struct UnixAcceptor {
/// The internal, opaque runtime Unix acceptor.
- obj: Box<RtioUnixAcceptor:Send>,
+ obj: Box<RtioUnixAcceptor + Send>,
}
impl UnixAcceptor {
/// A synchronous, in-memory pipe.
pub struct PipeStream {
/// The internal, opaque runtime pipe object.
- obj: Box<RtioPipe:Send>,
+ obj: Box<RtioPipe + Send>,
}
impl PipeStream {
}
#[doc(hidden)]
- pub fn new(inner: Box<RtioPipe:Send>) -> PipeStream {
+ pub fn new(inner: Box<RtioPipe + Send>) -> PipeStream {
PipeStream { obj: inner }
}
}
/// assert!(child.wait().unwrap().success());
/// ```
pub struct Process {
- handle: Box<RtioProcess:Send>,
+ handle: Box<RtioProcess + Send>,
/// Handle to the child's stdin, if the `stdin` field of this process's
/// `ProcessConfig` was `CreatePipe`. By default, this handle is `Some`.
/// ```
pub struct Listener {
/// A map from signums to handles to keep the handles in memory
- handles: Vec<(Signum, Box<RtioSignal:Send>)>,
+ handles: Vec<(Signum, Box<RtioSignal + Send>)>,
/// This is where all the handles send signums, which are received by
/// the clients from the receiver.
tx: Sender<Signum>,
// tl;dr; TTY works on everything but when windows stdout is redirected, in that
// case pipe also doesn't work, but magically file does!
enum StdSource {
- TTY(Box<RtioTTY:Send>),
- File(Box<RtioFileStream:Send>),
+ TTY(Box<RtioTTY + Send>),
+ File(Box<RtioFileStream + Send>),
}
fn src<T>(fd: libc::c_int, readable: bool, f: |StdSource| -> T) -> T {
}).map_err(IoError::from_rtio_error).unwrap()
}
-local_data_key!(local_stdout: Box<Writer:Send>)
+local_data_key!(local_stdout: Box<Writer + Send>)
/// Creates a new non-blocking handle to the stdin of the current process.
///
///
/// Note that this does not need to be called for all new tasks; the default
/// output handle is to the process's stdout stream.
-pub fn set_stdout(stdout: Box<Writer:Send>) -> Option<Box<Writer:Send>> {
+pub fn set_stdout(stdout: Box<Writer + Send>) -> Option<Box<Writer + Send>> {
local_stdout.replace(Some(stdout)).and_then(|mut s| {
let _ = s.flush();
Some(s)
///
/// Note that this does not need to be called for all new tasks; the default
/// output handle is to the process's stderr stream.
-pub fn set_stderr(stderr: Box<Writer:Send>) -> Option<Box<Writer:Send>> {
+pub fn set_stderr(stderr: Box<Writer + Send>) -> Option<Box<Writer + Send>> {
local_stderr.replace(Some(stderr)).and_then(|mut s| {
let _ = s.flush();
Some(s)
fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) {
let result = if Local::exists(None::<Task>) {
let mut my_stdout = local_stdout.replace(None).unwrap_or_else(|| {
- box stdout() as Box<Writer:Send>
+ box stdout() as Box<Writer + Send>
});
let result = f(my_stdout);
local_stdout.replace(Some(my_stdout));
/// # }
/// ```
pub struct Timer {
- obj: Box<RtioTimer:Send>,
+ obj: Box<RtioTimer + Send>,
}
struct TimerCallback { tx: Sender<()> }
// \\?\D:\
Path::new(repr.slice_from(4))
}
- #[cfg(stage0)]
- Some(VerbatimUNCPrefix(_,_)) => {
- // \\?\UNC\server\share
- Path::new(format!(r"\\{}", repr.slice_from(7)))
- }
- #[cfg(not(stage0))]
Some(VerbatimUNCPrefix(_,_)) => {
// \\?\UNC\server\share
Path::new(format!(r"\{}", repr.slice_from(7)))
/// The size of the stack for the spawned task
pub stack_size: Option<uint>,
/// Task-local stdout
- pub stdout: Option<Box<Writer:Send>>,
+ pub stdout: Option<Box<Writer + Send>>,
/// Task-local stderr
- pub stderr: Option<Box<Writer:Send>>,
+ pub stderr: Option<Box<Writer + Send>>,
}
/**
pub struct TaskBuilder {
/// Options to spawn the new task with
pub opts: TaskOpts,
- gen_body: Option<proc(v: proc():Send):Send -> proc():Send>,
+ gen_body: Option<proc(v: proc(): Send): Send -> proc(): Send>,
nocopy: marker::NoCopy,
}
* existing body generator to the new body generator.
*/
pub fn with_wrapper(mut self,
- wrapper: proc(v: proc():Send):Send -> proc():Send)
+ wrapper: proc(v: proc(): Send): Send -> proc(): Send)
-> TaskBuilder
{
self.gen_body = match self.gen_body.take() {
* the provided unique closure. The task has the properties and behavior
* specified by the task_builder.
*/
- pub fn spawn(mut self, f: proc():Send) {
+ pub fn spawn(mut self, f: proc(): Send) {
let gen_body = self.gen_body.take();
let f = match gen_body {
Some(gen) => gen(f),
* # Failure
* Fails if a future_result was already set for this task.
*/
- pub fn try<T:Send>(mut self, f: proc():Send -> T)
- -> Result<T, Box<Any:Send>> {
+ pub fn try<T: Send>(mut self, f: proc(): Send -> T)
+ -> Result<T, Box<Any + Send>> {
let (tx, rx) = channel();
let result = self.future_result();
/// the provided unique closure.
///
/// This function is equivalent to `TaskBuilder::new().spawn(f)`.
-pub fn spawn(f: proc():Send) {
+pub fn spawn(f: proc(): Send) {
TaskBuilder::new().spawn(f)
}
/// the function or an error if the task failed
///
/// This is equivalent to TaskBuilder::new().try
-pub fn try<T:Send>(f: proc():Send -> T) -> Result<T, Box<Any:Send>> {
+pub fn try<T: Send>(f: proc(): Send -> T) -> Result<T, Box<Any + Send>> {
TaskBuilder::new().try(f)
}
fn test_with_wrapper() {
let (tx, rx) = channel();
TaskBuilder::new().with_wrapper(proc(body) {
- let result: proc():Send = proc() {
+ let result: proc(): Send = proc() {
body();
tx.send(());
};
}
#[cfg(test)]
-fn avoid_copying_the_body(spawnfn: |v: proc():Send|) {
+fn avoid_copying_the_body(spawnfn: |v: proc(): Send|) {
let (tx, rx) = channel::<uint>();
let x = box 1;
// (well, it would if the constant were 8000+ - I lowered it to be more
// valgrind-friendly. try this at home, instead..!)
static generations: uint = 16;
- fn child_no(x: uint) -> proc():Send {
+ fn child_no(x: uint) -> proc(): Send {
return proc() {
if x < generations {
TaskBuilder::new().spawn(child_no(x+1));
#[test]
fn test_try_fail_message_any() {
match try(proc() {
- fail!(box 413u16 as Box<Any:Send>);
+ fail!(box 413u16 as Box<Any + Send>);
}) {
Err(e) => {
- type T = Box<Any:Send>;
+ type T = Box<Any + Send>;
assert!(e.is::<T>());
let any = e.move::<T>().unwrap();
assert!(any.is::<u16>());
let m = Arc::new(Mutex::new());
let m2 = m.clone();
- let result: result::Result<(), Box<Any:Send>> = task::try(proc() {
+ let result: result::Result<(), Box<Any + Send>> = task::try(proc() {
let _lock = m2.lock();
fail!();
});
let x = Arc::new(RWLock::new());
let x2 = x.clone();
- let result: result::Result<(), Box<Any:Send>> = task::try(proc() {
+ let result: result::Result<(), Box<Any + Send>> = task::try(proc() {
lock_rwlock_in_mode(&x2, mode1, || {
fail!();
})
}
impl fmt::Show for CrateId {
- #[cfg(stage0)]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(f, "{}", self.path));
- let version = match self.version {
- None => "0.0",
- Some(ref version) => version.as_slice(),
- };
- if self.path == self.name ||
- self.path
- .as_slice()
- .ends_with(format!("/{}", self.name).as_slice()) {
- write!(f, "\\#{}", version)
- } else {
- write!(f, "\\#{}:{}", self.name, version)
- }
- }
- #[cfg(not(stage0))]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f, "{}", self.path));
let version = match self.version {
// others log errors for later reporting.
pub struct Handler {
err_count: Cell<uint>,
- emit: RefCell<Box<Emitter:Send>>,
+ emit: RefCell<Box<Emitter + Send>>,
}
impl Handler {
mk_handler(box EmitterWriter::stderr(color_config))
}
-pub fn mk_handler(e: Box<Emitter:Send>) -> Handler {
+pub fn mk_handler(e: Box<Emitter + Send>) -> Handler {
Handler {
err_count: Cell::new(0),
emit: RefCell::new(e),
}
enum Destination {
- Terminal(Box<term::Terminal<Box<Writer:Send>>:Send>),
- Raw(Box<Writer:Send>),
+ Terminal(Box<term::Terminal<Box<Writer + Send>> + Send>),
+ Raw(Box<Writer + Send>),
}
impl EmitterWriter {
}
}
- pub fn new(dst: Box<Writer:Send>) -> EmitterWriter {
+ pub fn new(dst: Box<Writer + Send>) -> EmitterWriter {
EmitterWriter { dst: Raw(dst) }
}
}
inputs.push((constraint, input));
}
}
- #[cfg(stage0)]
- Clobbers => {
- let mut clobs = Vec::new();
- while p.token != token::EOF &&
- p.token != token::COLON &&
- p.token != token::MOD_SEP {
-
- if clobs.len() != 0 {
- p.eat(&token::COMMA);
- }
-
- let (s, _str_style) = p.parse_str();
- let clob = format!("~\\{{}\\}", s);
- clobs.push(clob);
-
- if OPTIONS.iter().any(|opt| s.equiv(opt)) {
- cx.span_warn(p.last_span, "expected a clobber, but found an option");
- }
- }
-
- cons = clobs.connect(",");
- }
- #[cfg(not(stage0))]
Clobbers => {
let mut clobs = Vec::new();
while p.token != token::EOF &&
/// A normal, function-like syntax extension.
///
/// `bytes!` is a `NormalTT`.
- NormalTT(Box<MacroExpander:'static>, Option<Span>),
+ NormalTT(Box<MacroExpander + 'static>, Option<Span>),
/// A function-like syntax extension that has an extra ident before
/// the block.
///
/// `macro_rules!` is an `IdentTT`.
- IdentTT(Box<IdentMacroExpander:'static>, Option<Span>),
+ IdentTT(Box<IdentMacroExpander + 'static>, Option<Span>),
}
pub type NamedSyntaxExtension = (Name, SyntaxExtension);
let hi = self.span.hi;
(mk_sp(lo, hi), meta_item, style)
}
- #[cfg(stage0)]
- _ => {
- let token_str = self.this_token_to_str();
- self.fatal(format!("expected `\\#` but found `{}`",
- token_str).as_slice());
- }
- #[cfg(not(stage0))]
_ => {
let token_str = self.this_token_to_str();
self.fatal(format!("expected `#` but found `{}`",
pub tokens_consumed: uint,
pub restriction: restriction,
pub quote_depth: uint, // not (yet) related to the quasiquoter
- pub reader: Box<Reader:>,
+ pub reader: Box<Reader>,
pub interner: Rc<token::IdentInterner>,
/// The set of seen errors about obsolete syntax. Used to suppress
/// extra detail when the same error is seen twice
}
impl<'a> Parser<'a> {
- pub fn new(sess: &'a ParseSess, cfg: ast::CrateConfig, mut rdr: Box<Reader:>) -> Parser<'a> {
+ pub fn new(sess: &'a ParseSess, cfg: ast::CrateConfig,
+ mut rdr: Box<Reader>) -> Parser<'a> {
let tok0 = rdr.next_token();
let span = tok0.sp;
let placeholder = TokenAndSpan {
})
}
- #[cfg(stage0)]
- _ => {
- let token_str = p.this_token_to_str();
- p.fatal((format!("expected `;` or `\\{` but found `{}`",
- token_str)).as_slice())
- }
- #[cfg(not(stage0))]
_ => {
let token_str = p.this_token_to_str();
p.fatal((format!("expected `;` or `{{` but found `{}`",
}
// Next, parse a plus and bounded type parameters, if applicable.
- //
- // NOTE(stage0, pcwalton): Remove `token::COLON` after a snapshot.
let bounds = if mode == LifetimeAndTypesAndBounds {
let bounds = {
- if self.eat(&token::BINOP(token::PLUS)) ||
- self.eat(&token::COLON) {
+ if self.eat(&token::BINOP(token::PLUS)) {
let (_, bounds) = self.parse_ty_param_bounds(false);
Some(bounds)
} else {
// consuming more tokens).
let (bra, ket) = match token::close_delimiter_for(&self.token) {
Some(ket) => (self.token.clone(), ket),
- #[cfg(stage0)]
- None => {
- // we only expect an ident if we didn't parse one
- // above.
- let ident_str = if id == token::special_idents::invalid {
- "identifier, "
- } else {
- ""
- };
- let tok_str = self.this_token_to_str();
- self.fatal(format!("expected {}`(` or `\\{`, but found `{}`",
- ident_str,
- tok_str).as_slice())
- }
- #[cfg(not(stage0))]
None => {
// we only expect an ident if we didn't parse one
// above.
self.bump();
}
token::RBRACE => {}
- #[cfg(stage0)]
- _ => {
- let span = self.span;
- let token_str = self.this_token_to_str();
- self.span_fatal(span,
- format!("expected `,`, or `\\}` but found `{}`",
- token_str).as_slice())
- }
- #[cfg(not(stage0))]
_ => {
let span = self.span;
let token_str = self.this_token_to_str();
#[cfg(not(windows))]
/// Return a Terminal wrapping stdout, or None if a terminal couldn't be
/// opened.
-pub fn stdout() -> Option<Box<Terminal<Box<Writer:Send>>:Send>> {
- let ti: Option<TerminfoTerminal<Box<Writer:Send>>>
- = Terminal::new(box std::io::stdout() as Box<Writer:Send>);
- ti.map(|t| box t as Box<Terminal<Box<Writer:Send>:Send>:Send>)
+pub fn stdout() -> Option<Box<Terminal<Box<Writer + Send>> + Send>> {
+ let ti: Option<TerminfoTerminal<Box<Writer + Send>>>
+ = Terminal::new(box std::io::stdout() as Box<Writer + Send>);
+ ti.map(|t| box t as Box<Terminal<Box<Writer + Send> + Send> + Send>)
}
#[cfg(windows)]
/// Return a Terminal wrapping stdout, or None if a terminal couldn't be
/// opened.
-pub fn stdout() -> Option<Box<Terminal<Box<Writer:Send>:Send>:Send>> {
- let ti: Option<TerminfoTerminal<Box<Writer:Send>>>
- = Terminal::new(box std::io::stdout() as Box<Writer:Send>);
+pub fn stdout() -> Option<Box<Terminal<Box<Writer + Send> + Send> + Send>> {
+ let ti: Option<TerminfoTerminal<Box<Writer + Send>>>
+ = Terminal::new(box std::io::stdout() as Box<Writer + Send>);
match ti {
- Some(t) => Some(box t as Box<Terminal<Box<Writer:Send>:Send>:Send>),
+ Some(t) => Some(box t as Box<Terminal<Box<Writer + Send> + Send> + Send>),
None => {
- let wc: Option<WinConsole<Box<Writer:Send>>>
- = Terminal::new(box std::io::stdout() as Box<Writer:Send>);
- wc.map(|w| box w as Box<Terminal<Box<Writer:Send>:Send>:Send>)
+ let wc: Option<WinConsole<Box<Writer + Send>>>
+ = Terminal::new(box std::io::stdout() as Box<Writer + Send>);
+ wc.map(|w| box w as Box<Terminal<Box<Writer + Send> + Send> + Send>)
}
}
}
#[cfg(not(windows))]
/// Return a Terminal wrapping stderr, or None if a terminal couldn't be
/// opened.
-pub fn stderr() -> Option<Box<Terminal<Box<Writer:Send>:Send>:Send>:Send> {
- let ti: Option<TerminfoTerminal<Box<Writer:Send>>>
- = Terminal::new(box std::io::stderr() as Box<Writer:Send>);
- ti.map(|t| box t as Box<Terminal<Box<Writer:Send>:Send>:Send>)
+pub fn stderr() -> Option<Box<Terminal<Box<Writer + Send> + Send> + Send> + Send> {
+ let ti: Option<TerminfoTerminal<Box<Writer + Send>>>
+ = Terminal::new(box std::io::stderr() as Box<Writer + Send>);
+ ti.map(|t| box t as Box<Terminal<Box<Writer + Send> + Send> + Send>)
}
#[cfg(windows)]
/// Return a Terminal wrapping stderr, or None if a terminal couldn't be
/// opened.
-pub fn stderr() -> Option<Box<Terminal<Box<Writer:Send>:Send>:Send>> {
- let ti: Option<TerminfoTerminal<Box<Writer:Send>>>
- = Terminal::new(box std::io::stderr() as Box<Writer:Send>);
+pub fn stderr() -> Option<Box<Terminal<Box<Writer + Send> + Send> + Send>> {
+ let ti: Option<TerminfoTerminal<Box<Writer + Send>>>
+ = Terminal::new(box std::io::stderr() as Box<Writer + Send>);
match ti {
- Some(t) => Some(box t as Box<Terminal<Box<Writer:Send>:Send>:Send>),
+ Some(t) => Some(box t as Box<Terminal<Box<Writer + Send> + Send> + Send>),
None => {
- let wc: Option<WinConsole<Box<Writer:Send>>>
- = Terminal::new(box std::io::stderr() as Box<Writer:Send>);
- wc.map(|w| box w as Box<Terminal<Box<Writer:Send>:Send>:Send>)
+ let wc: Option<WinConsole<Box<Writer + Send>>>
+ = Terminal::new(box std::io::stderr() as Box<Writer + Send>);
+ wc.map(|w| box w as Box<Terminal<Box<Writer + Send> + Send> + Send>)
}
}
}
Test Attributes:
- \#[test] - Indicates a function is a test to be run. This function
+ #[test] - Indicates a function is a test to be run. This function
takes no arguments.
- \#[bench] - Indicates a function is a benchmark to be run. This
+ #[bench] - Indicates a function is a benchmark to be run. This
function takes one argument (test::Bencher).
- \#[should_fail] - This function (also labeled with \#[test]) will only pass if
+ #[should_fail] - This function (also labeled with #[test]) will only pass if
the code causes a failure (an assertion failure or fail!)
- \#[ignore] - When applied to a function which is already attributed as a
+ #[ignore] - When applied to a function which is already attributed as a
test, then the test runner will ignore these tests during
normal test runs. Running with --ignored will run these
- tests. This may also be written as \#[ignore(cfg(...))] to
+ tests. This may also be written as #[ignore(cfg(...))] to
ignore the test on certain configurations.",
usage = getopts::usage(message.as_slice(),
optgroups().as_slice()));
}
enum OutputLocation<T> {
- Pretty(Box<term::Terminal<Box<Writer:Send>>:Send>),
+ Pretty(Box<term::Terminal<Box<Writer + Send>> + Send>),
Raw(T),
}
if nocapture {
drop((stdout, stderr));
} else {
- task.opts.stdout = Some(box stdout as Box<Writer:Send>);
- task.opts.stderr = Some(box stderr as Box<Writer:Send>);
+ task.opts.stdout = Some(box stdout as Box<Writer + Send>);
+ task.opts.stderr = Some(box stderr as Box<Writer + Send>);
}
let result_future = task.future_result();
task.spawn(testfn);
+S 2014-06-14 2c6caad
+ freebsd-x86_64 0152ba43f238014f0aede7c29f1c684c21077b0b
+ linux-i386 2eb1897c25abe0d5978ff03171ca943e92666046
+ linux-x86_64 c974465b482334461bf9771864eee3873e3cb3f9
+ macos-i386 5b138c0ea9028ec56ed215ad86ec3e69e5a9ffd3
+ macos-x86_64 294afb78328d63c7774f07303ef7138219ee02e7
+ winnt-i386 303afde8b5ca002c151f42df727d6ae701d086cd
+
S 2014-06-11 f9260d4
freebsd-x86_64 57f155da12e561a277506f999a616ff689a55dcc
linux-i386 df46b5dab3620375d6175c284ea0aeb3f9c6a11e
}
struct A {
- v: Box<Foo:Send>,
+ v: Box<Foo + Send>,
}
fn main() {
fn get(&self) -> A { self.clone() }
}
-fn repeater<A:Clone>(v: A) -> Box<Repeat<A>:> {
- box v as Box<Repeat<A>:> // No
+fn repeater<A:Clone>(v: A) -> Box<Repeat<A>> {
+ box v as Box<Repeat<A>> // No
}
fn main() {
trait X {}
impl<'a, T> X for B<'a, T> {}
-fn f<'a, T, U>(v: Box<A<T>>) -> Box<X:> {
- box B(v) as Box<X:> //~ ERROR value may contain references; add `'static` bound to `T`
+fn f<'a, T, U>(v: Box<A<T>>) -> Box<X> {
+ box B(v) as Box<X> //~ ERROR value may contain references; add `'static` bound to `T`
}
-fn g<'a, T, U>(v: Box<A<U>>) -> Box<X:> {
- box B(v) as Box<X:> //~ ERROR value may contain references; add `'static` bound to `U`
+fn g<'a, T, U>(v: Box<A<U>>) -> Box<X> {
+ box B(v) as Box<X> //~ ERROR value may contain references; add `'static` bound to `U`
}
-fn h<'a, T: 'static>(v: Box<A<T>>) -> Box<X:> {
- box B(v) as Box<X:> // ok
+fn h<'a, T: 'static>(v: Box<A<T>>) -> Box<X> {
+ box B(v) as Box<X> // ok
}
fn main() {}
trait Foo { }
-fn foo<'a>(x: Box<Foo:'a>) { //~ ERROR only the 'static lifetime is accepted here
+fn foo<'a>(x: Box<Foo + 'a>) { //~ ERROR only the 'static lifetime is accepted here
}
fn bar<'a, T:'a>() { //~ ERROR only the 'static lifetime is accepted here
// This should emit the less confusing error, not the more confusing one.
-fn foo(_x: Foo:Send) {
+fn foo(_x: Foo + Send) {
//~^ERROR reference to trait `Foo` where a type is expected; try `Box<Foo>` or `&Foo`
}
struct Bar;
-impl Foo:Owned for Bar { //~ ERROR bounded traits are only valid in type position
+impl Foo + Owned for Bar { //~ ERROR bounded traits are only valid in type position
}
fn main() { }
struct Foo;
-fn foo(_x: Box<Foo:Send>) { } //~ ERROR kind bounds can only be used on trait types
+fn foo(_x: Box<Foo + Send>) { } //~ ERROR kind bounds can only be used on trait types
fn main() { }
}
}
-fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>:> {
+fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>> {
box Invoker {
a: a,
b: b,
- } as (Box<Invokable<A>>+)
+ } as (Box<Invokable<A>>)
}
pub fn main() {
trait hax { }
impl<A> hax for A { }
-fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax:> {
- box x as Box<hax:>
+fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax> {
+ box x as Box<hax>
}
fn deadcode() {
trait hax { }
impl<A> hax for A { }
-fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax:> {
- box x as Box<hax:>
+fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax> {
+ box x as Box<hax>
}
fn deadcode() {
trait A {}
impl<T: 'static> A for T {}
-fn owned1<T: 'static>(a: T) { box a as Box<A:>; } /* note `:` */
-fn owned2<T: 'static>(a: Box<T>) { a as Box<A:>; }
-fn owned3<T: 'static>(a: Box<T>) { box a as Box<A:>; }
+fn owned1<T: 'static>(a: T) { box a as Box<A+>; } /* note `:` */
+fn owned2<T: 'static>(a: Box<T>) { a as Box<A>; }
+fn owned3<T: 'static>(a: Box<T>) { box a as Box<A>; }
}
}
-fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<repeat<A>:> {
+fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<repeat<A>> {
// Note: owned kind is not necessary as A appears in the trait type
- box v as Box<repeat<A>:> // No
+ box v as Box<repeat<A>> // No
}
pub fn main() {
}
pub fn main() {
- let foos: Vec<Box<FooTrait:>> = vec!(
- box BarStruct{ x: box(GC) 0 } as Box<FooTrait:>,
- box BarStruct{ x: box(GC) 1 } as Box<FooTrait:>,
- box BarStruct{ x: box(GC) 2 } as Box<FooTrait:>
+ let foos: Vec<Box<FooTrait>> = vec!(
+ box BarStruct{ x: box(GC) 0 } as Box<FooTrait>,
+ box BarStruct{ x: box(GC) 1 } as Box<FooTrait>,
+ box BarStruct{ x: box(GC) 2 } as Box<FooTrait>
);
for i in range(0u, foos.len()) {
}
pub fn main() {
- let foo = box BarStruct{ x: 22 } as Box<FooTrait:>;
+ let foo = box BarStruct{ x: 22 } as Box<FooTrait>;
assert_eq!(22, foo.foo());
}
pub trait D<'a, T> {}
}
-fn foo1<T>(_: &A<T>: Send) {}
-fn foo2<T>(_: Box<A<T>: Send + Share>) {}
-fn foo3<T>(_: Box<B<int, uint>: 'static>) {}
-fn foo4<'a, T>(_: Box<C<'a, T>: 'static + Send>) {}
-fn foo5<'a, T>(_: Box<foo::D<'a, T>: 'static + Send>) {}
+fn foo1<T>(_: &A<T> + Send) {}
+fn foo2<T>(_: Box<A<T> + Send + Share>) {}
+fn foo3<T>(_: Box<B<int, uint> + 'static>) {}
+fn foo4<'a, T>(_: Box<C<'a, T> + 'static + Send>) {}
+fn foo5<'a, T>(_: Box<foo::D<'a, T> + 'static + Send>) {}
pub fn main() {}
trait Foo { }
-fn foo<'a>(x: Box<Foo:'a>) {
+fn foo<'a>(x: Box<Foo + 'a>) {
}
-fn bar<'a, T:'a>() {
+fn bar<'a, T: 'a>() {
}
pub fn main() { }