From f407d310266eb2525dbfeae595dacb4a761b83fb Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 28 Jul 2014 23:14:18 -0700 Subject: [PATCH] librustc: Implement arbitrary lifetimes in trait objects. All trait objects must be annotated with a lifetime. This means that code like this breaks: fn f(x: Box) { ... } fn g<'a>(x: &'a Trait) { ... } Change this code to: fn f(x: Box) { ... } fn g<'a>(x: &'a Trait<'a>) { ... } This will be eventually addressed by some additions that @nikomatsakis wants. However, the fundamental thrust of this change is necessary to achieve memory safety. Further additions to improve ergonomics will follow. Closes #5723. --- src/liballoc/boxed.rs | 8 +- src/liballoc/lib.rs | 2 +- src/libcore/any.rs | 4 +- src/libcore/fmt/mod.rs | 10 +- src/libcore/lib.rs | 2 +- src/libdebug/lib.rs | 2 +- src/libdebug/repr.rs | 13 +- src/libfourcc/lib.rs | 2 +- src/libgreen/basic.rs | 22 +-- src/libgreen/lib.rs | 8 +- src/libgreen/sched.rs | 16 +-- src/libgreen/simple.rs | 2 +- src/libgreen/task.rs | 10 +- src/libhexfloat/lib.rs | 2 +- src/liblog/lib.rs | 9 +- src/libnative/io/file_unix.rs | 6 +- src/libnative/io/mod.rs | 57 ++++---- src/libnative/io/net.rs | 19 +-- src/libnative/io/pipe_unix.rs | 15 ++- src/libnative/io/timer_unix.rs | 6 +- src/libnative/task.rs | 11 +- src/librand/lib.rs | 2 +- src/libregex_macros/lib.rs | 2 +- src/librustc/driver/driver.rs | 5 +- src/librustc/lib.rs | 1 + src/librustc/metadata/tydecode.rs | 7 +- src/librustc/metadata/tyencode.rs | 4 +- src/librustc/middle/astencode.rs | 21 ++- src/librustc/middle/dataflow.rs | 6 +- src/librustc/middle/expr_use_visitor.rs | 4 +- src/librustc/middle/kind.rs | 35 +---- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/save/mod.rs | 3 +- src/librustc/middle/save/recorder.rs | 2 +- src/librustc/middle/trans/cleanup.rs | 36 ++--- src/librustc/middle/ty.rs | 52 +++++--- src/librustc/middle/ty_fold.rs | 6 +- src/librustc/middle/typeck/astconv.rs | 86 ++++++++---- src/librustc/middle/typeck/check/method.rs | 28 +++- src/librustc/middle/typeck/check/regionck.rs | 42 +++++- src/librustc/middle/typeck/check/vtable.rs | 12 +- src/librustc/middle/typeck/check/writeback.rs | 9 +- src/librustc/middle/typeck/collect.rs | 22 +-- src/librustc/middle/typeck/infer/coercion.rs | 72 +++++++--- src/librustc/middle/typeck/infer/combine.rs | 4 +- .../middle/typeck/infer/error_reporting.rs | 4 +- src/librustc/middle/typeck/infer/mod.rs | 3 +- src/librustc/middle/typeck/infer/test.rs | 8 +- src/librustc/util/ppaux.rs | 8 +- src/librustc_llvm/lib.rs | 10 +- src/librustdoc/clean/mod.rs | 2 +- src/librustrt/lib.rs | 2 +- src/librustrt/local_data.rs | 6 +- src/librustrt/rtio.rs | 73 +++++----- src/librustrt/task.rs | 10 +- src/librustrt/unwind.rs | 11 +- src/librustuv/async.rs | 5 +- src/librustuv/idle.rs | 5 +- src/librustuv/lib.rs | 4 +- src/librustuv/net.rs | 23 ++-- src/librustuv/pipe.rs | 16 +-- src/librustuv/signal.rs | 6 +- src/librustuv/timer.rs | 8 +- src/librustuv/uvio.rs | 73 +++++----- src/libserialize/json.rs | 125 +++++++++++------- src/libserialize/lib.rs | 1 + src/libstd/failure.rs | 2 +- src/libstd/fmt.rs | 2 +- src/libstd/io/fs.rs | 7 +- src/libstd/io/mod.rs | 8 +- src/libstd/io/net/tcp.rs | 8 +- src/libstd/io/net/udp.rs | 2 +- src/libstd/io/net/unix.rs | 6 +- src/libstd/io/pipe.rs | 4 +- src/libstd/io/process.rs | 2 +- src/libstd/io/signal.rs | 2 +- src/libstd/io/stdio.rs | 14 +- src/libstd/io/timer.rs | 2 +- src/libstd/io/util.rs | 9 +- src/libstd/lib.rs | 1 + src/libstd/rt/backtrace.rs | 4 +- src/libstd/task.rs | 34 +++-- src/libsync/comm/select.rs | 2 +- src/libsync/lib.rs | 1 + src/libsync/raw.rs | 12 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/diagnostic.rs | 10 +- src/libsyntax/diagnostics/plugin.rs | 18 ++- src/libsyntax/ext/asm.rs | 2 +- src/libsyntax/ext/base.rs | 33 ++--- src/libsyntax/ext/bytes.rs | 2 +- src/libsyntax/ext/cfg.rs | 2 +- src/libsyntax/ext/concat.rs | 2 +- src/libsyntax/ext/concat_idents.rs | 2 +- src/libsyntax/ext/env.rs | 4 +- src/libsyntax/ext/fmt.rs | 2 +- src/libsyntax/ext/format.rs | 4 +- src/libsyntax/ext/log_syntax.rs | 2 +- src/libsyntax/ext/quote.rs | 14 +- src/libsyntax/ext/source_util.rs | 16 +-- src/libsyntax/ext/trace_macros.rs | 2 +- src/libsyntax/ext/tt/macro_rules.rs | 25 ++-- src/libsyntax/fold.rs | 4 +- src/libsyntax/lib.rs | 2 +- src/libsyntax/parse/mod.rs | 3 +- src/libsyntax/parse/parser.rs | 16 ++- src/libsyntax/print/pp.rs | 4 +- src/libsyntax/print/pprust.rs | 39 +++--- src/libsyntax/visit.rs | 4 +- src/libterm/lib.rs | 41 +++--- src/libtest/lib.rs | 8 +- src/test/auxiliary/issue-2380.rs | 4 +- src/test/auxiliary/macro_crate_test.rs | 2 +- .../plugin_crate_outlive_expansion_phase.rs | 4 +- .../syntax-extension-with-dll-deps-2.rs | 2 +- ...-gate.rs => borrowck-object-lifetime-2.rs} | 16 ++- .../compile-fail/borrowck-object-lifetime.rs | 12 +- src/test/compile-fail/issue-14285.rs | 2 +- src/test/compile-fail/issue-4972.rs | 4 +- src/test/compile-fail/issue-5153.rs | 4 +- src/test/compile-fail/issue-7013.rs | 4 +- src/test/compile-fail/isuue-12470.rs | 4 +- .../kindck-owned-trait-contains.rs | 5 +- .../compile-fail/owned-ptr-static-bound.rs | 19 ++- .../compile-fail/regions-trait-variance.rs | 8 +- src/test/compile-fail/selftype-traittype.rs | 2 +- ...use-after-move-implicity-coerced-object.rs | 5 +- .../compile-fail/variance-trait-matching-2.rs | 4 +- src/test/run-pass/alignment-gep-tup-like-1.rs | 4 +- src/test/run-pass/capturing-logging.rs | 2 +- .../close-over-big-then-small-data.rs | 4 +- src/test/run-pass/colorful-write-macros.rs | 2 +- src/test/run-pass/issue-10802.rs | 8 +- src/test/run-pass/issue-11205.rs | 6 +- src/test/run-pass/issue-11677.rs | 2 +- src/test/run-pass/issue-11881.rs | 3 +- src/test/run-pass/issue-14958.rs | 4 +- src/test/run-pass/issue-14959.rs | 4 +- src/test/run-pass/issue-2734.rs | 4 +- src/test/run-pass/issue-2735.rs | 4 +- src/test/run-pass/issue-5192.rs | 7 +- src/test/run-pass/issue-5708.rs | 8 +- src/test/run-pass/issue-6318.rs | 4 +- src/test/run-pass/issue-8249.rs | 8 +- src/test/run-pass/issue-9719.rs | 12 +- .../run-pass/kindck-owned-trait-contains-1.rs | 4 +- .../regions-early-bound-trait-param.rs | 8 +- src/test/run-pass/task-stderr.rs | 4 +- src/test/run-pass/trait-cast.rs | 18 ++- src/test/run-pass/trait-object-generics.rs | 4 +- src/test/run-pass/unboxed-closures-boxed.rs | 4 +- 151 files changed, 1016 insertions(+), 690 deletions(-) rename src/test/compile-fail/{regions-bound-lists-feature-gate.rs => borrowck-object-lifetime-2.rs} (64%) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 58278d5664e5e..81c40ac8c0701 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -103,14 +103,14 @@ pub trait BoxAny { } #[stable] -impl BoxAny for Box { +impl<'a> BoxAny for Box { #[inline] - fn downcast(self) -> Result, Box> { + fn downcast(self) -> Result, Box> { if self.is::() { unsafe { // Get the raw representation of the trait object let to: TraitObject = - *mem::transmute::<&Box, &TraitObject>(&self); + *mem::transmute::<&Box, &TraitObject>(&self); // Prevent destructor on self being run intrinsics::forget(self); @@ -130,7 +130,7 @@ impl fmt::Show for Box { } } -impl fmt::Show for Box { +impl<'a> fmt::Show for Box { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("Box") } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 6ae91f3897104..2edfdd04357a1 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -69,7 +69,7 @@ html_root_url = "http://doc.rust-lang.org/")] #![no_std] -#![feature(lang_items, phase, unsafe_destructor)] +#![feature(lang_items, phase, unsafe_destructor, issue_5723_bootstrap)] #[phase(plugin, link)] extern crate core; diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 1809988847bc7..211c42a1c1225 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -132,7 +132,7 @@ pub trait AnyRefExt<'a> { } #[stable] -impl<'a> AnyRefExt<'a> for &'a Any { +impl<'a,'b> AnyRefExt<'a> for &'a Any+'b { #[inline] #[stable] fn is(self) -> bool { @@ -181,7 +181,7 @@ pub trait AnyMutRefExt<'a> { } #[stable] -impl<'a> AnyMutRefExt<'a> for &'a mut Any { +impl<'a,'b> AnyMutRefExt<'a> for &'a mut Any+'b { #[inline] #[unstable = "naming conventions around acquiring references may change"] fn downcast_mut(self) -> Option<&'a mut T> { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 5277b473828fc..5af98526b953f 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -81,7 +81,7 @@ pub trait FormatWriter { /// A struct to represent both where to emit formatting strings to and how they /// should be formatted. A mutable version of this is passed to all formatting /// traits. -pub struct Formatter<'a> { +pub struct Formatter<'a,'b> { /// Flags for formatting (packed version of rt::Flag) pub flags: uint, /// Character used as 'fill' whenever there is alignment @@ -93,7 +93,7 @@ pub struct Formatter<'a> { /// Optionally specified precision for numeric types pub precision: Option, - buf: &'a mut FormatWriter, + buf: &'a mut FormatWriter+'b, curarg: slice::Items<'a, Argument<'a>>, args: &'a [Argument<'a>], } @@ -281,7 +281,7 @@ pub fn write(output: &mut FormatWriter, args: &Arguments) -> Result { Ok(()) } -impl<'a> Formatter<'a> { +impl<'a,'b> Formatter<'a,'b> { // First up is the collection of functions used to execute a format string // at runtime. This consumes all of the compile-time statics generated by @@ -520,7 +520,7 @@ impl<'a, T: Show> Show for &'a T { impl<'a, T: Show> Show for &'a mut T { fn fmt(&self, f: &mut Formatter) -> Result { secret_show(&**self, f) } } -impl<'a> Show for &'a Show { +impl<'a,'b> Show for &'a Show+'b { fn fmt(&self, f: &mut Formatter) -> Result { (*self).fmt(f) } } @@ -686,7 +686,7 @@ macro_rules! tuple ( tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } -impl<'a> Show for &'a any::Any { +impl<'a,'b> Show for &'a any::Any+'b { fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") } } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 2809bda4f6ed6..bd16c0cb5bc28 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -58,7 +58,7 @@ #![no_std] #![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)] -#![feature(simd, unsafe_destructor)] +#![feature(simd, unsafe_destructor, issue_5723_bootstrap)] #![deny(missing_doc)] mod macros; diff --git a/src/libdebug/lib.rs b/src/libdebug/lib.rs index 6341a38056359..cc97eeffe7ae9 100644 --- a/src/libdebug/lib.rs +++ b/src/libdebug/lib.rs @@ -25,7 +25,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] #![experimental] -#![feature(managed_boxes, macro_rules)] +#![feature(managed_boxes, macro_rules, issue_5723_bootstrap)] #![allow(experimental)] pub mod fmt; diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index b72cc43b28c60..914f0860ad1bd 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -91,15 +91,15 @@ enum VariantState { AlreadyFound } -pub struct ReprVisitor<'a> { +pub struct ReprVisitor<'a,'b> { ptr: *const u8, ptr_stk: Vec<*const u8>, var_stk: Vec, - writer: &'a mut io::Writer, + writer: &'a mut io::Writer+'b, last_err: Option, } -impl<'a> MovePtr for ReprVisitor<'a> { +impl<'a,'b> MovePtr for ReprVisitor<'a,'b> { #[inline] fn move_ptr(&mut self, adjustment: |*const u8| -> *const u8) { self.ptr = adjustment(self.ptr); @@ -112,9 +112,10 @@ impl<'a> MovePtr for ReprVisitor<'a> { } } -impl<'a> ReprVisitor<'a> { +impl<'a,'b> ReprVisitor<'a,'b> { // Various helpers for the TyVisitor impl - pub fn new(ptr: *const u8, writer: &'a mut io::Writer) -> ReprVisitor<'a> { + pub fn new(ptr: *const u8, writer: &'a mut io::Writer+'b) + -> ReprVisitor<'a,'b> { ReprVisitor { ptr: ptr, ptr_stk: vec!(), @@ -239,7 +240,7 @@ impl<'a> ReprVisitor<'a> { } } -impl<'a> TyVisitor for ReprVisitor<'a> { +impl<'a,'b> TyVisitor for ReprVisitor<'a,'b> { fn visit_bot(&mut self) -> bool { try!(self, self.writer.write("!".as_bytes())); true diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index aa8d84bec1711..bde1d44ec89ca 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -71,7 +71,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let (expr, endian) = parse_tts(cx, tts); let little = match endian { diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index d022474978189..9d2ff2eec9a11 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -23,16 +23,16 @@ use std::rt::rtio::{PausableIdleCallback, Callback}; use std::rt::exclusive::Exclusive; /// This is the only exported function from this module. -pub fn event_loop() -> Box { - box BasicLoop::new() as Box +pub fn event_loop() -> Box { + box BasicLoop::new() as Box } struct BasicLoop { work: Vec, // pending work - remotes: Vec<(uint, Box)>, + remotes: Vec<(uint, Box)>, next_remote: uint, messages: Arc>>, - idle: Option>, + idle: Option>, idle_active: Option>, } @@ -132,22 +132,24 @@ impl EventLoop for BasicLoop { } // FIXME: Seems like a really weird requirement to have an event loop provide. - fn pausable_idle_callback(&mut self, cb: Box) - -> Box { + fn pausable_idle_callback(&mut self, cb: Box) + -> Box { 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 + box BasicPausable { + active: a, + } as Box } - fn remote_callback(&mut self, f: Box) - -> Box { + fn remote_callback(&mut self, f: Box) + -> Box { let id = self.next_remote; self.next_remote += 1; self.remotes.push((id, f)); box BasicRemote::new(self.messages.clone(), id) as - Box + Box } fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory> { None } diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 6e4e2ac0feee3..b19be38ca2f03 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -299,7 +299,7 @@ macro_rules! green_start( ($f:ident) => ( /// The return value is used as the process return code. 0 on success, 101 on /// error. pub fn start(argc: int, argv: *const *const u8, - event_loop_factory: fn() -> Box, + event_loop_factory: fn() -> Box, main: proc():Send) -> int { rt::init(argc, argv); let mut main = Some(main); @@ -320,7 +320,7 @@ pub fn start(argc: int, argv: *const *const u8, /// /// This function will not return until all schedulers in the associated pool /// have returned. -pub fn run(event_loop_factory: fn() -> Box, +pub fn run(event_loop_factory: fn() -> Box, 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. @@ -351,7 +351,7 @@ pub struct PoolConfig { 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, + pub event_loop_factory: fn() -> Box, } impl PoolConfig { @@ -376,7 +376,7 @@ pub struct SchedPool { stack_pool: StackPool, deque_pool: deque::BufferPool>, sleepers: SleeperList, - factory: fn() -> Box, + factory: fn() -> Box, task_state: TaskState, tasks_done: Receiver<()>, } diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index 38bb6e355a771..7218246bb8038 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -83,7 +83,7 @@ pub struct Scheduler { /// A fast XorShift rng for scheduler use rng: XorShiftRng, /// A toggleable idle callback - idle_callback: Option>, + idle_callback: Option>, /// 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. @@ -100,7 +100,7 @@ pub struct Scheduler { // destroyed before it's actually destroyed. /// The event loop used to drive the scheduler and perform I/O - pub event_loop: Box, + pub event_loop: Box, } /// An indication of how hard to work on a given operation, the difference @@ -123,7 +123,7 @@ impl Scheduler { // * Initialization Functions pub fn new(pool_id: uint, - event_loop: Box, + event_loop: Box, work_queue: deque::Worker>, work_queues: Vec>>, sleeper_list: SleeperList, @@ -136,7 +136,7 @@ impl Scheduler { } pub fn new_special(pool_id: uint, - event_loop: Box, + event_loop: Box, work_queue: deque::Worker>, work_queues: Vec>>, sleeper_list: SleeperList, @@ -181,9 +181,8 @@ impl Scheduler { // Take a main task to run, and a scheduler to run it in. Create a // scheduler task and bootstrap into it. pub fn bootstrap(mut self: Box) { - // Build an Idle callback. - let cb = box SchedRunner as Box; + let cb = box SchedRunner as Box; self.idle_callback = Some(self.event_loop.pausable_idle_callback(cb)); // Create a task for the scheduler with an empty context. @@ -232,7 +231,8 @@ impl Scheduler { // mutable reference to the event_loop to give it the "run" // command. unsafe { - let event_loop: *mut Box = &mut self.event_loop; + let event_loop: *mut Box = + &mut self.event_loop; // Our scheduler must be in the task before the event loop // is started. stask.put_with_sched(self); @@ -908,7 +908,7 @@ pub enum SchedMessage { } pub struct SchedHandle { - remote: Box, + remote: Box, queue: msgq::Producer, pub sched_id: uint } diff --git a/src/libgreen/simple.rs b/src/libgreen/simple.rs index 6254e8c55f007..058a00bcd4bc0 100644 --- a/src/libgreen/simple.rs +++ b/src/libgreen/simple.rs @@ -82,7 +82,7 @@ impl Runtime for SimpleTask { fn local_io<'a>(&'a mut self) -> Option> { None } fn stack_bounds(&self) -> (uint, uint) { fail!() } fn can_block(&self) -> bool { true } - fn wrap(self: Box) -> Box { fail!() } + fn wrap(self: Box) -> Box { fail!() } } pub fn task() -> Box { diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index 3d3b413384050..96afbca124d74 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -456,7 +456,11 @@ impl Runtime for GreenTask { // Local I/O is provided by the scheduler's event loop fn local_io<'a>(&'a mut self) -> Option> { match self.sched.get_mut_ref().event_loop.io() { - Some(io) => Some(rtio::LocalIo::new(io)), + Some(io) => { + unsafe { + Some(rtio::LocalIo::new(mem::transmute(io))) + } + } None => None, } } @@ -473,7 +477,9 @@ impl Runtime for GreenTask { fn can_block(&self) -> bool { false } - fn wrap(self: Box) -> Box { self as Box } + fn wrap(self: Box) -> Box { + self as Box + } } #[cfg(test)] diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index 2859e1c985f5e..6aa70dd91e284 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -103,7 +103,7 @@ fn hex_float_lit_err(s: &str) -> Option<(uint, String)> { } pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let (expr, ty_lit) = parse_tts(cx, tts); let ty = match ty_lit { diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 554f27b881b72..a7ea8acadef39 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -155,7 +155,7 @@ pub static WARN: u32 = 2; /// Error log level pub static ERROR: u32 = 1; -local_data_key!(local_logger: Box) +local_data_key!(local_logger: Box) /// 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 @@ -226,7 +226,9 @@ pub fn log(level: u32, loc: &'static LogLocation, args: &fmt::Arguments) { // 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 + box DefaultLogger { + handle: io::stderr(), + } as Box }); logger.log(&LogRecord { level: LogLevel(level), @@ -246,7 +248,8 @@ pub fn log_level() -> u32 { unsafe { LOG_LEVEL } } /// Replaces the task-local logger with the specified logger, returning the old /// logger. -pub fn set_logger(logger: Box) -> Option> { +pub fn set_logger(logger: Box) + -> Option> { local_logger.replace(Some(logger)) } diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index ddcff2be5f340..21ef2777f3c3b 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -168,8 +168,10 @@ impl rtio::RtioPipe for FileDesc { fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.inner_write(buf) } - fn clone(&self) -> Box { - box FileDesc { inner: self.inner.clone() } as Box + fn clone(&self) -> Box { + box FileDesc { + inner: self.inner.clone(), + } as Box } // Only supported on named pipes currently. Note that this doesn't have an diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs index ecdf4ad2c45f4..25df1adf675f9 100644 --- a/src/libnative/io/mod.rs +++ b/src/libnative/io/mod.rs @@ -169,36 +169,35 @@ impl IoFactory { impl rtio::IoFactory for IoFactory { // networking - fn tcp_connect(&mut self, addr: rtio::SocketAddr, - timeout: Option) - -> IoResult> + fn tcp_connect(&mut self, addr: rtio::SocketAddr, timeout: Option) + -> IoResult> { net::TcpStream::connect(addr, timeout).map(|s| { - box s as Box + box s as Box }) } fn tcp_bind(&mut self, addr: rtio::SocketAddr) - -> IoResult> { + -> IoResult> { net::TcpListener::bind(addr).map(|s| { - box s as Box + box s as Box }) } fn udp_bind(&mut self, addr: rtio::SocketAddr) - -> IoResult> { + -> IoResult> { net::UdpSocket::bind(addr).map(|u| { - box u as Box + box u as Box }) } fn unix_bind(&mut self, path: &CString) - -> IoResult> { + -> IoResult> { pipe::UnixListener::bind(path).map(|s| { - box s as Box + box s as Box }) } fn unix_connect(&mut self, path: &CString, - timeout: Option) -> IoResult> { + timeout: Option) -> IoResult> { pipe::UnixStream::connect(path, timeout).map(|s| { - box s as Box + box s as Box }) } fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>, @@ -210,18 +209,18 @@ impl rtio::IoFactory for IoFactory { // filesystem operations fn fs_from_raw_fd(&mut self, fd: c_int, close: rtio::CloseBehavior) - -> Box { + -> Box { let close = match close { rtio::CloseSynchronously | rtio::CloseAsynchronously => true, rtio::DontClose => false }; - box file::FileDesc::new(fd, close) as Box + box file::FileDesc::new(fd, close) as Box } fn fs_open(&mut self, path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess) - -> IoResult> + -> IoResult> { - file::open(path, fm, fa).map(|fd| box fd as Box) + file::open(path, fm, fa).map(|fd| box fd as Box) } fn fs_unlink(&mut self, path: &CString) -> IoResult<()> { file::unlink(path) @@ -265,30 +264,30 @@ impl rtio::IoFactory for IoFactory { } // misc - fn timer_init(&mut self) -> IoResult> { - timer::Timer::new().map(|t| box t as Box) + fn timer_init(&mut self) -> IoResult> { + timer::Timer::new().map(|t| box t as Box) } fn spawn(&mut self, cfg: rtio::ProcessConfig) - -> IoResult<(Box, - Vec>>)> { + -> IoResult<(Box, + Vec>>)> { process::Process::spawn(cfg).map(|(p, io)| { - (box p as Box, + (box p as Box, io.move_iter().map(|p| p.map(|p| { - box p as Box + box p as Box })).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> { - Ok(box file::FileDesc::new(fd, true) as Box) + fn pipe_open(&mut self, fd: c_int) -> IoResult> { + Ok(box file::FileDesc::new(fd, true) as Box) } #[cfg(unix)] fn tty_open(&mut self, fd: c_int, _readable: bool) - -> IoResult> { + -> IoResult> { if unsafe { libc::isatty(fd) } != 0 { - Ok(box file::FileDesc::new(fd, true) as Box) + Ok(box file::FileDesc::new(fd, true) as Box) } else { Err(IoError { code: libc::ENOTTY as uint, @@ -299,9 +298,9 @@ impl rtio::IoFactory for IoFactory { } #[cfg(windows)] fn tty_open(&mut self, fd: c_int, _readable: bool) - -> IoResult> { + -> IoResult> { if tty::is_tty(fd) { - Ok(box tty::WindowsTTY::new(fd) as Box) + Ok(box tty::WindowsTTY::new(fd) as Box) } else { Err(IoError { code: libc::ERROR_INVALID_HANDLE as uint, @@ -311,7 +310,7 @@ impl rtio::IoFactory for IoFactory { } } fn signal(&mut self, _signal: int, _cb: Box) - -> IoResult> { + -> IoResult> { Err(unimpl()) } } diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index c3eb5e91e90f0..05398310cb6d4 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -397,12 +397,12 @@ impl rtio::RtioTcpStream for TcpStream { self.set_keepalive(None) } - fn clone(&self) -> Box { + fn clone(&self) -> Box { box TcpStream { inner: self.inner.clone(), read_deadline: 0, write_deadline: 0, - } as Box + } as Box } fn close_write(&mut self) -> IoResult<()> { @@ -485,9 +485,9 @@ impl TcpListener { impl rtio::RtioTcpListener for TcpListener { fn listen(self: Box) - -> IoResult> { + -> IoResult> { self.native_listen(128).map(|a| { - box a as Box + box a as Box }) } } @@ -534,8 +534,11 @@ impl rtio::RtioSocket for TcpAcceptor { } impl rtio::RtioTcpAcceptor for TcpAcceptor { - fn accept(&mut self) -> IoResult> { - self.native_accept().map(|s| box s as Box) + fn accept(&mut self) + -> IoResult> { + self.native_accept().map(|s| { + box s as Box + }) } fn accept_simultaneously(&mut self) -> IoResult<()> { Ok(()) } @@ -721,12 +724,12 @@ impl rtio::RtioUdpSocket for UdpSocket { self.set_broadcast(false) } - fn clone(&self) -> Box { + fn clone(&self) -> Box { box UdpSocket { inner: self.inner.clone(), read_deadline: 0, write_deadline: 0, - } as Box + } as Box } fn set_timeout(&mut self, timeout: Option) { diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs index 075ca769d073e..4ad5b55911e51 100644 --- a/src/libnative/io/pipe_unix.rs +++ b/src/libnative/io/pipe_unix.rs @@ -179,8 +179,9 @@ impl rtio::RtioPipe for UnixStream { } } - fn clone(&self) -> Box { - box UnixStream::new(self.inner.clone()) as Box + fn clone(&self) -> Box { + box UnixStream::new(self.inner.clone()) + as Box } fn close_write(&mut self) -> IoResult<()> { @@ -230,9 +231,9 @@ impl UnixListener { impl rtio::RtioUnixListener for UnixListener { fn listen(self: Box) - -> IoResult> { + -> IoResult> { self.native_listen(128).map(|a| { - box a as Box + box a as Box }) } } @@ -265,8 +266,10 @@ impl UnixAcceptor { } impl rtio::RtioUnixAcceptor for UnixAcceptor { - fn accept(&mut self) -> IoResult> { - self.native_accept().map(|s| box s as Box) + fn accept(&mut self) -> IoResult> { + self.native_accept().map(|s| { + box s as Box + }) } fn set_timeout(&mut self, timeout: Option) { self.deadline = timeout.map(|a| ::io::timer::now() + a).unwrap_or(0); diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs index 87c320e0457cb..c6d931004efda 100644 --- a/src/libnative/io/timer_unix.rs +++ b/src/libnative/io/timer_unix.rs @@ -67,7 +67,7 @@ pub struct Timer { } struct Inner { - cb: Option>, + cb: Option>, interval: u64, repeat: bool, target: u64, @@ -254,7 +254,7 @@ impl rtio::RtioTimer for Timer { Timer::sleep(msecs); } - fn oneshot(&mut self, msecs: u64, cb: Box) { + fn oneshot(&mut self, msecs: u64, cb: Box) { let now = now(); let mut inner = self.inner(); @@ -266,7 +266,7 @@ impl rtio::RtioTimer for Timer { unsafe { HELPER.send(NewTimer(inner)); } } - fn period(&mut self, msecs: u64, cb: Box) { + fn period(&mut self, msecs: u64, cb: Box) { let now = now(); let mut inner = self.inner(); diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 35367ff2efab3..7fd9bdf48138d 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -145,8 +145,8 @@ impl rt::Runtime for Ops { Local::put(cur_task); } - fn wrap(self: Box) -> Box { - self as Box + fn wrap(self: Box) -> Box { + self as Box } fn stack_bounds(&self) -> (uint, uint) { self.stack_bounds } @@ -274,7 +274,12 @@ impl rt::Runtime for Ops { } fn local_io<'a>(&'a mut self) -> Option> { - Some(rtio::LocalIo::new(&mut self.io as &mut rtio::IoFactory)) + unsafe { + let io_factory: &mut rtio::IoFactory = &mut self.io; + let io_factory: &mut rtio::IoFactory+'static = + mem::transmute(io_factory); + Some(rtio::LocalIo::new(io_factory)) + } } } diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 9c33b713e4a6b..59ffd94f98317 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -24,7 +24,7 @@ html_root_url = "http://doc.rust-lang.org/master/", html_playground_url = "http://play.rust-lang.org/")] -#![feature(macro_rules, phase, globs)] +#![feature(macro_rules, phase, globs, issue_5723_bootstrap)] #![no_std] #![experimental] diff --git a/src/libregex_macros/lib.rs b/src/libregex_macros/lib.rs index 07539a11113f5..0cf89053abf4e 100644 --- a/src/libregex_macros/lib.rs +++ b/src/libregex_macros/lib.rs @@ -77,7 +77,7 @@ pub fn plugin_registrar(reg: &mut Registry) { /// strategy is identical and vm.rs has comments and will be easier to follow. #[allow(experimental)] fn native(cx: &mut ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let regex = match parse(cx, tts) { Some(r) => r, // error is logged in 'parse' with cx.span_err diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 9796aab51fb6b..e35a2e22c29c7 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -719,11 +719,11 @@ pub fn pretty_print_input(sess: Session, let mut rdr = MemReader::new(src); let out = match ofile { - None => box io::stdout() as Box, + None => box io::stdout() as Box, Some(p) => { let r = io::File::create(&p); match r { - Ok(w) => box w as Box, + Ok(w) => box w as Box, Err(e) => fail!("print-print failed to open {} due to {}", p.display(), e), } @@ -767,6 +767,7 @@ pub fn pretty_print_input(sess: Session, let variants = gather_flowgraph_variants(&sess); let analysis = phase_3_run_analysis_passes(sess, &krate, ast_map, id); + let out: Box = out; print_flowgraph(variants, analysis, code, out) } None => { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 2a7f7e8c54dd1..73f7d54ee5731 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -31,6 +31,7 @@ This API is completely unstable and subject to change. #![allow(deprecated)] #![feature(macro_rules, globs, struct_variant, managed_boxes, quote)] #![feature(default_type_params, phase, unsafe_destructor)] +#![feature(issue_5723_bootstrap)] #![allow(unknown_features)] // NOTE: Remove after next snapshot #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index ffa0cca753904..7f6dd8dcd6481 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -356,8 +356,13 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { let def = parse_def(st, NominalType, |x,y| conv(x,y)); let substs = parse_substs(st, |x,y| conv(x,y)); let bounds = parse_bounds(st, |x,y| conv(x,y)); + let region = parse_region(st, |x,y| conv(x,y)); assert_eq!(next(st), ']'); - return ty::mk_trait(st.tcx, def, substs, bounds.builtin_bounds); + return ty::mk_trait(st.tcx, + def, + substs, + bounds.builtin_bounds, + region); } 'p' => { let did = parse_def(st, TypeParameter, |x,y| conv(x,y)); diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 15e4e85ddb711..acb43d77f69d7 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -231,13 +231,15 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) { ty::ty_trait(box ty::TyTrait { def_id, ref substs, - bounds + bounds, + region }) => { mywrite!(w, "x[{}|", (cx.ds)(def_id)); enc_substs(w, cx, substs); let bounds = ty::ParamBounds {builtin_bounds: bounds, trait_bounds: Vec::new()}; enc_bounds(w, cx, &bounds); + enc_region(w, cx, region); mywrite!(w, "]"); } ty::ty_tup(ref ts) => { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 722715405bce4..7a844226cd565 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -946,12 +946,19 @@ impl<'a> ebml_writer_helpers for Encoder<'a> { }) } - ty::AutoObject(store, b, def_id, ref substs) => { + ty::AutoObject(store, + b, + def_id, + ref substs, + ref lifetime) => { this.emit_enum_variant("AutoObject", 2, 4, |this| { this.emit_enum_variant_arg(0, |this| store.encode(this)); this.emit_enum_variant_arg(1, |this| b.encode(this)); this.emit_enum_variant_arg(2, |this| def_id.encode(this)); - this.emit_enum_variant_arg(3, |this| Ok(this.emit_substs(ecx, substs))) + this.emit_enum_variant_arg(3, |this| Ok(this.emit_substs(ecx, substs))); + this.emit_enum_variant_arg(4, |this| { + lifetime.encode(this) + }) }) } } @@ -1359,8 +1366,14 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> { this.read_enum_variant_arg(2, |this| Decodable::decode(this)).unwrap(); let substs = this.read_enum_variant_arg(3, |this| Ok(this.read_substs(xcx))) .unwrap(); - - ty::AutoObject(store.tr(xcx), b, def_id.tr(xcx), substs) + let region: ty::Region = + this.read_enum_variant_arg(4, |this| Decodable::decode(this)).unwrap(); + + ty::AutoObject(store.tr(xcx), + b, + def_id.tr(xcx), + substs, + region) } _ => fail!("bad enum variant for ty::AutoAdjustment") }) diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 7c5b001354dbb..ffb63ba7fac37 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -458,8 +458,10 @@ impl<'a, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, O> { }); } - fn pretty_print_to(&self, wr: Box, - blk: &ast::Block) -> io::IoResult<()> { + fn pretty_print_to(&self, + wr: Box, + blk: &ast::Block) + -> io::IoResult<()> { let mut ps = pprust::rust_printer_annotated(wr, self); try!(ps.cbox(pprust::indent_unit)); try!(ps.ibox(0u)); diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 605811555a168..f9e7fc097e15c 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -185,7 +185,7 @@ impl OverloadedCallType { pub struct ExprUseVisitor<'d,'t,TYPER> { typer: &'t TYPER, mc: mc::MemCategorizationContext<'t,TYPER>, - delegate: &'d mut Delegate, + delegate: &'d mut Delegate+'d, } // If the TYPER results in an error, it's because the type check @@ -205,7 +205,7 @@ macro_rules! return_if_err( ) impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> { - pub fn new(delegate: &'d mut Delegate, + pub fn new(delegate: &'d mut Delegate+'d, typer: &'t TYPER) -> ExprUseVisitor<'d,'t,TYPER> { ExprUseVisitor { typer: typer, diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index e2e3081eb2d16..dadd2940f147b 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -17,8 +17,7 @@ use middle::ty_fold; use middle::ty_fold::TypeFoldable; use middle::typeck; use middle::typeck::{MethodCall, NoAdjustment}; -use util::ppaux::{Repr, ty_to_string}; -use util::ppaux::UserString; +use util::ppaux::{Repr, UserString, ty_to_string}; use syntax::ast::*; use syntax::attr; @@ -590,11 +589,10 @@ pub fn check_static(tcx: &ty::ctxt, ty: ty::t, sp: Span) -> bool { /// This is rather subtle. When we are casting a value to an instantiated /// trait like `a as trait<'r>`, regionck already ensures that any references -/// that appear in the type of `a` are bounded by `'r` (ed.: rem -/// FIXME(#5723)). However, it is possible that there are *type parameters* -/// in the type of `a`, and those *type parameters* may have references -/// within them. We have to guarantee that the regions which appear in those -/// type parameters are not obscured. +/// that appear in the type of `a` are bounded by `'r`. However, it is +/// possible that there are *type parameters* in the type of `a`, and those +/// *type parameters* may have references within them. We have to guarantee +/// that the regions which appear in those type parameters are not obscured. /// /// Therefore, we ensure that one of three conditions holds: /// @@ -652,30 +650,11 @@ pub fn check_cast_for_escaping_regions( ty::walk_regions_and_ty( cx.tcx, source_ty, - - |_r| { - // FIXME(#5723) --- turn this check on once &Objects are usable - // - // if !target_regions.iter().any(|t_r| is_subregion_of(cx, *t_r, r)) { - // cx.tcx.sess.span_err( - // source_span, - // format!("source contains reference with lifetime \ - // not found in the target type `{}`", - // ty_to_string(cx.tcx, target_ty))); - // note_and_explain_region( - // cx.tcx, "source data is only valid for ", r, ""); - // } - }, - + |_| {}, |ty| { match ty::get(ty).sty { ty::ty_param(source_param) => { - if source_param.space == subst::SelfSpace { - // FIXME (#5723) -- there is no reason that - // Self should be exempt from this check, - // except for historical accident. Bottom - // line, we need proper region bounding. - } else if target_params.iter().any(|x| x == &source_param) { + if target_params.iter().any(|x| x == &source_param) { /* case (2) */ } else { check_static(cx.tcx, ty, source_span); /* case (3) */ diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 95c04ad6607d6..9c4f5da369d5d 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -3964,7 +3964,7 @@ impl<'a> Resolver<'a> { self.resolve_type(&*unboxed_function.decl.output); } - StaticRegionTyParamBound | OtherRegionTyParamBound(_) => {} + StaticRegionTyParamBound | OtherRegionTyParamBound(..) => {} } } diff --git a/src/librustc/middle/save/mod.rs b/src/librustc/middle/save/mod.rs index c4373a023ccb2..933dbb9be2fed 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc/middle/save/mod.rs @@ -1432,7 +1432,8 @@ pub fn process_crate(sess: &Session, collected_paths: vec!(), collecting: false, fmt: FmtStrs::new(box Recorder { - out: output_file as Box, + out: output_file as + Box, dump_spans: false, }, SpanUtils { diff --git a/src/librustc/middle/save/recorder.rs b/src/librustc/middle/save/recorder.rs index 1af6fde02afa4..0695b6b360c2c 100644 --- a/src/librustc/middle/save/recorder.rs +++ b/src/librustc/middle/save/recorder.rs @@ -19,7 +19,7 @@ use syntax::codemap::*; pub struct Recorder { // output file - pub out: Box, + pub out: Box, pub dump_spans: bool, } diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index cf2410f657155..ba4238cda96ca 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -35,7 +35,7 @@ pub struct CleanupScope<'a> { kind: CleanupScopeKind<'a>, // Cleanups to run upon scope exit. - cleanups: Vec>, + cleanups: Vec>, cached_early_exits: Vec, cached_landing_pad: Option, @@ -238,7 +238,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { cleanup_scope, self.ccx.tn.val_to_string(val)); - self.schedule_clean(cleanup_scope, drop as Box); + self.schedule_clean(cleanup_scope, drop as Box); } fn schedule_drop_mem(&self, @@ -264,7 +264,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { self.ccx.tn.val_to_string(val), ty.repr(self.ccx.tcx())); - self.schedule_clean(cleanup_scope, drop as Box); + self.schedule_clean(cleanup_scope, drop as Box); } fn schedule_drop_and_zero_mem(&self, @@ -291,7 +291,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { ty.repr(self.ccx.tcx()), true); - self.schedule_clean(cleanup_scope, drop as Box); + self.schedule_clean(cleanup_scope, drop as Box); } fn schedule_drop_immediate(&self, @@ -316,7 +316,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { self.ccx.tn.val_to_string(val), ty.repr(self.ccx.tcx())); - self.schedule_clean(cleanup_scope, drop as Box); + self.schedule_clean(cleanup_scope, drop as Box); } fn schedule_free_value(&self, @@ -329,19 +329,23 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { * operation. */ - let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty }; + let drop = box FreeValue { + ptr: val, + heap: heap, + content_ty: content_ty, + }; debug!("schedule_free_value({:?}, val={}, heap={:?})", cleanup_scope, self.ccx.tn.val_to_string(val), heap); - self.schedule_clean(cleanup_scope, drop as Box); + self.schedule_clean(cleanup_scope, drop as Box); } fn schedule_clean(&self, cleanup_scope: ScopeId, - cleanup: Box) { + cleanup: Box) { match cleanup_scope { AstScope(id) => self.schedule_clean_in_ast_scope(id, cleanup), CustomScope(id) => self.schedule_clean_in_custom_scope(id, cleanup), @@ -350,7 +354,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { fn schedule_clean_in_ast_scope(&self, cleanup_scope: ast::NodeId, - cleanup: Box) { + cleanup: Box) { /*! * Schedules a cleanup to occur upon exit from `cleanup_scope`. * If `cleanup_scope` is not provided, then the cleanup is scheduled @@ -378,7 +382,7 @@ impl<'a> CleanupMethods<'a> for FunctionContext<'a> { fn schedule_clean_in_custom_scope(&self, custom_scope: CustomScopeIndex, - cleanup: Box) { + cleanup: Box) { /*! * Schedules a cleanup to occur in the top-most scope, * which must be a temporary scope. @@ -983,9 +987,9 @@ pub trait CleanupMethods<'a> { exits: [&'a Block<'a>, ..EXIT_MAX]); fn push_custom_cleanup_scope(&self) -> CustomScopeIndex; fn pop_and_trans_ast_cleanup_scope(&self, - bcx: &'a Block<'a>, - cleanup_scope: ast::NodeId) - -> &'a Block<'a>; + bcx: &'a Block<'a>, + cleanup_scope: ast::NodeId) + -> &'a Block<'a>; fn pop_loop_cleanup_scope(&self, cleanup_scope: ast::NodeId); fn pop_custom_cleanup_scope(&self, @@ -1021,13 +1025,13 @@ pub trait CleanupMethods<'a> { content_ty: ty::t); fn schedule_clean(&self, cleanup_scope: ScopeId, - cleanup: Box); + cleanup: Box); fn schedule_clean_in_ast_scope(&self, cleanup_scope: ast::NodeId, - cleanup: Box); + cleanup: Box); fn schedule_clean_in_custom_scope(&self, custom_scope: CustomScopeIndex, - cleanup: Box); + cleanup: Box); fn needs_invoke(&self) -> bool; fn get_landing_pad(&'a self) -> BasicBlockRef; } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 0f5af4421a5e8..0cf08d32510ad 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -209,7 +209,8 @@ pub enum AutoAdjustment { AutoObject(ty::TraitStore, ty::BuiltinBounds, ast::DefId, /* Trait ID */ - subst::Substs /* Trait substitutions */) + subst::Substs, /* Trait substitutions */ + ty::Region /* Region bound on trait */) } #[deriving(Clone, Decodable, Encodable)] @@ -755,7 +756,9 @@ pub enum sty { pub struct TyTrait { pub def_id: DefId, pub substs: Substs, - pub bounds: BuiltinBounds + pub bounds: BuiltinBounds, + /// The region bound for this trait. + pub region: Region, } #[deriving(PartialEq, Eq, Hash, Show)] @@ -1192,8 +1195,9 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t { &ty_enum(_, ref substs) | &ty_struct(_, ref substs) => { flags |= sflags(substs); } - &ty_trait(box ty::TyTrait { ref substs, .. }) => { + &ty_trait(box ty::TyTrait { ref substs, ref region, .. }) => { flags |= sflags(substs); + flags |= rflags(*region); } &ty_box(tt) | &ty_uniq(tt) => { flags |= get(tt).flags @@ -1420,13 +1424,15 @@ pub fn mk_ctor_fn(cx: &ctxt, pub fn mk_trait(cx: &ctxt, did: ast::DefId, substs: Substs, - bounds: BuiltinBounds) - -> t { + bounds: BuiltinBounds, + region: Region) + -> t { // take a copy of substs so that we own the vectors inside let inner = box TyTrait { def_id: did, substs: substs, - bounds: bounds + bounds: bounds, + region: region, }; mk_t(cx, ty_trait(inner)) } @@ -2948,9 +2954,13 @@ pub fn adjust_ty(cx: &ctxt, } } - AutoObject(store, bounds, def_id, ref substs) => { + AutoObject(store, bounds, def_id, ref substs, ref region) => { - let tr = mk_trait(cx, def_id, substs.clone(), bounds); + let tr = mk_trait(cx, + def_id, + substs.clone(), + bounds, + *region); match store { UniqTraitStore => { mk_uniq(cx, tr) @@ -3000,9 +3010,18 @@ pub fn adjust_ty(cx: &ctxt, m: ast::Mutability, ty: ty::t) -> ty::t { match get(ty).sty { ty_uniq(t) | ty_rptr(_, mt{ty: t, ..}) => match get(t).sty { - ty_trait(box ty::TyTrait {def_id, ref substs, bounds, .. }) => { + ty_trait(box ty::TyTrait { + def_id, + ref substs, + bounds, + region + }) => { mk_rptr(cx, r, mt { - ty: ty::mk_trait(cx, def_id, substs.clone(), bounds), + ty: ty::mk_trait(cx, + def_id, + substs.clone(), + bounds, + region), mutbl: m }) } @@ -4393,11 +4412,14 @@ pub fn visitor_object_ty(tcx: &ctxt, let substs = Substs::empty(); let trait_ref = Rc::new(TraitRef { def_id: trait_lang_item, substs: substs }); Ok((trait_ref.clone(), - mk_rptr(tcx, region, mt {mutbl: ast::MutMutable, - ty: mk_trait(tcx, - trait_ref.def_id, - trait_ref.substs.clone(), - empty_builtin_bounds()) }))) + mk_rptr(tcx, region, mt { + mutbl: ast::MutMutable, + ty: mk_trait(tcx, + trait_ref.def_id, + trait_ref.substs.clone(), + empty_builtin_bounds(), + ReStatic) + }))) } pub fn item_variances(tcx: &ctxt, item_id: ast::DefId) -> Rc { diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index e2b984959060c..d85529a1e9c15 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -369,12 +369,14 @@ pub fn super_fold_sty(this: &mut T, ty::ty_trait(box ty::TyTrait { def_id, ref substs, - bounds + bounds, + region }) => { ty::ty_trait(box ty::TyTrait { def_id: def_id, substs: substs.fold_with(this), - bounds: bounds + bounds: bounds, + region: region.fold_with(this), }) } ty::ty_tup(ref ts) => { diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index d202e61abf332..c6e706e22c412 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -612,7 +612,8 @@ fn mk_pointer { return ty::mk_uniq(this.tcx(), tr); @@ -669,16 +670,31 @@ fn mk_pointer region, + None => { + match rscope.anon_regions(path.span, 1) { + Err(()) => { + tcx.sess.span_err(path.span, + "missing lifetime on \ + trait object"); + ty::ReStatic + } + Ok(regions) => *regions.get(0), + } + } + }; let tr = ty::mk_trait(tcx, result.def_id, result.substs.clone(), - bounds); + bounds, + region); // We could just match on ptr_ty, but we need to pass a trait - // store to conv_builtin_bounds, so mathc twice for now. + // store to conv_builtin_bounds, so match twice for now. return match trait_store { ty::UniqTraitStore => { return ty::mk_uniq(tcx, tr); @@ -775,10 +791,14 @@ pub fn ast_ty_to_ty( // Use corresponding trait store to figure out default bounds // if none were specified. - let bounds = conv_builtin_bounds(this.tcx(), - ast_ty.span, - &f.bounds, - store); + let (bounds, region) = conv_builtin_bounds(this.tcx(), + ast_ty.span, + &f.bounds, + store); + if region.is_some() && region != Some(ty::ReStatic) { + tcx.sess.span_err(ast_ty.span, + "only `'static` is permitted here") + } let fn_decl = ty_of_closure(this, ast_ty.id, @@ -794,10 +814,15 @@ pub fn ast_ty_to_ty( ast::TyProc(ref f) => { // Use corresponding trait store to figure out default bounds // if none were specified. - let bounds = conv_builtin_bounds(this.tcx(), - ast_ty.span, - &f.bounds, - ty::UniqTraitStore); + let (bounds, region) = + conv_builtin_bounds(this.tcx(), + ast_ty.span, + &f.bounds, + ty::UniqTraitStore); + if region.is_some() && region != Some(ty::ReStatic) { + tcx.sess.span_err(ast_ty.span, + "only `'static` is permitted here") + } let fn_decl = ty_of_closure(this, ast_ty.id, @@ -1206,7 +1231,7 @@ fn conv_builtin_bounds(tcx: &ty::ctxt, span: Span, ast_bounds: &Option>, store: ty::TraitStore) - -> ty::BuiltinBounds { + -> (ty::BuiltinBounds, Option) { //! Converts a list of bounds from the AST into a `BuiltinBounds` //! struct. Reports an error if any of the bounds that appear //! in the AST refer to general traits and not the built-in traits @@ -1218,6 +1243,7 @@ fn conv_builtin_bounds(tcx: &ty::ctxt, //! override this with an empty bounds list, e.g. "Box" or //! "Box". + let mut region = None; match (ast_bounds, store) { (&Some(ref bound_vec), _) => { let mut builtin_bounds = ty::empty_builtin_bounds(); @@ -1239,32 +1265,42 @@ fn conv_builtin_bounds(tcx: &ty::ctxt, or object bounds"); } ast::StaticRegionTyParamBound => { + if region.is_some() { + tcx.sess.span_err(span, + "only one lifetime may be \ + present") + } builtin_bounds.add(ty::BoundStatic); + region = Some(ty::ReStatic); } ast::UnboxedFnTyParamBound(_) => { tcx.sess.span_err(span, "unboxed functions are not allowed \ here"); } - ast::OtherRegionTyParamBound(span) => { - if !tcx.sess.features.issue_5723_bootstrap.get() { - tcx.sess.span_err( - span, - "only the 'static lifetime is accepted \ - here."); + ast::OtherRegionTyParamBound(span, ref lifetime) => { + if region.is_some() { + tcx.sess.span_err(span, + "only one lifetime may be \ + present") } + region = Some(ast_region_to_region(tcx, lifetime)) } } } - builtin_bounds + (builtin_bounds, region) }, // &'static Trait is sugar for &'static Trait:'static. (&None, ty::RegionTraitStore(ty::ReStatic, _)) => { - let mut set = ty::empty_builtin_bounds(); set.add(ty::BoundStatic); set + let mut set = ty::empty_builtin_bounds(); + set.add(ty::BoundStatic); + (set, None) } // No bounds are automatically applied for &'r Trait or ~Trait (&None, ty::RegionTraitStore(..)) | - (&None, ty::UniqTraitStore) => ty::empty_builtin_bounds(), + (&None, ty::UniqTraitStore) => { + (ty::empty_builtin_bounds(), None) + } } } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 1805c18eaf10c..9d0463f31d3af 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -270,8 +270,11 @@ fn construct_transformed_self_ty_for_object( tcx.sess.span_bug(span, "static method for object type receiver"); } ByValueExplicitSelfCategory => { - let tr = ty::mk_trait(tcx, trait_def_id, obj_substs, - ty::empty_builtin_bounds()); + let tr = ty::mk_trait(tcx, + trait_def_id, + obj_substs, + ty::empty_builtin_bounds(), + ty::ReStatic); ty::mk_uniq(tcx, tr) } ByReferenceExplicitSelfCategory(..) | ByBoxExplicitSelfCategory => { @@ -279,13 +282,19 @@ fn construct_transformed_self_ty_for_object( match ty::get(transformed_self_ty).sty { ty::ty_rptr(r, mt) => { // must be SelfRegion let r = r.subst(tcx, rcvr_substs); // handle Early-Bound lifetime - let tr = ty::mk_trait(tcx, trait_def_id, obj_substs, - ty::empty_builtin_bounds()); + let tr = ty::mk_trait(tcx, + trait_def_id, + obj_substs, + ty::empty_builtin_bounds(), + ty::ReStatic); ty::mk_rptr(tcx, r, ty::mt{ ty: tr, mutbl: mt.mutbl }) } ty::ty_uniq(_) => { // must be SelfUniq - let tr = ty::mk_trait(tcx, trait_def_id, obj_substs, - ty::empty_builtin_bounds()); + let tr = ty::mk_trait(tcx, + trait_def_id, + obj_substs, + ty::empty_builtin_bounds(), + ty::ReStatic); ty::mk_uniq(tcx, tr) } _ => { @@ -947,12 +956,17 @@ impl<'a> LookupContext<'a> { def_id: trt_did, substs: ref trt_substs, bounds: b, + region: ref region, .. }) => { let tcx = self.tcx(); self.search_for_some_kind_of_autorefd_method( AutoBorrowObj, autoderefs, [MutImmutable, MutMutable], |m, r| { - let tr = ty::mk_trait(tcx, trt_did, trt_substs.clone(), b); + let tr = ty::mk_trait(tcx, + trt_did, + trt_substs.clone(), + b, + *region); ty::mk_rptr(tcx, r, ty::mt{ ty: tr, mutbl: m }) }) } diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index d0431de81a359..19567b2f00fda 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -418,7 +418,11 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { infer::AutoBorrow(expr.span)); } } - ty::AutoObject(ty::RegionTraitStore(trait_region, _), _, _, _) => { + ty::AutoObject(ty::RegionTraitStore(trait_region, _), + _, + _, + _, + region_bound) => { // Determine if we are casting `expr` to a trait // instance. If so, we have to be sure that the type of // the source obeys the trait's region bound. @@ -436,6 +440,21 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { let source_ty = rcx.resolve_node_type(expr.id); constrain_regions_in_type(rcx, trait_region, infer::RelateObjectBound(expr.span), source_ty); + + // Resolve the regions inside the type. + let interior_source_type = match ty::deref(source_ty, true) { + Some(mt) => mt.ty, + None => { + rcx.fcx.tcx().sess.span_bug(expr.span, + "autoobject type wasn't \ + derefable?!") + } + }; + + constrain_regions_in_type(rcx, + region_bound, + infer::RelateObjectBound(expr.span), + interior_source_type); } _ => {} } @@ -548,13 +567,32 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { match ty::get(target_ty).sty { ty::ty_rptr(trait_region, ty::mt{ty, ..}) => { match ty::get(ty).sty { - ty::ty_trait(..) => { + ty::ty_trait(ref ty_trait) => { let source_ty = rcx.resolve_expr_type_adjusted(&**source); constrain_regions_in_type( rcx, trait_region, infer::RelateObjectBound(expr.span), source_ty); + + // Resolve the regions inside the type. + let interior_source_type = + match ty::deref(source_ty, true) { + Some(mt) => mt.ty, + None => { + rcx.fcx + .tcx() + .sess + .span_bug(expr.span, + "trait cast type wasn't \ + derefable?!") + } + }; + constrain_regions_in_type( + rcx, + ty_trait.region, + infer::RelateObjectBound(expr.span), + interior_source_type); } _ => {} } diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 565b88b74939b..f68fc8934ad63 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -553,8 +553,10 @@ fn fixup_substs(vcx: &VtableContext, let tcx = vcx.tcx(); // use a dummy type just to package up the substs that need fixing up let t = ty::mk_trait(tcx, - id, substs, - ty::empty_builtin_bounds()); + id, + substs, + ty::empty_builtin_bounds(), + ty::ReStatic); fixup_ty(vcx, span, t, is_early).map(|t_f| { match ty::get(t_f).sty { ty::ty_trait(ref inner) => inner.substs.clone(), @@ -812,7 +814,8 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) { AutoObject(store, bounds, def_id, - ref substs) => { + ref substs, + ref region) => { debug!("doing trait adjustment for expr {} {} \ (early? {})", ex.id, @@ -822,7 +825,8 @@ pub fn early_resolve_expr(ex: &ast::Expr, fcx: &FnCtxt, is_early: bool) { let trait_ty = ty::mk_trait(cx.tcx, def_id, substs.clone(), - bounds); + bounds, + *region); let object_ty = match store { ty::UniqTraitStore => ty::mk_uniq(cx.tcx, trait_ty), ty::RegionTraitStore(r, m) => { diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index c3e7d06f3f896..ecd1ec089353b 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -282,7 +282,11 @@ impl<'cx> WritebackCx<'cx> { }) } - ty::AutoObject(trait_store, bb, def_id, substs) => { + ty::AutoObject(trait_store, + bb, + def_id, + substs, + region) => { let method_call = MethodCall::autoobject(id); self.visit_method_map_entry(reason, method_call); self.visit_vtable_map_entry(reason, method_call); @@ -291,7 +295,8 @@ impl<'cx> WritebackCx<'cx> { self.resolve(&trait_store, reason), self.resolve(&bb, reason), def_id, - self.resolve(&substs, reason) + self.resolve(&substs, reason), + self.resolve(®ion, reason) ) } }; diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 780faddb88639..e9fe5ff66faed 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -1149,14 +1149,13 @@ fn ty_generics(ccx: &CrateCtxt, def } - fn compute_bounds( - ccx: &CrateCtxt, - param_ty: ty::ParamTy, - ast_bounds: &OwnedSlice, - unbound: &Option, - ident: ast::Ident, - span: Span) -> ty::ParamBounds - { + fn compute_bounds(ccx: &CrateCtxt, + param_ty: ty::ParamTy, + ast_bounds: &OwnedSlice, + unbound: &Option, + ident: ast::Ident, + span: Span) + -> ty::ParamBounds { /*! * Translate the AST's notion of ty param bounds (which are an * enum consisting of a newtyped Ty or a region) to ty's @@ -1183,6 +1182,7 @@ fn ty_generics(ccx: &CrateCtxt, } StaticRegionTyParamBound => { + // FIXME(pcwalton): Other lifetimes conflict with 'static. param_bounds.builtin_bounds.add(ty::BoundStatic); } @@ -1200,12 +1200,12 @@ fn ty_generics(ccx: &CrateCtxt, param_bounds.trait_bounds.push(Rc::new(trait_ref)); } - OtherRegionTyParamBound(span) => { - if !ccx.tcx.sess.features.issue_5723_bootstrap.get() { + OtherRegionTyParamBound(_span, _) => { + /*if !ccx.tcx.sess.features.issue_5723_bootstrap.get() { ccx.tcx.sess.span_err( span, "only the 'static lifetime is accepted here."); - } + }*/ } } } diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 03890250f7701..28aa1852a8d0b 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -113,18 +113,41 @@ impl<'f> Coerce<'f> { }); } - ty::ty_trait(box ty::TyTrait { def_id, ref substs, bounds }) => { + ty::ty_trait(box ty::TyTrait { + def_id, + ref substs, + bounds, + region + }) => { let result = self.unpack_actual_value(a, |sty_a| { match *sty_a { ty::ty_rptr(_, mt_a) => match ty::get(mt_a.ty).sty { ty::ty_trait(..) => { - self.coerce_borrowed_object(a, sty_a, b, mt_b.mutbl) + self.coerce_borrowed_object(a, + sty_a, + b, + mt_b.mutbl) + } + _ => { + let trait_store = + ty::RegionTraitStore(r_b, + mt_b.mutbl); + self.coerce_object(a, + sty_a, + b, + def_id, + substs, + trait_store, + bounds, + region) } - _ => self.coerce_object(a, sty_a, b, def_id, substs, - ty::RegionTraitStore(r_b, mt_b.mutbl), - bounds) }, - _ => self.coerce_borrowed_object(a, sty_a, b, mt_b.mutbl) + _ => { + self.coerce_borrowed_object(a, + sty_a, + b, + mt_b.mutbl) + } } }); @@ -144,15 +167,23 @@ impl<'f> Coerce<'f> { ty::ty_uniq(t_b) => { match ty::get(t_b).sty { - ty::ty_trait(box ty::TyTrait { def_id, ref substs, bounds }) => { + ty::ty_trait(box ty::TyTrait { def_id, ref substs, bounds, region }) => { let result = self.unpack_actual_value(a, |sty_a| { match *sty_a { ty::ty_uniq(t_a) => match ty::get(t_a).sty { ty::ty_trait(..) => { Err(ty::terr_mismatch) } - _ => self.coerce_object(a, sty_a, b, def_id, substs, - ty::UniqTraitStore, bounds) + _ => { + self.coerce_object(a, + sty_a, + b, + def_id, + substs, + ty::UniqTraitStore, + bounds, + region) + } }, _ => Err(ty::terr_mismatch) } @@ -320,8 +351,8 @@ impl<'f> Coerce<'f> { a: ty::t, sty_a: &ty::sty, b: ty::t, - b_mutbl: ast::Mutability) -> CoerceResult - { + b_mutbl: ast::Mutability) + -> CoerceResult { debug!("coerce_borrowed_object(a={}, sty_a={:?}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -336,9 +367,14 @@ impl<'f> Coerce<'f> { def_id, ref substs, bounds, + region, .. }) => { - let tr = ty::mk_trait(tcx, def_id, substs.clone(), bounds); + let tr = ty::mk_trait(tcx, + def_id, + substs.clone(), + bounds, + region); ty::mk_rptr(tcx, r_a, ty::mt{ mutbl: b_mutbl, ty: tr }) } _ => { @@ -446,13 +482,17 @@ impl<'f> Coerce<'f> { trait_def_id: ast::DefId, trait_substs: &subst::Substs, trait_store: ty::TraitStore, - bounds: ty::BuiltinBounds) -> CoerceResult { - + bounds: ty::BuiltinBounds, + region: ty::Region) + -> CoerceResult { debug!("coerce_object(a={}, sty_a={:?}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); - Ok(Some(ty::AutoObject(trait_store, bounds, - trait_def_id, trait_substs.clone()))) + Ok(Some(ty::AutoObject(trait_store, + bounds, + trait_def_id, + trait_substs.clone(), + region))) } } diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 1aae97d3d83e9..4689feb933ed0 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -480,10 +480,12 @@ pub fn super_tys(this: &C, a: ty::t, b: ty::t) -> cres { debug!("Trying to match traits {:?} and {:?}", a, b); let substs = if_ok!(this.substs(a_.def_id, &a_.substs, &b_.substs)); let bounds = if_ok!(this.bounds(a_.bounds, b_.bounds)); + let region = if_ok!(this.regions(a_.region, b_.region)); Ok(ty::mk_trait(tcx, a_.def_id, substs.clone(), - bounds)) + bounds, + region)) } (&ty::ty_struct(a_id, ref a_substs), &ty::ty_struct(b_id, ref b_substs)) diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 8be1700b635b4..b2303a93d72a9 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -910,7 +910,9 @@ impl<'a> Rebuilder<'a> { ty_param_bounds.map(|tpb| { match tpb { &ast::StaticRegionTyParamBound => ast::StaticRegionTyParamBound, - &ast::OtherRegionTyParamBound(s) => ast::OtherRegionTyParamBound(s), + &ast::OtherRegionTyParamBound(s, region) => { + ast::OtherRegionTyParamBound(s, region) + } &ast::UnboxedFnTyParamBound(unboxed_function_type) => { ast::UnboxedFnTyParamBound(unboxed_function_type) } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 30fffc42a3f97..66060a4ae3e85 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -694,7 +694,8 @@ impl<'a> InferCtxt<'a> { let dummy0 = ty::mk_trait(self.tcx, trait_ref.def_id, trait_ref.substs.clone(), - ty::empty_builtin_bounds()); + ty::empty_builtin_bounds(), + ty::ReStatic); let dummy1 = self.resolve_type_vars_if_possible(dummy0); match ty::get(dummy1).sty { ty::ty_trait(box ty::TyTrait { ref def_id, ref substs, .. }) => { diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 637af96b6321a..88153e79d4632 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -94,14 +94,16 @@ impl Emitter for ExpectErrorEmitter { } } -fn errors(msgs: &[&str]) -> (Box, uint) { +fn errors(msgs: &[&str]) -> (Box, uint) { let v = msgs.iter().map(|m| m.to_string()).collect(); - (box ExpectErrorEmitter { messages: v } as Box, msgs.len()) + (box ExpectErrorEmitter { + messages: v, + } as Box, msgs.len()) } fn test_env(_test_name: &str, source_string: &str, - (emitter, expected_err_count): (Box, uint), + (emitter, expected_err_count): (Box, uint), body: |Env|) { let options = config::basic_options(); diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index c3986d01d3da5..1aa325bce5bc3 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -401,7 +401,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { parameterized(cx, base.as_slice(), substs, &generics) } ty_trait(box ty::TyTrait { - def_id: did, ref substs, ref bounds + def_id: did, ref substs, ref bounds, ref region }) => { let base = ty::item_path_str(cx, did); let trait_def = ty::lookup_trait_def(cx, did); @@ -409,10 +409,12 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { substs, &trait_def.generics); let bound_sep = if bounds.is_empty() { "" } else { ":" }; let bound_str = bounds.repr(cx); - format!("{}{}{}", + let region_str = region_to_string(cx, "+", false, *region); + format!("{}{}{}{}", ty, bound_sep, - bound_str) + bound_str, + region_str) } ty_str => "str".to_string(), ty_unboxed_closure(..) => "closure".to_string(), diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 1ac0aee85d4d9..e2e6953a80887 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -192,7 +192,7 @@ impl AttrHelper for SpecialAttribute { } pub struct AttrBuilder { - attrs: Vec<(uint, Box)> + attrs: Vec<(uint, Box)> } impl AttrBuilder { @@ -202,13 +202,15 @@ impl AttrBuilder { } } - pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) -> &'a mut AttrBuilder { - self.attrs.push((idx, box a as Box)); + pub fn arg<'a, T: AttrHelper + 'static>(&'a mut self, idx: uint, a: T) + -> &'a mut AttrBuilder { + self.attrs.push((idx, box a as Box)); self } pub fn ret<'a, T: AttrHelper + 'static>(&'a mut self, a: T) -> &'a mut AttrBuilder { - self.attrs.push((ReturnIndex as uint, box a as Box)); + self.attrs.push((ReturnIndex as uint, + box a as Box)); self } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 002f887834747..fc5451bb5d85d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -489,7 +489,7 @@ impl Clean for ast::TyParamBound { fn clean(&self) -> TyParamBound { match *self { ast::StaticRegionTyParamBound => RegionBound, - ast::OtherRegionTyParamBound(_) => RegionBound, + ast::OtherRegionTyParamBound(_, _) => RegionBound, ast::UnboxedFnTyParamBound(_) => { // FIXME(pcwalton): Wrong. RegionBound diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index b7b5e09a5562a..d75119ec33b00 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -94,7 +94,7 @@ pub trait Runtime { fn can_block(&self) -> bool; // FIXME: This is a serious code smell and this should not exist at all. - fn wrap(self: Box) -> Box; + fn wrap(self: Box) -> Box; } /// The default error code of the rust runtime if the main task fails instead diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index b7366f440d034..efff1a301f0f8 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -92,7 +92,7 @@ impl LocalData for T {} // a proper map. #[doc(hidden)] pub type Map = Vec>; -type TLSValue = Box; +type TLSValue = Box; // Gets the map from the runtime. Lazily initialises if not done so already. unsafe fn get_local_map<'a>() -> Option<&'a mut Map> { @@ -176,7 +176,9 @@ impl KeyValue { // anything. let newval = data.map(|d| { let d = box d as Box; - let d: Box = unsafe { mem::transmute(d) }; + let d: Box = unsafe { + mem::transmute(d) + }; (keyval, d, 0) }); diff --git a/src/librustrt/rtio.rs b/src/librustrt/rtio.rs index 134453659dbf6..f122fe8192aa6 100644 --- a/src/librustrt/rtio.rs +++ b/src/librustrt/rtio.rs @@ -26,10 +26,10 @@ use task::Task; pub trait EventLoop { fn run(&mut self); fn callback(&mut self, arg: proc(): Send); - fn pausable_idle_callback(&mut self, Box) - -> Box; - fn remote_callback(&mut self, Box) - -> Box; + fn pausable_idle_callback(&mut self, Box) + -> Box; + fn remote_callback(&mut self, Box) + -> Box; /// The asynchronous I/O services. Not all event loops may provide one. fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory>; @@ -120,7 +120,7 @@ pub struct ProcessConfig<'a> { } pub struct LocalIo<'a> { - factory: &'a mut IoFactory, + factory: &'a mut IoFactory + 'static, } #[unsafe_destructor] @@ -174,39 +174,41 @@ impl<'a> LocalIo<'a> { } } - pub fn new<'a>(io: &'a mut IoFactory) -> LocalIo<'a> { + pub fn new<'a>(io: &'a mut IoFactory + 'static) -> LocalIo<'a> { LocalIo { factory: io } } /// Returns the underlying I/O factory as a trait reference. #[inline] - pub fn get<'a>(&'a mut self) -> &'a mut IoFactory { - let f: &'a mut IoFactory = self.factory; + pub fn get<'a>(&'a mut self) -> &'a mut IoFactory + 'static { + let f: &'a mut IoFactory + 'static = self.factory; f } } pub trait IoFactory { // networking - fn tcp_connect(&mut self, addr: SocketAddr, - timeout: Option) -> IoResult>; + fn tcp_connect(&mut self, addr: SocketAddr, timeout: Option) + -> IoResult>; fn tcp_bind(&mut self, addr: SocketAddr) - -> IoResult>; + -> IoResult>; fn udp_bind(&mut self, addr: SocketAddr) - -> IoResult>; + -> IoResult>; fn unix_bind(&mut self, path: &CString) - -> IoResult>; - fn unix_connect(&mut self, path: &CString, - timeout: Option) -> IoResult>; - fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>, + -> IoResult>; + fn unix_connect(&mut self, path: &CString, timeout: Option) + -> IoResult>; + fn get_host_addresses(&mut self, + host: Option<&str>, + servname: Option<&str>, hint: Option) -> IoResult>; // filesystem operations fn fs_from_raw_fd(&mut self, fd: c_int, close: CloseBehavior) - -> Box; + -> Box; fn fs_open(&mut self, path: &CString, fm: FileMode, fa: FileAccess) - -> IoResult>; + -> IoResult>; fn fs_unlink(&mut self, path: &CString) -> IoResult<()>; fn fs_stat(&mut self, path: &CString) -> IoResult; fn fs_mkdir(&mut self, path: &CString, mode: uint) -> IoResult<()>; @@ -225,24 +227,26 @@ pub trait IoFactory { IoResult<()>; // misc - fn timer_init(&mut self) -> IoResult>; + fn timer_init(&mut self) -> IoResult>; fn spawn(&mut self, cfg: ProcessConfig) - -> IoResult<(Box, - Vec>>)>; + -> IoResult<(Box, + Vec>>)>; fn kill(&mut self, pid: libc::pid_t, signal: int) -> IoResult<()>; - fn pipe_open(&mut self, fd: c_int) -> IoResult>; + fn pipe_open(&mut self, fd: c_int) + -> IoResult>; fn tty_open(&mut self, fd: c_int, readable: bool) - -> IoResult>; - fn signal(&mut self, signal: int, cb: Box) - -> IoResult>; + -> IoResult>; + fn signal(&mut self, signal: int, cb: Box) + -> IoResult>; } pub trait RtioTcpListener : RtioSocket { - fn listen(self: Box) -> IoResult>; + fn listen(self: Box) + -> IoResult>; } pub trait RtioTcpAcceptor : RtioSocket { - fn accept(&mut self) -> IoResult>; + fn accept(&mut self) -> IoResult>; fn accept_simultaneously(&mut self) -> IoResult<()>; fn dont_accept_simultaneously(&mut self) -> IoResult<()>; fn set_timeout(&mut self, timeout: Option); @@ -256,7 +260,7 @@ pub trait RtioTcpStream : RtioSocket { fn nodelay(&mut self) -> IoResult<()>; fn keepalive(&mut self, delay_in_seconds: uint) -> IoResult<()>; fn letdie(&mut self) -> IoResult<()>; - fn clone(&self) -> Box; + fn clone(&self) -> Box; fn close_write(&mut self) -> IoResult<()>; fn close_read(&mut self) -> IoResult<()>; fn set_timeout(&mut self, timeout_ms: Option); @@ -284,7 +288,7 @@ pub trait RtioUdpSocket : RtioSocket { fn hear_broadcasts(&mut self) -> IoResult<()>; fn ignore_broadcasts(&mut self) -> IoResult<()>; - fn clone(&self) -> Box; + fn clone(&self) -> Box; fn set_timeout(&mut self, timeout_ms: Option); fn set_read_timeout(&mut self, timeout_ms: Option); fn set_write_timeout(&mut self, timeout_ms: Option); @@ -292,8 +296,8 @@ pub trait RtioUdpSocket : RtioSocket { pub trait RtioTimer { fn sleep(&mut self, msecs: u64); - fn oneshot(&mut self, msecs: u64, cb: Box); - fn period(&mut self, msecs: u64, cb: Box); + fn oneshot(&mut self, msecs: u64, cb: Box); + fn period(&mut self, msecs: u64, cb: Box); } pub trait RtioFileStream { @@ -319,7 +323,7 @@ pub trait RtioProcess { pub trait RtioPipe { fn read(&mut self, buf: &mut [u8]) -> IoResult; fn write(&mut self, buf: &[u8]) -> IoResult<()>; - fn clone(&self) -> Box; + fn clone(&self) -> Box; fn close_write(&mut self) -> IoResult<()>; fn close_read(&mut self) -> IoResult<()>; @@ -329,11 +333,12 @@ pub trait RtioPipe { } pub trait RtioUnixListener { - fn listen(self: Box) -> IoResult>; + fn listen(self: Box) + -> IoResult>; } pub trait RtioUnixAcceptor { - fn accept(&mut self) -> IoResult>; + fn accept(&mut self) -> IoResult>; fn set_timeout(&mut self, timeout: Option); } diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index d27a4f25b4e70..2062650fdd849 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -103,7 +103,7 @@ pub struct Task { pub destroyed: bool, pub name: Option, - imp: Option>, + imp: Option>, } pub struct TaskOpts { @@ -121,7 +121,7 @@ pub struct TaskOpts { /// /// 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>; +pub type Result = ::core::result::Result<(), Box>; pub struct GarbageCollector; pub struct LocalStorage(pub Option); @@ -343,14 +343,14 @@ impl Task { /// 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) { + pub fn put_runtime(&mut self, ops: Box) { assert!(self.imp.is_none()); self.imp = Some(ops); } /// Removes the runtime from this task, transferring ownership to the /// caller. - pub fn take_runtime(&mut self) -> Box { + pub fn take_runtime(&mut self) -> Box { assert!(self.imp.is_some()); self.imp.take().unwrap() } @@ -380,7 +380,7 @@ impl Task { Ok(t) => Some(t), Err(t) => { let data = mem::transmute::<_, raw::TraitObject>(t).data; - let obj: Box = + let obj: Box = mem::transmute(raw::TraitObject { vtable: vtable, data: data, diff --git a/src/librustrt/unwind.rs b/src/librustrt/unwind.rs index 5dfeb15afb84a..98d9775839946 100644 --- a/src/librustrt/unwind.rs +++ b/src/librustrt/unwind.rs @@ -82,7 +82,7 @@ pub struct Unwinder { struct Exception { uwe: uw::_Unwind_Exception, - cause: Option>, + cause: Option>, } pub type Callback = fn(msg: &Any + Send, file: &'static str, line: uint); @@ -134,7 +134,8 @@ impl Unwinder { /// 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> { +pub unsafe fn try(f: ||) + -> ::core::result::Result<(), Box> { let closure: Closure = mem::transmute(f); let ep = rust_try(try_fn, closure.code as *mut c_void, closure.env as *mut c_void); @@ -173,7 +174,7 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box> { // An uninlined, unmangled function upon which to slap yer breakpoints #[inline(never)] #[no_mangle] -fn rust_fail(cause: Box) -> ! { +fn rust_fail(cause: Box) -> ! { rtdebug!("begin_unwind()"); unsafe { @@ -442,7 +443,9 @@ pub fn begin_unwind(msg: M, file: &'static str, line: uint) -> ! /// 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, file_line: &(&'static str, uint)) -> ! { +fn begin_unwind_inner(msg: Box, + file_line: &(&'static str, uint)) + -> ! { // First, invoke call the user-defined callbacks triggered on task failure. // // By the time that we see a callback has been registered (by reading diff --git a/src/librustuv/async.rs b/src/librustuv/async.rs index 97f95145b8992..7bca62cb4a2cf 100644 --- a/src/librustuv/async.rs +++ b/src/librustuv/async.rs @@ -27,12 +27,13 @@ pub struct AsyncWatcher { } struct Payload { - callback: Box, + callback: Box, exit_flag: Arc>, } impl AsyncWatcher { - pub fn new(loop_: &mut Loop, cb: Box) -> AsyncWatcher { + pub fn new(loop_: &mut Loop, cb: Box) + -> AsyncWatcher { let handle = UvHandle::alloc(None::, uvll::UV_ASYNC); assert_eq!(unsafe { uvll::uv_async_init(loop_.handle, handle, async_cb) diff --git a/src/librustuv/idle.rs b/src/librustuv/idle.rs index 7b9a2fcf44467..07442ae9c4360 100644 --- a/src/librustuv/idle.rs +++ b/src/librustuv/idle.rs @@ -18,11 +18,12 @@ use std::rt::rtio::{Callback, PausableIdleCallback}; pub struct IdleWatcher { handle: *mut uvll::uv_idle_t, idle_flag: bool, - callback: Box, + callback: Box, } impl IdleWatcher { - pub fn new(loop_: &mut Loop, cb: Box) -> Box { + pub fn new(loop_: &mut Loop, cb: Box) + -> Box { let handle = UvHandle::alloc(None::, uvll::UV_IDLE); assert_eq!(unsafe { uvll::uv_idle_init(loop_.handle, handle) diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 24b8c29785804..e59306b5cbc3c 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -129,8 +129,8 @@ pub mod stream; /// // this code is running inside of a green task powered by libuv /// } /// ``` -pub fn event_loop() -> Box { - box uvio::UvEventLoop::new() as Box +pub fn event_loop() -> Box { + box uvio::UvEventLoop::new() as Box } /// A type that wraps a uv handle diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index 3cc10ae3823ac..30bcef4766e8b 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -166,8 +166,10 @@ pub struct TcpWatcher { pub struct TcpListener { home: HomeHandle, handle: *mut uvll::uv_pipe_t, - outgoing: Sender, IoError>>, - incoming: Receiver, IoError>>, + outgoing: Sender, + IoError>>, + incoming: Receiver, + IoError>>, } pub struct TcpAcceptor { @@ -275,7 +277,7 @@ impl rtio::RtioTcpStream for TcpWatcher { }) } - fn clone(&self) -> Box { + fn clone(&self) -> Box { box TcpWatcher { handle: self.handle, stream: StreamWatcher::new(self.handle, false), @@ -283,7 +285,7 @@ impl rtio::RtioTcpStream for TcpWatcher { refcount: self.refcount.clone(), read_access: self.read_access.clone(), write_access: self.write_access.clone(), - } as Box + } as Box } fn close_read(&mut self) -> Result<(), IoError> { @@ -390,7 +392,7 @@ impl rtio::RtioSocket for TcpListener { impl rtio::RtioTcpListener for TcpListener { fn listen(self: Box) - -> Result, IoError> { + -> Result, IoError> { // create the acceptor object from ourselves let mut acceptor = box TcpAcceptor { listener: self, @@ -400,7 +402,7 @@ impl rtio::RtioTcpListener for TcpListener { 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), + 0 => Ok(acceptor as Box), n => Err(uv_error_to_io_error(UvError(n))), } } @@ -416,7 +418,7 @@ extern fn listen_cb(server: *mut uvll::uv_stream_t, status: c_int) { }); let client = TcpWatcher::new_home(&loop_, tcp.home().clone()); assert_eq!(unsafe { uvll::uv_accept(server, client.handle) }, 0); - Ok(box client as Box) + Ok(box client as Box) } n => Err(uv_error_to_io_error(UvError(n))) }; @@ -444,7 +446,8 @@ impl rtio::RtioSocket for TcpAcceptor { } impl rtio::RtioTcpAcceptor for TcpAcceptor { - fn accept(&mut self) -> Result, IoError> { + fn accept(&mut self) -> Result, + IoError> { self.timeout.accept(&self.listener.incoming) } @@ -743,7 +746,7 @@ impl rtio::RtioUdpSocket for UdpWatcher { }) } - fn clone(&self) -> Box { + fn clone(&self) -> Box { box UdpWatcher { handle: self.handle, home: self.home.clone(), @@ -751,7 +754,7 @@ impl rtio::RtioUdpSocket for UdpWatcher { write_access: self.write_access.clone(), read_access: self.read_access.clone(), blocked_sender: None, - } as Box + } as Box } fn set_timeout(&mut self, timeout: Option) { diff --git a/src/librustuv/pipe.rs b/src/librustuv/pipe.rs index f0a57546ed43e..5f488fa1ecb25 100644 --- a/src/librustuv/pipe.rs +++ b/src/librustuv/pipe.rs @@ -38,8 +38,8 @@ pub struct PipeWatcher { pub struct PipeListener { home: HomeHandle, pipe: *mut uvll::uv_pipe_t, - outgoing: Sender>>, - incoming: Receiver>>, + outgoing: Sender>>, + incoming: Receiver>>, } pub struct PipeAcceptor { @@ -129,7 +129,7 @@ impl rtio::RtioPipe for PipeWatcher { self.stream.write(buf, guard.can_timeout).map_err(uv_error_to_io_error) } - fn clone(&self) -> Box { + fn clone(&self) -> Box { box PipeWatcher { stream: StreamWatcher::new(self.stream.handle, false), defused: false, @@ -137,7 +137,7 @@ impl rtio::RtioPipe for PipeWatcher { refcount: self.refcount.clone(), read_access: self.read_access.clone(), write_access: self.write_access.clone(), - } as Box + } as Box } fn close_read(&mut self) -> IoResult<()> { @@ -249,7 +249,7 @@ impl PipeListener { impl rtio::RtioUnixListener for PipeListener { fn listen(self: Box) - -> IoResult> { + -> IoResult> { // create the acceptor object from ourselves let mut acceptor = box PipeAcceptor { listener: self, @@ -259,7 +259,7 @@ impl rtio::RtioUnixListener for PipeListener { 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), + 0 => Ok(acceptor as Box), n => Err(uv_error_to_io_error(UvError(n))), } } @@ -284,7 +284,7 @@ extern fn listen_cb(server: *mut uvll::uv_stream_t, status: libc::c_int) { }); 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) + Ok(box client as Box) } n => Err(uv_error_to_io_error(UvError(n))) }; @@ -301,7 +301,7 @@ impl Drop for PipeListener { // PipeAcceptor implementation and traits impl rtio::RtioUnixAcceptor for PipeAcceptor { - fn accept(&mut self) -> IoResult> { + fn accept(&mut self) -> IoResult> { self.timeout.accept(&self.listener.incoming) } diff --git a/src/librustuv/signal.rs b/src/librustuv/signal.rs index 49ef4e9a24bcc..b05419794b6c3 100644 --- a/src/librustuv/signal.rs +++ b/src/librustuv/signal.rs @@ -20,11 +20,13 @@ pub struct SignalWatcher { handle: *mut uvll::uv_signal_t, home: HomeHandle, - cb: Box, + cb: Box, } impl SignalWatcher { - pub fn new(io: &mut UvIoFactory, signum: int, cb: Box) + pub fn new(io: &mut UvIoFactory, + signum: int, + cb: Box) -> Result, UvError> { let s = box SignalWatcher { handle: UvHandle::alloc(None::, uvll::UV_SIGNAL), diff --git a/src/librustuv/timer.rs b/src/librustuv/timer.rs index f6c1cdd297754..ec6c6d0b4139b 100644 --- a/src/librustuv/timer.rs +++ b/src/librustuv/timer.rs @@ -27,8 +27,8 @@ pub struct TimerWatcher { pub enum NextAction { WakeTask, - CallOnce(Box), - CallMany(Box, uint), + CallOnce(Box), + CallMany(Box, uint), } impl TimerWatcher { @@ -103,7 +103,7 @@ impl RtioTimer for TimerWatcher { self.stop(); } - fn oneshot(&mut self, msecs: u64, cb: Box) { + fn oneshot(&mut self, msecs: u64, cb: Box) { // similarly to the destructor, we must drop the previous action outside // of the homing missile let _prev_action = { @@ -115,7 +115,7 @@ impl RtioTimer for TimerWatcher { }; } - fn period(&mut self, msecs: u64, cb: Box) { + fn period(&mut self, msecs: u64, cb: Box) { // similarly to the destructor, we must drop the previous action outside // of the homing missile let _prev_action = { diff --git a/src/librustuv/uvio.rs b/src/librustuv/uvio.rs index 61e52a3abd19c..edea0c5e10ca3 100644 --- a/src/librustuv/uvio.rs +++ b/src/librustuv/uvio.rs @@ -84,16 +84,17 @@ impl EventLoop for UvEventLoop { IdleWatcher::onetime(&mut self.uvio.loop_, f); } - fn pausable_idle_callback(&mut self, cb: Box) - -> Box { + fn pausable_idle_callback(&mut self, cb: Box) + -> + Box { IdleWatcher::new(&mut self.uvio.loop_, cb) - as Box + as Box } - fn remote_callback(&mut self, f: Box) - -> Box { + fn remote_callback(&mut self, f: Box) + -> Box { box AsyncWatcher::new(&mut self.uvio.loop_, f) as - Box + Box } fn io<'a>(&'a mut self) -> Option<&'a mut rtio::IoFactory> { @@ -141,31 +142,32 @@ impl IoFactory for UvIoFactory { // 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) - -> IoResult> { + -> IoResult> { match TcpWatcher::connect(self, addr, timeout) { - Ok(t) => Ok(box t as Box), + Ok(t) => Ok(box t as Box), Err(e) => Err(uv_error_to_io_error(e)), } } fn tcp_bind(&mut self, addr: rtio::SocketAddr) - -> IoResult> { + -> IoResult> { match TcpListener::bind(self, addr) { - Ok(t) => Ok(t as Box), + Ok(t) => Ok(t as Box), Err(e) => Err(uv_error_to_io_error(e)), } } fn udp_bind(&mut self, addr: rtio::SocketAddr) - -> IoResult> { + -> IoResult> { match UdpWatcher::bind(self, addr) { - Ok(u) => Ok(box u as Box), + Ok(u) => Ok(box u as Box), Err(e) => Err(uv_error_to_io_error(e)), } } - fn timer_init(&mut self) -> IoResult> { - Ok(TimerWatcher::new(self) as Box) + fn timer_init(&mut self) + -> IoResult> { + Ok(TimerWatcher::new(self) as Box) } fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>, @@ -177,14 +179,14 @@ impl IoFactory for UvIoFactory { } fn fs_from_raw_fd(&mut self, fd: c_int, close: rtio::CloseBehavior) - -> Box { + -> Box { box FileWatcher::new(self, fd, close) as - Box + Box } fn fs_open(&mut self, path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess) - -> IoResult> + -> IoResult> { let flags = match fm { rtio::Open => 0, @@ -201,7 +203,9 @@ impl IoFactory for UvIoFactory { }; match FsRequest::open(self, path, flags as int, mode as int) { - Ok(fs) => Ok(box fs as Box), + Ok(fs) => { + Ok(box fs as Box) + } Err(e) => Err(uv_error_to_io_error(e)) } } @@ -264,14 +268,13 @@ impl IoFactory for UvIoFactory { } fn spawn(&mut self, cfg: ProcessConfig) - -> IoResult<(Box, - Vec>>)> - { + -> IoResult<(Box, + Vec>>)> { match Process::spawn(self, cfg) { Ok((p, io)) => { - Ok((p as Box, + Ok((p as Box, io.move_iter().map(|i| i.map(|p| { - box p as Box + box p as Box })).collect())) } Err(e) => Err(uv_error_to_io_error(e)), @@ -283,43 +286,41 @@ impl IoFactory for UvIoFactory { } fn unix_bind(&mut self, path: &CString) - -> IoResult> { + -> IoResult> { match PipeListener::bind(self, path) { - Ok(p) => Ok(p as Box), + Ok(p) => Ok(p as Box), Err(e) => Err(uv_error_to_io_error(e)), } } fn unix_connect(&mut self, path: &CString, timeout: Option) - -> IoResult> { + -> IoResult> { match PipeWatcher::connect(self, path, timeout) { - Ok(p) => Ok(box p as Box), + Ok(p) => Ok(box p as Box), Err(e) => Err(uv_error_to_io_error(e)), } } fn tty_open(&mut self, fd: c_int, readable: bool) - -> IoResult> { + -> IoResult> { match TtyWatcher::new(self, fd, readable) { - Ok(tty) => Ok(box tty as Box), + Ok(tty) => Ok(box tty as Box), Err(e) => Err(uv_error_to_io_error(e)) } } fn pipe_open(&mut self, fd: c_int) - -> IoResult> - { + -> IoResult> { match PipeWatcher::open(self, fd) { - Ok(s) => Ok(box s as Box), + Ok(s) => Ok(box s as Box), Err(e) => Err(uv_error_to_io_error(e)) } } - fn signal(&mut self, signum: int, cb: Box) - -> IoResult> - { + fn signal(&mut self, signum: int, cb: Box) + -> IoResult> { match SignalWatcher::new(self, signum, cb) { - Ok(s) => Ok(s as Box), + Ok(s) => Ok(s as Box), Err(e) => Err(uv_error_to_io_error(e)), } } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index a56904c9ef4db..ae6bc4273205b 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -293,7 +293,8 @@ pub fn decode>(s: &str) -> DecodeResult } /// Shortcut function to encode a `T` into a JSON `String` -pub fn encode<'a, T: Encodable, io::IoError>>(object: &T) -> String { +pub fn encode<'a,'b,T: Encodable,io::IoError>>(object: &T) + -> String { let buff = Encoder::buffer_encode(object); String::from_utf8(buff).unwrap() } @@ -378,19 +379,20 @@ fn fmt_number_or_null(v: f64) -> String { } /// A structure for implementing serialization to JSON. -pub struct Encoder<'a> { - writer: &'a mut io::Writer, +pub struct Encoder<'a,'b> { + writer: &'a mut io::Writer+'b, } -impl<'a> Encoder<'a> { +impl<'a,'b> Encoder<'a,'b> { /// Creates a new JSON encoder whose output will be written to the writer /// specified. - pub fn new(writer: &'a mut io::Writer) -> Encoder<'a> { + pub fn new(writer: &'a mut io::Writer+'b) -> Encoder<'a,'b> { Encoder { writer: writer } } /// Encode the specified struct into a json [u8] - pub fn buffer_encode, io::IoError>>(object: &T) -> Vec { + pub fn buffer_encode,io::IoError>>(object: &T) + -> Vec { //Serialize the object in a string using a writer let mut m = MemWriter::new(); // FIXME(14302) remove the transmute and unsafe block. @@ -406,12 +408,13 @@ impl<'a> Encoder<'a> { /// /// Note: this function is deprecated. Consider using `json::encode` instead. #[deprecated = "Replaced by `json::encode`"] - pub fn str_encode, io::IoError>>(object: &T) -> String { + pub fn str_encode,io::IoError>>(object: &T) + -> String { encode(object) } } -impl<'a> ::Encoder for Encoder<'a> { +impl<'a,'b> ::Encoder for Encoder<'a,'b> { fn emit_nil(&mut self) -> EncodeResult { write!(self.writer, "null") } fn emit_uint(&mut self, v: uint) -> EncodeResult { self.emit_f64(v as f64) } @@ -446,7 +449,10 @@ impl<'a> ::Encoder for Encoder<'a> { escape_str(self.writer, v) } - fn emit_enum(&mut self, _name: &str, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_enum(&mut self, + _name: &str, + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { f(self) } @@ -454,7 +460,8 @@ impl<'a> ::Encoder for Encoder<'a> { name: &str, _id: uint, cnt: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { // enums are encoded as strings or objects // Bunny => "Bunny" // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]} @@ -471,7 +478,8 @@ impl<'a> ::Encoder for Encoder<'a> { fn emit_enum_variant_arg(&mut self, idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { if idx != 0 { try!(write!(self.writer, ",")); } @@ -482,21 +490,24 @@ impl<'a> ::Encoder for Encoder<'a> { name: &str, id: uint, cnt: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { self.emit_enum_variant(name, id, cnt, f) } fn emit_enum_struct_variant_field(&mut self, _: &str, idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { self.emit_enum_variant_arg(idx, f) } fn emit_struct(&mut self, _: &str, _: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { try!(write!(self.writer, "{{")); try!(f(self)); write!(self.writer, "}}") @@ -505,56 +516,70 @@ impl<'a> ::Encoder for Encoder<'a> { fn emit_struct_field(&mut self, name: &str, idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { if idx != 0 { try!(write!(self.writer, ",")); } try!(escape_str(self.writer, name)); try!(write!(self.writer, ":")); f(self) } - fn emit_tuple(&mut self, len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_tuple(&mut self, + len: uint, + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { self.emit_seq(len, f) } fn emit_tuple_arg(&mut self, idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { self.emit_seq_elt(idx, f) } fn emit_tuple_struct(&mut self, _name: &str, len: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { self.emit_seq(len, f) } fn emit_tuple_struct_arg(&mut self, idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { self.emit_seq_elt(idx, f) } - fn emit_option(&mut self, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_option(&mut self, f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { f(self) } fn emit_option_none(&mut self) -> EncodeResult { self.emit_nil() } - fn emit_option_some(&mut self, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_option_some(&mut self, f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { f(self) } - fn emit_seq(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_seq(&mut self, _: uint, f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { try!(write!(self.writer, "[")); try!(f(self)); write!(self.writer, "]") } - fn emit_seq_elt(&mut self, idx: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_seq_elt(&mut self, + idx: uint, + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { if idx != 0 { try!(write!(self.writer, ",")); } f(self) } - fn emit_map(&mut self, _len: uint, f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_map(&mut self, _: uint, f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { try!(write!(self.writer, "{{")); try!(f(self)); write!(self.writer, "}}") @@ -562,7 +587,8 @@ impl<'a> ::Encoder for Encoder<'a> { fn emit_map_elt_key(&mut self, idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { if idx != 0 { try!(write!(self.writer, ",")) } // ref #12967, make sure to wrap a key in double quotes, // in the event that its of a type that omits them (eg numbers) @@ -582,7 +608,8 @@ impl<'a> ::Encoder for Encoder<'a> { fn emit_map_elt_val(&mut self, _idx: uint, - f: |&mut Encoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut Encoder<'a,'b>| -> EncodeResult) + -> EncodeResult { try!(write!(self.writer, ":")); f(self) } @@ -590,19 +617,19 @@ impl<'a> ::Encoder for Encoder<'a> { /// Another encoder for JSON, but prints out human-readable JSON instead of /// compact data -pub struct PrettyEncoder<'a> { - writer: &'a mut io::Writer, +pub struct PrettyEncoder<'a,'b> { + writer: &'a mut io::Writer+'b, indent: uint, } -impl<'a> PrettyEncoder<'a> { +impl<'a,'b> PrettyEncoder<'a,'b> { /// Creates a new encoder whose output will be written to the specified writer - pub fn new<'a>(writer: &'a mut io::Writer) -> PrettyEncoder<'a> { + pub fn new<'a,'b>(writer: &'a mut io::Writer+'b) -> PrettyEncoder<'a,'b> { PrettyEncoder { writer: writer, indent: 0 } } } -impl<'a> ::Encoder for PrettyEncoder<'a> { +impl<'a,'b> ::Encoder for PrettyEncoder<'a,'b> { fn emit_nil(&mut self) -> EncodeResult { write!(self.writer, "null") } fn emit_uint(&mut self, v: uint) -> EncodeResult { self.emit_f64(v as f64) } @@ -641,7 +668,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_enum(&mut self, _name: &str, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { f(self) } @@ -649,7 +676,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { name: &str, _: uint, cnt: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if cnt == 0 { escape_str(self.writer, name) } else { @@ -668,7 +695,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_enum_variant_arg(&mut self, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if idx != 0 { try!(write!(self.writer, ",\n")); } @@ -680,14 +707,14 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { name: &str, id: uint, cnt: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { self.emit_enum_variant(name, id, cnt, f) } fn emit_enum_struct_variant_field(&mut self, _: &str, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { self.emit_enum_variant_arg(idx, f) } @@ -695,7 +722,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_struct(&mut self, _: &str, len: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if len == 0 { write!(self.writer, "{{}}") } else { @@ -712,7 +739,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_struct_field(&mut self, name: &str, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if idx == 0 { try!(write!(self.writer, "\n")); } else { @@ -726,38 +753,38 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_tuple(&mut self, len: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { self.emit_seq(len, f) } fn emit_tuple_arg(&mut self, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { self.emit_seq_elt(idx, f) } fn emit_tuple_struct(&mut self, _: &str, len: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { self.emit_seq(len, f) } fn emit_tuple_struct_arg(&mut self, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { self.emit_seq_elt(idx, f) } - fn emit_option(&mut self, f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_option(&mut self, f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { f(self) } fn emit_option_none(&mut self) -> EncodeResult { self.emit_nil() } - fn emit_option_some(&mut self, f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + fn emit_option_some(&mut self, f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { f(self) } fn emit_seq(&mut self, len: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if len == 0 { write!(self.writer, "[]") } else { @@ -773,7 +800,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_seq_elt(&mut self, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if idx == 0 { try!(write!(self.writer, "\n")); } else { @@ -785,7 +812,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_map(&mut self, len: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if len == 0 { write!(self.writer, "{{}}") } else { @@ -801,7 +828,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_map_elt_key(&mut self, idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { if idx == 0 { try!(write!(self.writer, "\n")); } else { @@ -826,7 +853,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { fn emit_map_elt_val(&mut self, _idx: uint, - f: |&mut PrettyEncoder<'a>| -> EncodeResult) -> EncodeResult { + f: |&mut PrettyEncoder<'a,'b>| -> EncodeResult) -> EncodeResult { try!(write!(self.writer, ": ")); f(self) } diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 5cb272a19eb88..fc2113ee90e6c 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -24,6 +24,7 @@ Core encoding and decoding interfaces. html_root_url = "http://doc.rust-lang.org/master/", html_playground_url = "http://play.rust-lang.org/")] #![feature(macro_rules, managed_boxes, default_type_params, phase)] +#![feature(issue_5723_bootstrap)] // test harness access #[cfg(test)] diff --git a/src/libstd/failure.rs b/src/libstd/failure.rs index 8c709d20d1904..9321e47ed09ed 100644 --- a/src/libstd/failure.rs +++ b/src/libstd/failure.rs @@ -25,7 +25,7 @@ use str::Str; use string::String; // Defined in this module instead of io::stdio so that the unwinding -local_data_key!(pub local_stderr: Box) +local_data_key!(pub local_stderr: Box) impl Writer for Stdio { fn write(&mut self, bytes: &[u8]) -> IoResult<()> { diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index 2182c43d4a0c2..28d32fc0dfe49 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -466,7 +466,7 @@ pub fn format(args: &Arguments) -> string::String{ string::String::from_utf8(output.unwrap()).unwrap() } -impl<'a> Writer for Formatter<'a> { +impl<'a,'b> Writer for Formatter<'a,'b> { fn write(&mut self, b: &[u8]) -> io::IoResult<()> { match (*self).write(b) { Ok(()) => Ok(()), diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 790fe6cb8b93a..7b9379c7ff127 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -86,7 +86,7 @@ use vec::Vec; /// configured at creation time, via the `FileAccess` parameter to /// `File::open_mode()`. pub struct File { - fd: Box, + fd: Box, path: Path, last_nread: int, } @@ -130,9 +130,8 @@ impl File { /// * Attempting to open a file with a `FileAccess` that the user lacks /// permissions for /// * Filesystem-level errors (full disk, etc) - pub fn open_mode(path: &Path, - mode: FileMode, - access: FileAccess) -> IoResult { + pub fn open_mode(path: &Path, mode: FileMode, access: FileAccess) + -> IoResult { let rtio_mode = match mode { Open => rtio::Open, Append => rtio::Append, diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 4277b509962cc..538656ccf2a71 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -944,11 +944,11 @@ pub trait Reader { } } -impl Reader for Box { +impl<'a> Reader for Box { fn read(&mut self, buf: &mut [u8]) -> IoResult { self.read(buf) } } -impl<'a> Reader for &'a mut Reader { +impl<'a,'b> Reader for &'a mut Reader + 'b { fn read(&mut self, buf: &mut [u8]) -> IoResult { self.read(buf) } } @@ -1277,7 +1277,7 @@ pub trait Writer { } } -impl Writer for Box { +impl<'a> Writer for Box { #[inline] fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) } @@ -1285,7 +1285,7 @@ impl Writer for Box { fn flush(&mut self) -> IoResult<()> { self.flush() } } -impl<'a> Writer for &'a mut Writer { +impl<'a,'b> Writer for &'a mut Writer + 'b { #[inline] fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) } diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index cb754135bc152..954b53a9df775 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -52,11 +52,11 @@ use rt::rtio; /// drop(stream); // close the connection /// ``` pub struct TcpStream { - obj: Box, + obj: Box, } impl TcpStream { - fn new(s: Box) -> TcpStream { + fn new(s: Box) -> TcpStream { TcpStream { obj: s } } @@ -327,7 +327,7 @@ impl Writer for TcpStream { /// # } /// ``` pub struct TcpListener { - obj: Box, + obj: Box, } impl TcpListener { @@ -383,7 +383,7 @@ impl Listener for TcpListener { /// a `TcpListener`'s `listen` method, and this object can be used to accept new /// `TcpStream` instances. pub struct TcpAcceptor { - obj: Box, + obj: Box, } impl TcpAcceptor { diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 5f7563e7467ba..0bd87bf76489c 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -57,7 +57,7 @@ use rt::rtio; /// drop(socket); // close the socket /// ``` pub struct UdpSocket { - obj: Box, + obj: Box, } impl UdpSocket { diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index 5e7c421497772..02c340b1397c9 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -36,7 +36,7 @@ use rt::rtio::{RtioUnixAcceptor, RtioPipe}; /// A stream which communicates over a named pipe. pub struct UnixStream { - obj: Box, + obj: Box, } impl UnixStream { @@ -144,7 +144,7 @@ impl Writer for UnixStream { /// A value that can listen for incoming named pipe connection requests. pub struct UnixListener { /// The internal, opaque runtime Unix listener. - obj: Box, + obj: Box, } impl UnixListener { @@ -188,7 +188,7 @@ impl Listener for UnixListener { /// A value that can accept named pipe connections, returned from `listen()`. pub struct UnixAcceptor { /// The internal, opaque runtime Unix acceptor. - obj: Box, + obj: Box, } impl UnixAcceptor { diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index c476a99fee9dc..d396147fe02d4 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -26,7 +26,7 @@ use rt::rtio::{RtioPipe, LocalIo}; /// A synchronous, in-memory pipe. pub struct PipeStream { /// The internal, opaque runtime pipe object. - obj: Box, + obj: Box, } pub struct PipePair { @@ -62,7 +62,7 @@ impl PipeStream { } #[doc(hidden)] - pub fn new(inner: Box) -> PipeStream { + pub fn new(inner: Box) -> PipeStream { PipeStream { obj: inner } } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 1eee69834948f..40dd002b7855a 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -59,7 +59,7 @@ use collections::HashMap; /// assert!(child.wait().unwrap().success()); /// ``` pub struct Process { - handle: Box, + handle: Box, forget: bool, /// Handle to the child's stdin, if the `stdin` field of this process's diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index c126866e7159a..5c3a0491c9f19 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -83,7 +83,7 @@ pub enum Signum { /// ``` pub struct Listener { /// A map from signums to handles to keep the handles in memory - handles: Vec<(Signum, Box)>, + handles: Vec<(Signum, Box)>, /// This is where all the handles send signums, which are received by /// the clients from the receiver. tx: Sender, diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 45c084b345961..dfe1a54c00ba9 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -74,8 +74,8 @@ use uint; // 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), - File(Box), + TTY(Box), + File(Box), } fn src(fd: libc::c_int, readable: bool, f: |StdSource| -> T) -> T { @@ -87,7 +87,7 @@ fn src(fd: libc::c_int, readable: bool, f: |StdSource| -> T) -> T { }).map_err(IoError::from_rtio_error).unwrap() } -local_data_key!(local_stdout: Box) +local_data_key!(local_stdout: Box) /// Creates a new non-blocking handle to the stdin of the current process. /// @@ -166,7 +166,8 @@ pub fn stderr_raw() -> StdWriter { /// /// 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) -> Option> { +pub fn set_stdout(stdout: Box) + -> Option> { local_stdout.replace(Some(stdout)).and_then(|mut s| { let _ = s.flush(); Some(s) @@ -181,7 +182,8 @@ pub fn set_stdout(stdout: Box) -> Option> { /// /// 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) -> Option> { +pub fn set_stderr(stderr: Box) + -> Option> { local_stderr.replace(Some(stderr)).and_then(|mut s| { let _ = s.flush(); Some(s) @@ -201,7 +203,7 @@ pub fn set_stderr(stderr: Box) -> Option> { fn with_task_stdout(f: |&mut Writer| -> IoResult<()>) { let result = if Local::exists(None::) { let mut my_stdout = local_stdout.replace(None).unwrap_or_else(|| { - box stdout() as Box + box stdout() as Box }); let result = f(my_stdout); local_stdout.replace(Some(my_stdout)); diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 1c9e428dcad82..ca7d7ba81c224 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -64,7 +64,7 @@ use rt::rtio::{IoFactory, LocalIo, RtioTimer, Callback}; /// # } /// ``` pub struct Timer { - obj: Box, + obj: Box, } struct TimerCallback { tx: Sender<()> } diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index e928323030c4f..61eec95367d1a 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -119,12 +119,12 @@ impl Buffer for NullReader { /// A `Writer` which multiplexes writes to a set of `Writers`. pub struct MultiWriter { - writers: Vec> + writers: Vec> } impl MultiWriter { /// Creates a new `MultiWriter` - pub fn new(writers: Vec>) -> MultiWriter { + pub fn new(writers: Vec>) -> MultiWriter { MultiWriter { writers: writers } } } @@ -338,8 +338,9 @@ mod test { } } - let mut multi = MultiWriter::new(vec!(box TestWriter as Box, - box TestWriter as Box)); + let mut multi = MultiWriter::new( + vec!(box TestWriter as Box, + box TestWriter as Box)); multi.write([1, 2, 3]).unwrap(); assert_eq!(2, unsafe { writes }); assert_eq!(0, unsafe { flushes }); diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 125c3fdf5d90c..6b2550e796025 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -107,6 +107,7 @@ #![feature(macro_rules, globs, managed_boxes, linkage)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)] +#![feature(issue_5723_bootstrap)] // Don't link to std. We are std. #![no_std] diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index d075f9a1205c7..8caae11056d22 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -289,9 +289,9 @@ mod imp { pub fn write(w: &mut Writer) -> IoResult<()> { use io::IoError; - struct Context<'a> { + struct Context<'a,'b> { idx: int, - writer: &'a mut Writer, + writer: &'a mut Writer + 'b, last_error: Option, } diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 19ad81a04834d..9e505c4fad640 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -145,9 +145,9 @@ pub struct TaskBuilder { // The size of the stack for the spawned task stack_size: Option, // Task-local stdout - stdout: Option>, + stdout: Option>, // Task-local stderr - stderr: Option>, + stderr: Option>, // The mechanics of actually spawning the task (i.e.: green or native) spawner: S, // Optionally wrap the eventual task body @@ -188,14 +188,16 @@ impl TaskBuilder { /// Redirect task-local stdout. #[experimental = "May not want to make stdio overridable here."] - pub fn stdout(mut self, stdout: Box) -> TaskBuilder { + pub fn stdout(mut self, stdout: Box) + -> TaskBuilder { self.stdout = Some(stdout); self } /// Redirect task-local stderr. #[experimental = "May not want to make stdio overridable here."] - pub fn stderr(mut self, stderr: Box) -> TaskBuilder { + pub fn stderr(mut self, stderr: Box) + -> TaskBuilder { self.stderr = Some(stderr); self } @@ -246,8 +248,10 @@ impl TaskBuilder { } // Where spawning actually happens (whether yielding a future or not) - fn spawn_internal(self, f: proc():Send, - on_exit: Option>):Send>) { + fn spawn_internal(self, + f: proc():Send, + on_exit: + Option>):Send>) { let TaskBuilder { name, stack_size, stdout, stderr, spawner, mut gen_body, nocopy: _ } = self; @@ -295,7 +299,7 @@ impl TaskBuilder { /// containing the argument to `fail!(...)` as an `Any` trait object. #[experimental = "Futures are experimental."] pub fn try_future(self, f: proc():Send -> T) - -> Future>> { + -> Future>> { // currently, the on_exit proc provided by librustrt only works for unit // results, so we use an additional side-channel to communicate the // result. @@ -315,7 +319,8 @@ impl TaskBuilder { /// Execute a function in a newly-spawnedtask and block until the task /// completes or fails. Equivalent to `.try_future(f).unwrap()`. #[unstable = "Error type may change."] - pub fn try(self, f: proc():Send -> T) -> Result> { + pub fn try(self, f: proc():Send -> T) + -> Result> { self.try_future(f).unwrap() } } @@ -337,7 +342,8 @@ pub fn spawn(f: proc(): Send) { /// /// This is equivalent to `TaskBuilder::new().try`. #[unstable = "Error type may change."] -pub fn try(f: proc(): Send -> T) -> Result> { +pub fn try(f: proc(): Send -> T) + -> Result> { TaskBuilder::new().try(f) } @@ -346,7 +352,8 @@ pub fn try(f: proc(): Send -> T) -> Result> { /// /// This is equivalent to `TaskBuilder::new().try_future`. #[experimental = "Futures are experimental."] -pub fn try_future(f: proc():Send -> T) -> Future>> { +pub fn try_future(f: proc():Send -> T) + -> Future>> { TaskBuilder::new().try_future(f) } @@ -616,10 +623,10 @@ mod test { #[test] fn test_try_fail_message_any() { match try(proc() { - fail!(box 413u16 as Box); + fail!(box 413u16 as Box); }) { Err(e) => { - type T = Box; + type T = Box; assert!(e.is::()); let any = e.downcast::().unwrap(); assert!(any.is::()); @@ -647,7 +654,8 @@ mod test { let mut reader = ChanReader::new(rx); let stdout = ChanWriter::new(tx); - let r = TaskBuilder::new().stdout(box stdout as Box) + let r = TaskBuilder::new().stdout(box stdout as Box) .try(proc() { print!("Hello, world!"); }); diff --git a/src/libsync/comm/select.rs b/src/libsync/comm/select.rs index 737a4bfe29916..c60a1997db794 100644 --- a/src/libsync/comm/select.rs +++ b/src/libsync/comm/select.rs @@ -84,7 +84,7 @@ pub struct Handle<'rx, T> { next: *mut Handle<'static, ()>, prev: *mut Handle<'static, ()>, added: bool, - packet: &'rx Packet, + packet: &'rx Packet+'rx, // due to our fun transmutes, we be sure to place this at the end. (nothing // previous relies on T) diff --git a/src/libsync/lib.rs b/src/libsync/lib.rs index f6a1684b66940..e2e1bb240629f 100644 --- a/src/libsync/lib.rs +++ b/src/libsync/lib.rs @@ -28,6 +28,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![feature(phase, globs, macro_rules, unsafe_destructor)] +#![feature(issue_5723_bootstrap)] #![deny(missing_doc)] #![no_std] diff --git a/src/libsync/raw.rs b/src/libsync/raw.rs index e7a2d3e063996..63a32d84edf5f 100644 --- a/src/libsync/raw.rs +++ b/src/libsync/raw.rs @@ -839,10 +839,11 @@ mod tests { let m = Arc::new(Mutex::new()); let m2 = m.clone(); - let result: result::Result<(), Box> = task::try(proc() { - let _lock = m2.lock(); - fail!(); - }); + let result: result::Result<(), Box> = + task::try(proc() { + let _lock = m2.lock(); + fail!(); + }); assert!(result.is_err()); // child task must have finished by the time try returns drop(m.lock()); @@ -1079,7 +1080,8 @@ mod tests { let x = Arc::new(RWLock::new()); let x2 = x.clone(); - let result: result::Result<(), Box> = task::try(proc() { + let result: result::Result<(), + Box> = task::try(proc() { lock_rwlock_in_mode(&x2, mode1, || { fail!(); }) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index f05d17569f68d..57f12707b15f4 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -213,7 +213,7 @@ pub enum TyParamBound { TraitTyParamBound(TraitRef), StaticRegionTyParamBound, UnboxedFnTyParamBound(UnboxedFnTy), - OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands + OtherRegionTyParamBound(Span, Lifetime), } #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 0b26a641f8d50..93125617ee84b 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -127,7 +127,7 @@ impl SpanHandler { /// others log errors for later reporting. pub struct Handler { err_count: Cell, - emit: RefCell>, + emit: RefCell>, } impl Handler { @@ -204,7 +204,7 @@ pub fn default_handler(color_config: ColorConfig, mk_handler(box EmitterWriter::stderr(color_config, registry)) } -pub fn mk_handler(e: Box) -> Handler { +pub fn mk_handler(e: Box) -> Handler { Handler { err_count: Cell::new(0), emit: RefCell::new(e), @@ -317,8 +317,8 @@ pub struct EmitterWriter { } enum Destination { - Terminal(Box + Send>), - Raw(Box), + Terminal(Box + Send + 'static>), + Raw(Box), } impl EmitterWriter { @@ -343,7 +343,7 @@ impl EmitterWriter { } } - pub fn new(dst: Box, + pub fn new(dst: Box, registry: Option) -> EmitterWriter { EmitterWriter { dst: Raw(dst), registry: registry } } diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 209296989fa0d..2f37f9da38b56 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -45,8 +45,10 @@ fn with_used_diagnostics(f: |&mut HashMap| -> T) -> T { } } -pub fn expand_diagnostic_used(ecx: &mut ExtCtxt, span: Span, - token_tree: &[TokenTree]) -> Box { +pub fn expand_diagnostic_used(ecx: &mut ExtCtxt, + span: Span, + token_tree: &[TokenTree]) + -> Box { let code = match token_tree { [ast::TTTok(_, token::IDENT(code, _))] => code, _ => unreachable!() @@ -75,8 +77,10 @@ pub fn expand_diagnostic_used(ecx: &mut ExtCtxt, span: Span, MacExpr::new(quote_expr!(ecx, ())) } -pub fn expand_register_diagnostic(ecx: &mut ExtCtxt, span: Span, - token_tree: &[TokenTree]) -> Box { +pub fn expand_register_diagnostic(ecx: &mut ExtCtxt, + span: Span, + token_tree: &[TokenTree]) + -> Box { let (code, description) = match token_tree { [ast::TTTok(_, token::IDENT(ref code, _))] => { (code, None) @@ -101,8 +105,10 @@ pub fn expand_register_diagnostic(ecx: &mut ExtCtxt, span: Span, MacItem::new(quote_item!(ecx, mod $sym {}).unwrap()) } -pub fn expand_build_diagnostic_array(ecx: &mut ExtCtxt, span: Span, - token_tree: &[TokenTree]) -> Box { +pub fn expand_build_diagnostic_array(ecx: &mut ExtCtxt, + span: Span, + token_tree: &[TokenTree]) + -> Box { let name = match token_tree { [ast::TTTok(_, token::IDENT(ref name, _))] => name, _ => unreachable!() diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 13738e658e9f9..271dcd56c21a9 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -46,7 +46,7 @@ impl State { static OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"]; pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let mut p = cx.new_parser_from_tts(tts); let mut asm = InternedString::new(""); let mut asm_str_style = None; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a66d6839ab074..569d1d9460f36 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -56,19 +56,19 @@ pub trait TTMacroExpander { ecx: &mut ExtCtxt, span: Span, token_tree: &[ast::TokenTree]) - -> Box; + -> Box; } pub type MacroExpanderFn = fn(ecx: &mut ExtCtxt, span: codemap::Span, token_tree: &[ast::TokenTree]) - -> Box; + -> Box; impl TTMacroExpander for BasicMacroExpander { fn expand(&self, ecx: &mut ExtCtxt, span: Span, token_tree: &[ast::TokenTree]) - -> Box { + -> Box { (self.expander)(ecx, span, token_tree) } } @@ -84,7 +84,7 @@ pub trait IdentMacroExpander { sp: Span, ident: ast::Ident, token_tree: Vec ) - -> Box; + -> Box; } impl IdentMacroExpander for BasicIdentMacroExpander { @@ -93,13 +93,14 @@ impl IdentMacroExpander for BasicIdentMacroExpander { sp: Span, ident: ast::Ident, token_tree: Vec ) - -> Box { + -> Box { (self.expander)(cx, sp, ident, token_tree) } } pub type IdentMacroExpanderFn = - fn(&mut ExtCtxt, Span, ast::Ident, Vec) -> Box; + fn(&mut ExtCtxt, Span, ast::Ident, Vec) + -> Box; /// The result of a macro expansion. The return values of the various /// methods are spliced into the AST at the callsite of the macro (or @@ -146,8 +147,8 @@ pub struct MacExpr { e: Gc, } impl MacExpr { - pub fn new(e: Gc) -> Box { - box MacExpr { e: e } as Box + pub fn new(e: Gc) -> Box { + box MacExpr { e: e } as Box } } impl MacResult for MacExpr { @@ -160,8 +161,8 @@ pub struct MacPat { p: Gc, } impl MacPat { - pub fn new(p: Gc) -> Box { - box MacPat { p: p } as Box + pub fn new(p: Gc) -> Box { + box MacPat { p: p } as Box } } impl MacResult for MacPat { @@ -174,8 +175,8 @@ pub struct MacItem { i: Gc } impl MacItem { - pub fn new(i: Gc) -> Box { - box MacItem { i: i } as Box + pub fn new(i: Gc) -> Box { + box MacItem { i: i } as Box } } impl MacResult for MacItem { @@ -203,8 +204,8 @@ impl DummyResult { /// /// Use this as a return value after hitting any errors and /// calling `span_err`. - pub fn any(sp: Span) -> Box { - box DummyResult { expr_only: false, span: sp } as Box + pub fn any(sp: Span) -> Box { + box DummyResult { expr_only: false, span: sp } as Box } /// Create a default MacResult that can only be an expression. @@ -212,8 +213,8 @@ impl DummyResult { /// Use this for macros that must expand to an expression, so even /// if an error is encountered internally, the user will receive /// an error that they also used it in the wrong place. - pub fn expr(sp: Span) -> Box { - box DummyResult { expr_only: true, span: sp } as Box + pub fn expr(sp: Span) -> Box { + box DummyResult { expr_only: true, span: sp } as Box } /// A plain dummy expression. diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index ce13fa2a7c6ee..cf4c166f7d5b4 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -18,7 +18,7 @@ use ext::build::AstBuilder; pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { cx.span_warn(sp, "`bytes!` is deprecated, use `b\"foo\"` literals instead"); cx.parse_sess.span_diagnostic.span_note(sp, "see http://doc.rust-lang.org/rust.html#byte-and-byte-string-literals \ diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index c2930662bc459..8f4b565702d31 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -27,7 +27,7 @@ use parse::token; pub fn expand_cfg(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let mut p = cx.new_parser_from_tts(tts); let mut cfgs = Vec::new(); // parse `cfg!(meta_item, meta_item(x,y), meta_item="foo", ...)` diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index 670e38327d6c4..6a49c7de7274c 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -19,7 +19,7 @@ use std::string::String; pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let es = match base::get_exprs_from_tts(cx, sp, tts) { Some(e) => e, None => return base::DummyResult::expr(sp) diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 7cf901bbd5e1c..030fd7e562b53 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -19,7 +19,7 @@ use parse::token::{str_to_ident}; use std::gc::GC; pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let mut res_str = String::new(); for (i, e) in tts.iter().enumerate() { if i & 1 == 1 { diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index b24cfb85794ed..ff536fc283f2f 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -24,7 +24,7 @@ use parse::token; use std::os; pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") { None => return DummyResult::expr(sp), Some(v) => v @@ -60,7 +60,7 @@ pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } pub fn expand_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let exprs = match get_exprs_from_tts(cx, sp, tts) { Some(ref exprs) if exprs.len() == 0 => { cx.span_err(sp, "env! takes 1 or 2 arguments"); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 4185458bfbe61..5352cfaf749b0 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -19,7 +19,7 @@ use ext::build::AstBuilder; pub fn expand_syntax_ext(ecx: &mut base::ExtCtxt, sp: Span, _tts: &[ast::TokenTree]) - -> Box { + -> Box { ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead"); ecx.parse_sess.span_diagnostic.span_note(sp, "see http://doc.rust-lang.org/std/fmt/ \ diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index b00924c159016..5890d49d98df2 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -669,7 +669,7 @@ impl<'a, 'b> Context<'a, 'b> { } pub fn expand_format_args(ecx: &mut ExtCtxt, sp: Span, - tts: &[ast::TokenTree]) -> Box { + tts: &[ast::TokenTree]) -> Box { match parse_args(ecx, sp, false, tts) { (invocation, Some((efmt, args, order, names))) => { @@ -681,7 +681,7 @@ pub fn expand_format_args(ecx: &mut ExtCtxt, sp: Span, } pub fn expand_format_args_method(ecx: &mut ExtCtxt, sp: Span, - tts: &[ast::TokenTree]) -> Box { + tts: &[ast::TokenTree]) -> Box { match parse_args(ecx, sp, true, tts) { (invocation, Some((efmt, args, order, names))) => { diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 1f4d087abd0fe..34631fbf5e2fe 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -18,7 +18,7 @@ use std::rc::Rc; pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, sp: codemap::Span, tt: &[ast::TokenTree]) - -> Box { + -> Box { cx.print_backtrace(); println!("{}", print::pprust::tt_to_string(&ast::TTDelim( diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index a7ede6f742d9f..5f30639de182e 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -315,7 +315,7 @@ pub mod rt { pub fn expand_quote_tokens(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let (cx_expr, expr) = expand_tts(cx, sp, tts); let expanded = expand_wrapper(cx, sp, cx_expr, expr); base::MacExpr::new(expanded) @@ -323,7 +323,7 @@ pub fn expand_quote_tokens(cx: &mut ExtCtxt, pub fn expand_quote_expr(cx: &mut ExtCtxt, sp: Span, - tts: &[ast::TokenTree]) -> Box { + tts: &[ast::TokenTree]) -> Box { let expanded = expand_parse_call(cx, sp, "parse_expr", Vec::new(), tts); base::MacExpr::new(expanded) } @@ -331,7 +331,7 @@ pub fn expand_quote_expr(cx: &mut ExtCtxt, pub fn expand_quote_item(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let expanded = expand_parse_call(cx, sp, "parse_item_with_outer_attributes", vec!(), tts); base::MacExpr::new(expanded) @@ -340,7 +340,7 @@ pub fn expand_quote_item(cx: &mut ExtCtxt, pub fn expand_quote_pat(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let expanded = expand_parse_call(cx, sp, "parse_pat", vec!(), tts); base::MacExpr::new(expanded) } @@ -348,7 +348,7 @@ pub fn expand_quote_pat(cx: &mut ExtCtxt, pub fn expand_quote_ty(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let e_param_colons = cx.expr_lit(sp, ast::LitBool(false)); let expanded = expand_parse_call(cx, sp, "parse_ty", vec!(e_param_colons), tts); @@ -358,7 +358,7 @@ pub fn expand_quote_ty(cx: &mut ExtCtxt, pub fn expand_quote_method(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let e_param_colons = cx.expr_none(sp); let expanded = expand_parse_call(cx, sp, "parse_method", vec!(e_param_colons), tts); @@ -368,7 +368,7 @@ pub fn expand_quote_method(cx: &mut ExtCtxt, pub fn expand_quote_stmt(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let e_attrs = cx.expr_vec_ng(sp); let expanded = expand_parse_call(cx, sp, "parse_stmt", vec!(e_attrs), tts); diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 703adcbd33552..5cc0ec4a12290 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -29,7 +29,7 @@ use std::rc::Rc; /// line!(): expands to the current line number pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { base::check_zero_tts(cx, sp, tts, "line!"); let topmost = topmost_expn_info(cx.backtrace().unwrap()); @@ -40,7 +40,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) /* col!(): expands to the current column number */ pub fn expand_col(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { base::check_zero_tts(cx, sp, tts, "col!"); let topmost = topmost_expn_info(cx.backtrace().unwrap()); @@ -52,7 +52,7 @@ pub fn expand_col(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) /// The filemap (`loc.file`) contains a bunch more information we could spit /// out if we wanted. pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { base::check_zero_tts(cx, sp, tts, "file!"); let topmost = topmost_expn_info(cx.backtrace().unwrap()); @@ -62,14 +62,14 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let s = pprust::tts_to_string(tts); base::MacExpr::new(cx.expr_str(sp, token::intern_and_get_ident(s.as_slice()))) } pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { base::check_zero_tts(cx, sp, tts, "module_path!"); let string = cx.mod_path() .iter() @@ -85,7 +85,7 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) /// This is generally a bad idea because it's going to behave /// unhygienically. pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let file = match get_single_str_from_tts(cx, sp, tts, "include!") { Some(f) => f, None => return DummyResult::expr(sp), @@ -105,7 +105,7 @@ pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) // include_str! : read the given file, insert it as a literal string expr pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") { Some(f) => f, None => return DummyResult::expr(sp) @@ -141,7 +141,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) } pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) - -> Box { + -> Box { let file = match get_single_str_from_tts(cx, sp, tts, "include_bin!") { Some(f) => f, None => return DummyResult::expr(sp) diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index 773246326648a..1f50eb933bb4e 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -18,7 +18,7 @@ use parse::token::{keywords, is_keyword}; pub fn expand_trace_macros(cx: &mut ExtCtxt, sp: Span, tt: &[ast::TokenTree]) - -> Box { + -> Box { match tt { [ast::TTTok(_, ref tok)] if is_keyword(keywords::True, tok) => { cx.set_trace_macros(true); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 1eb37abb781a3..1fddd69cbb1d8 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -28,6 +28,7 @@ use print; use util::small_vector::SmallVector; use std::cell::RefCell; +use std::mem; use std::rc::Rc; use std::gc::Gc; @@ -117,7 +118,7 @@ impl TTMacroExpander for MacroRulesMacroExpander { cx: &mut ExtCtxt, sp: Span, arg: &[ast::TokenTree]) - -> Box { + -> Box { generic_extension(cx, sp, self.name, @@ -143,7 +144,7 @@ fn generic_extension(cx: &ExtCtxt, arg: &[ast::TokenTree], lhses: &[Rc], rhses: &[Rc]) - -> Box { + -> Box { if cx.trace_macros() { println!("{}! {} {} {}", token::get_ident(name), @@ -193,9 +194,17 @@ fn generic_extension(cx: &ExtCtxt, let p = Parser::new(cx.parse_sess(), cx.cfg(), box trncbr); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. - return box ParserAnyMacro { - parser: RefCell::new(p), - } as Box + unsafe { + // FIXME(pcwalton): This is totally bogus with the + // lifetimes. I have no idea how this even worked to begin + // with. + let result = box ParserAnyMacro { + parser: RefCell::new(p), + } as Box; + let result: Box = + mem::transmute(result); + return result + } } Failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo { best_fail_spot = sp; @@ -216,8 +225,8 @@ fn generic_extension(cx: &ExtCtxt, pub fn add_new_extension(cx: &mut ExtCtxt, sp: Span, name: Ident, - arg: Vec ) - -> Box { + arg: Vec) + -> Box { // these spans won't matter, anyways fn ms(m: Matcher_) -> Matcher { Spanned { @@ -274,5 +283,5 @@ pub fn add_new_extension(cx: &mut ExtCtxt, name: token::get_ident(name).to_string(), ext: NormalTT(exp, Some(sp)) })) - } as Box + } as Box } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index f48306bc6ee2f..7942e41eb0009 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -509,7 +509,9 @@ fn fold_ty_param_bound(tpb: &TyParamBound, fld: &mut T) decl: fld.fold_fn_decl(&*unboxed_function_type.decl), }) } - OtherRegionTyParamBound(s) => OtherRegionTyParamBound(s) + OtherRegionTyParamBound(s, ref lifetime) => { + OtherRegionTyParamBound(s, fld.fold_lifetime(lifetime)) + } } } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 13d2a632f3638..1c00f2c70865c 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -24,7 +24,7 @@ html_root_url = "http://doc.rust-lang.org/master/")] #![feature(macro_rules, globs, managed_boxes, default_type_params, phase)] -#![feature(quote, struct_variant, unsafe_destructor)] +#![feature(quote, struct_variant, unsafe_destructor, issue_5723_bootstrap)] #![allow(deprecated)] extern crate fmt_macros; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index a3e169cd5116d..a7f512673c104 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -263,7 +263,8 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess, tts: Vec, cfg: ast::CrateConfig) -> Parser<'a> { let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, tts); - Parser::new(sess, cfg, box trdr) + let trdr: Box = box trdr; + Parser::new(sess, cfg, trdr) } /// Abort if necessary diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 878994369d0d4..ea2ff709734da 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -304,7 +304,7 @@ pub struct Parser<'a> { pub tokens_consumed: uint, pub restriction: restriction, pub quote_depth: uint, // not (yet) related to the quasiquoter - pub reader: Box, + pub reader: Box, pub interner: Rc, /// The set of seen errors about obsolete syntax. Used to suppress /// extra detail when the same error is seen twice @@ -341,8 +341,10 @@ fn real_token(rdr: &mut Reader) -> TokenAndSpan { } impl<'a> Parser<'a> { - pub fn new(sess: &'a ParseSess, cfg: ast::CrateConfig, - mut rdr: Box) -> Parser<'a> { + pub fn new(sess: &'a ParseSess, + cfg: ast::CrateConfig, + mut rdr: Box) + -> Parser<'a> { let tok0 = real_token(rdr); let span = tok0.sp; let placeholder = TokenAndSpan { @@ -3569,7 +3571,13 @@ impl<'a> Parser<'a> { name: lifetime.name }); } else { - result.push(OtherRegionTyParamBound(self.span)); + result.push(OtherRegionTyParamBound( + self.span, + ast::Lifetime { + id: ast::DUMMY_NODE_ID, + span: self.span, + name: lifetime.name + })); } self.bump(); } diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index fe84eeff4f87f..a28bf981c8c09 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -155,7 +155,7 @@ pub struct PrintStackElem { static SIZE_INFINITY: int = 0xffff; -pub fn mk_printer(out: Box, linewidth: uint) -> Printer { +pub fn mk_printer(out: Box, linewidth: uint) -> Printer { // Yes 3, it makes the ring buffers big enough to never // fall behind. let n: uint = 3 * linewidth; @@ -260,7 +260,7 @@ pub fn mk_printer(out: Box, linewidth: uint) -> Printer { /// the method called 'pretty_print', and the 'PRINT' process is the method /// called 'print'. pub struct Printer { - pub out: Box, + pub out: Box, buf_len: uint, /// Width of lines we're constrained to margin: int, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ac8355651916e..ec161dc5cfbe7 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -52,23 +52,27 @@ pub struct CurrentCommentAndLiteral { cur_lit: uint, } -pub struct State<'a> { +pub struct State<'a,'b> { pub s: pp::Printer, cm: Option<&'a CodeMap>, comments: Option >, literals: Option >, cur_cmnt_and_lit: CurrentCommentAndLiteral, boxes: Vec, - ann: &'a PpAnn + ann: &'a PpAnn+'b } -pub fn rust_printer(writer: Box) -> State<'static> { +pub fn rust_printer(writer: Box) + -> State<'static,'static> { static NO_ANN: NoAnn = NoAnn; rust_printer_annotated(writer, &NO_ANN) } -pub fn rust_printer_annotated<'a>(writer: Box, - ann: &'a PpAnn) -> State<'a> { +pub fn rust_printer_annotated<'a, + 'b>( + writer: Box, + ann: &'a PpAnn+'b) + -> State<'a,'b> { State { s: pp::mk_printer(writer, default_columns), cm: None, @@ -90,14 +94,17 @@ pub static default_columns: uint = 78u; /// Requires you to pass an input filename and reader so that /// it can scan the input text for comments and literals to /// copy forward. -pub fn print_crate<'a>(cm: &'a CodeMap, - span_diagnostic: &diagnostic::SpanHandler, - krate: &ast::Crate, - filename: String, - input: &mut io::Reader, - out: Box, - ann: &'a PpAnn, - is_expanded: bool) -> IoResult<()> { +pub fn print_crate<'a, + 'b>( + cm: &'a CodeMap, + span_diagnostic: &diagnostic::SpanHandler, + krate: &ast::Crate, + filename: String, + input: &mut io::Reader, + out: Box, + ann: &'a PpAnn+'b, + is_expanded: bool) + -> IoResult<()> { let (cmnts, lits) = comments::gather_comments_and_literals( span_diagnostic, filename, @@ -265,7 +272,7 @@ fn needs_parentheses(expr: &ast::Expr) -> bool { } } -impl<'a> State<'a> { +impl<'a,'b> State<'a,'b> { pub fn ibox(&mut self, u: uint) -> IoResult<()> { self.boxes.push(pp::Inconsistent); pp::ibox(&mut self.s, u) @@ -2067,7 +2074,9 @@ impl<'a> State<'a> { None, true) } - OtherRegionTyParamBound(_) => Ok(()) + OtherRegionTyParamBound(_, ref lifetime) => { + self.print_lifetime(lifetime) + } }) } Ok(()) diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 371fae53b41d0..fdd2e134e9502 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -531,7 +531,9 @@ pub fn walk_ty_param_bounds>(visitor: &mut V, visitor.visit_ty(&*function_declaration.decl.output, env.clone()); } - OtherRegionTyParamBound(..) => {} + OtherRegionTyParamBound(_, ref lifetime) => { + visitor.visit_lifetime_ref(lifetime, env.clone()) + } } } } diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 3fc631422d5f3..45bd6d6198453 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -66,10 +66,10 @@ pub mod terminfo; #[cfg(windows)] mod win; -/// A hack to work around the fact that `Box` does not -/// currently implement `Writer`. +/// A hack to work around the fact that `Box` does +/// not currently implement `Writer`. pub struct WriterWrapper { - wrapped: Box, + wrapped: Box, } impl Writer for WriterWrapper { @@ -87,31 +87,31 @@ impl Writer for WriterWrapper { #[cfg(not(windows))] /// Return a Terminal wrapping stdout, or None if a terminal couldn't be /// opened. -pub fn stdout() -> Option + Send>> { +pub fn stdout() -> Option + Send + 'static>> { let ti: Option> = Terminal::new(WriterWrapper { - wrapped: box std::io::stdout() as Box, + wrapped: box std::io::stdout() as Box, }); - ti.map(|t| box t as Box + Send>) + ti.map(|t| box t as Box + Send + 'static>) } #[cfg(windows)] /// Return a Terminal wrapping stdout, or None if a terminal couldn't be /// opened. -pub fn stdout() -> Option + Send>> { +pub fn stdout() -> Option + Send + 'static>> { let ti: Option> = Terminal::new(WriterWrapper { - wrapped: box std::io::stdout() as Box, + wrapped: box std::io::stdout() as Box, }); match ti { - Some(t) => Some(box t as Box + Send>), + Some(t) => Some(box t as Box+Send+'static>), None => { let wc: Option> = Terminal::new(WriterWrapper { - wrapped: box std::io::stdout() as Box, + wrapped: box std::io::stdout() as Box, }); - wc.map(|w| box w as Box + Send>) + wc.map(|w| box w as Box+Send+'static>) } } } @@ -119,31 +119,34 @@ pub fn stdout() -> Option + Send>> { #[cfg(not(windows))] /// Return a Terminal wrapping stderr, or None if a terminal couldn't be /// opened. -pub fn stderr() -> Option + Send> + Send> { +pub fn stderr() -> Option+Send+'static>+ + Send+'static> { let ti: Option> = Terminal::new(WriterWrapper { - wrapped: box std::io::stderr() as Box, + wrapped: box std::io::stderr() as Box, }); - ti.map(|t| box t as Box + Send>) + ti.map(|t| box t as Box+Send+'static>) } #[cfg(windows)] /// Return a Terminal wrapping stderr, or None if a terminal couldn't be /// opened. -pub fn stderr() -> Option + Send> + Send> { +pub fn stderr() -> Option+Send+'static> + +Send+'static> { let ti: Option> = Terminal::new(WriterWrapper { - wrapped: box std::io::stderr() as Box, + wrapped: box std::io::stderr() as Box, }); match ti { - Some(t) => Some(box t as Box + Send>), + Some(t) => Some(box t as Box+Send+'static>), None => { let wc: Option> = Terminal::new(WriterWrapper { - wrapped: box std::io::stderr() as Box, + wrapped: box std::io::stderr() as + Box, }); - wc.map(|w| box w as Box + Send>) + wc.map(|w| box w as Box + Send + 'static>) } } } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 46e2ca03ef6ed..1c0470fe32d62 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -138,7 +138,7 @@ pub enum TestFn { StaticMetricFn(proc(&mut MetricMap)), DynTestFn(proc():Send), DynMetricFn(proc(&mut MetricMap)), - DynBenchFn(Box) + DynBenchFn(Box) } impl TestFn { @@ -473,7 +473,7 @@ pub enum TestResult { } enum OutputLocation { - Pretty(Box + Send>), + Pretty(Box + Send + 'static>), Raw(T), } @@ -1048,8 +1048,8 @@ pub fn run_test(opts: &TestOpts, if nocapture { drop((stdout, stderr)); } else { - task = task.stdout(box stdout as Box); - task = task.stderr(box stderr as Box); + task = task.stdout(box stdout as Box); + task = task.stderr(box stderr as Box); } let result_future = task.try_future(testfn); diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index c617c1b2d03b4..1cba738c56406 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -14,8 +14,8 @@ pub trait i { } -pub fn f() -> Box> { +pub fn f() -> Box+'static> { impl i for () { } - box() () as Box> + box() () as Box+'static> } diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 4936bff5768c9..89cd599fe9c28 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -37,7 +37,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box { + -> Box { if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } diff --git a/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs b/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs index 1592ffb6c6790..7f724eae0fd80 100644 --- a/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs +++ b/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs @@ -27,7 +27,7 @@ impl Drop for Foo { #[plugin_registrar] pub fn registrar(_: &mut Registry) { - local_data_key!(foo: Box); - foo.replace(Some(box Foo { foo: 10 } as Box)); + local_data_key!(foo: Box); + foo.replace(Some(box Foo { foo: 10 } as Box)); } diff --git a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs index 04318fcae2733..2884cb9490ba7 100644 --- a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs +++ b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs @@ -29,7 +29,7 @@ pub fn plugin_registrar(reg: &mut Registry) { } fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box { + -> Box { let answer = other::the_answer(); MacExpr::new(quote_expr!(cx, $answer)) } diff --git a/src/test/compile-fail/regions-bound-lists-feature-gate.rs b/src/test/compile-fail/borrowck-object-lifetime-2.rs similarity index 64% rename from src/test/compile-fail/regions-bound-lists-feature-gate.rs rename to src/test/compile-fail/borrowck-object-lifetime-2.rs index de3b2faef861f..91867ca48e5bb 100644 --- a/src/test/compile-fail/regions-bound-lists-feature-gate.rs +++ b/src/test/compile-fail/borrowck-object-lifetime-2.rs @@ -8,13 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +trait Foo { + fn borrowed(&self) -> &(); +} -trait Foo { } - -fn foo<'a>(x: Box) { //~ ERROR only the 'static lifetime is accepted here +fn mut_owned_receiver(mut x: Box) { + let _y = x.borrowed(); + let _z = &mut x; //~ ERROR cannot borrow } -fn bar<'a, T:'a>() { //~ ERROR only the 'static lifetime is accepted here +fn imm_owned_receiver(mut x: Box) { + let _y = x.borrowed(); + let _z = &x; } -fn main() { } +fn main() {} + diff --git a/src/test/compile-fail/borrowck-object-lifetime.rs b/src/test/compile-fail/borrowck-object-lifetime.rs index c55a5a30538d8..f9375275ed2ec 100644 --- a/src/test/compile-fail/borrowck-object-lifetime.rs +++ b/src/test/compile-fail/borrowck-object-lifetime.rs @@ -18,17 +18,7 @@ fn borrowed_receiver(x: &Foo) -> &() { } fn owned_receiver(x: Box) -> &'static () { - x.borrowed() //~ ERROR `*x` does not live long enough -} - -fn mut_owned_receiver(mut x: Box) { - let _y = x.borrowed(); - let _z = &mut x; //~ ERROR cannot borrow -} - -fn imm_owned_receiver(mut x: Box) { - let _y = x.borrowed(); - let _z = &x; + x.borrowed() //~ ERROR cannot infer an appropriate lifetime } fn main() {} diff --git a/src/test/compile-fail/issue-14285.rs b/src/test/compile-fail/issue-14285.rs index d5e608ecae303..624ddf0c8bbdc 100644 --- a/src/test/compile-fail/issue-14285.rs +++ b/src/test/compile-fail/issue-14285.rs @@ -14,7 +14,7 @@ struct A; impl Foo for A {} -struct B<'a>(&'a Foo); +struct B<'a>(&'a Foo+'a); fn foo<'a>(a: &Foo) -> B<'a> { B(a) //~ ERROR cannot infer an appropriate lifetime diff --git a/src/test/compile-fail/issue-4972.rs b/src/test/compile-fail/issue-4972.rs index d684d1b376b8f..dec3063217773 100644 --- a/src/test/compile-fail/issue-4972.rs +++ b/src/test/compile-fail/issue-4972.rs @@ -12,10 +12,10 @@ trait MyTrait { } pub enum TraitWrapper { - A(Box), + A(Box), } -fn get_tw_map(tw: &TraitWrapper) -> &MyTrait { +fn get_tw_map(tw: &TraitWrapper) -> &MyTrait+'static { match *tw { A(box ref map) => map, //~ ERROR cannot be dereferenced } diff --git a/src/test/compile-fail/issue-5153.rs b/src/test/compile-fail/issue-5153.rs index 57a158d2438dd..0087513b0da49 100644 --- a/src/test/compile-fail/issue-5153.rs +++ b/src/test/compile-fail/issue-5153.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: type `&Foo` does not implement any method in scope named `foo` +// error-pattern: does not implement any method in scope named `foo` trait Foo { fn foo(self: Box); @@ -19,5 +19,5 @@ impl Foo for int { } fn main() { - (&5 as &Foo).foo(); + (&5 as &Foo+'static).foo(); } diff --git a/src/test/compile-fail/issue-7013.rs b/src/test/compile-fail/issue-7013.rs index ea332c1e25233..565069e51be85 100644 --- a/src/test/compile-fail/issue-7013.rs +++ b/src/test/compile-fail/issue-7013.rs @@ -27,11 +27,11 @@ impl Foo for B { } struct A { - v: Box, + v: Box, } fn main() { - let a = A {v: box B{v: None} as Box}; + let a = A {v: box B{v: None} as Box}; //~^ ERROR cannot pack type `Box`, which does not fulfill `Send` let v = Rc::new(RefCell::new(a)); let w = v.clone(); diff --git a/src/test/compile-fail/isuue-12470.rs b/src/test/compile-fail/isuue-12470.rs index bf13b7ebbdbbe..4b7a8e4ed2c02 100644 --- a/src/test/compile-fail/isuue-12470.rs +++ b/src/test/compile-fail/isuue-12470.rs @@ -24,10 +24,10 @@ impl X for B { } struct A<'a> { - p: &'a X + p: &'a X+'a } -fn make_a<'a>(p: &'a X) -> A<'a> { +fn make_a<'a>(p: &'a X+'a) -> A<'a> { A { p: p } } diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 50704a1afbf4e..00b1ec07058d8 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -15,8 +15,9 @@ impl Repeat for A { fn get(&self) -> A { self.clone() } } -fn repeater(v: A) -> Box> { - box v as Box> // No +fn repeater(v: A) -> Box+'static> { + box v as Box+'static> + //~^ ERROR does not fulfill `'static` } fn main() { diff --git a/src/test/compile-fail/owned-ptr-static-bound.rs b/src/test/compile-fail/owned-ptr-static-bound.rs index dc6e8b1d6be5f..708c3a0643d7c 100644 --- a/src/test/compile-fail/owned-ptr-static-bound.rs +++ b/src/test/compile-fail/owned-ptr-static-bound.rs @@ -8,23 +8,28 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-test +// +// See failure below. trait A {} -struct B<'a, T>(&'a A); +struct B<'a, T>(&'a A+'a); trait X {} impl<'a, T> X for B<'a, T> {} -fn f<'a, T, U>(v: Box>) -> Box { - box B(v) as Box //~ ERROR value may contain references; add `'static` bound to `T` +fn f<'a, T, U>(v: Box+'static>) -> Box { + box B(v) as Box //~ ERROR `*v` does not live long enough + //~^ ERROR does not fulfill `'static` } -fn g<'a, T, U>(v: Box>) -> Box { - box B(v) as Box //~ ERROR value may contain references; add `'static` bound to `U` +fn g<'a, T, U>(v: Box+'static>) -> Box { + box B(v) as Box //~ ERROR `*v` does not live long enough + //~^ ERROR does not fulfill `'static` } -fn h<'a, T: 'static>(v: Box>) -> Box { - box B(v) as Box // ok +fn h(v: &'static A+'static) -> Box { + box B(v) as Box // should be ok but fails now (FIXME) } fn main() {} diff --git a/src/test/compile-fail/regions-trait-variance.rs b/src/test/compile-fail/regions-trait-variance.rs index 53cfd4e032497..e74180645bfa6 100644 --- a/src/test/compile-fail/regions-trait-variance.rs +++ b/src/test/compile-fail/regions-trait-variance.rs @@ -31,11 +31,13 @@ impl Drop for B { } struct A<'r> { - p: &'r X + p: &'r X+'r } -fn make_a(p:&X) -> A { - A{p:p} +fn make_a<'r>(p:&'r X+'r) -> A<'r> { + A{ + p: p, + } } fn make_make_a<'a>() -> A<'a> { diff --git a/src/test/compile-fail/selftype-traittype.rs b/src/test/compile-fail/selftype-traittype.rs index 3bf547e3affc3..bf7c3b261fd7d 100644 --- a/src/test/compile-fail/selftype-traittype.rs +++ b/src/test/compile-fail/selftype-traittype.rs @@ -13,7 +13,7 @@ trait add { fn plus(&self, x: Self) -> Self; } -fn do_add(x: Box, y: Box) -> Box { +fn do_add(x: Box, y: Box) -> Box { x.plus(y) //~ ERROR cannot call a method whose type contains a self-type through an object } diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs index 043f3a233a625..f6e00ea7d48f0 100644 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs @@ -23,10 +23,11 @@ impl fmt::Show for Number { } struct List { - list: Vec> } + list: Vec>, +} impl List { - fn push(&mut self, n: Box) { + fn push(&mut self, n: Box) { self.list.push(n); } } diff --git a/src/test/compile-fail/variance-trait-matching-2.rs b/src/test/compile-fail/variance-trait-matching-2.rs index f549c78be9d0d..6cbb06422dc17 100644 --- a/src/test/compile-fail/variance-trait-matching-2.rs +++ b/src/test/compile-fail/variance-trait-matching-2.rs @@ -15,7 +15,9 @@ use std::io; use serialize::{Encodable, Encoder}; pub fn buffer_encode<'a, - T:Encodable,io::IoError>>( + 'b, + T:Encodable, + io::IoError>>( to_encode_object: &T) -> Vec { let mut m = MemWriter::new(); diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index dec53672d87f2..6e67b3f6add66 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -29,11 +29,11 @@ impl Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box> { +fn f(a: A, b: u16) -> Box+'static> { box Invoker { a: a, b: b, - } as (Box>) + } as (Box+'static>) } pub fn main() { diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs index 33ee2ffd3592c..1c55a99722b26 100644 --- a/src/test/run-pass/capturing-logging.rs +++ b/src/test/run-pass/capturing-logging.rs @@ -41,7 +41,7 @@ fn main() { let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); spawn(proc() { - set_logger(box MyWriter(w) as Box); + set_logger(box MyWriter(w) as Box); debug!("debug"); info!("info"); }); diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index b5c42c453a793..d4876fea1215f 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -33,11 +33,11 @@ impl Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box> { +fn f(a: A, b: u16) -> Box + 'static> { box Invoker { a: a, b: b, - } as (Box>) + } as (Box + 'static>) } pub fn main() { diff --git a/src/test/run-pass/colorful-write-macros.rs b/src/test/run-pass/colorful-write-macros.rs index 724e57bdef23d..60b6d8f8be064 100644 --- a/src/test/run-pass/colorful-write-macros.rs +++ b/src/test/run-pass/colorful-write-macros.rs @@ -18,7 +18,7 @@ use std::fmt; use std::fmt::FormatWriter; struct Foo<'a> { - writer: &'a mut Writer, + writer: &'a mut Writer+'a, other: &'a str, } diff --git a/src/test/run-pass/issue-10802.rs b/src/test/run-pass/issue-10802.rs index 4fda506ae64b6..c315cd8e494f4 100644 --- a/src/test/run-pass/issue-10802.rs +++ b/src/test/run-pass/issue-10802.rs @@ -30,9 +30,9 @@ trait MyTrait { } impl MyTrait for Box {} impl MyTrait for Box {} -struct Whatever { w: Box } +struct Whatever { w: Box } impl Whatever { - fn new(w: Box) -> Whatever { + fn new(w: Box) -> Whatever { Whatever { w: w } } } @@ -40,13 +40,13 @@ impl Whatever { fn main() { { let f = box DroppableStruct; - let _a = Whatever::new(box f as Box); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); unsafe { DROPPED = false; } { let f = box DroppableVariant1; - let _a = Whatever::new(box f as Box); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); } diff --git a/src/test/run-pass/issue-11205.rs b/src/test/run-pass/issue-11205.rs index 5b52bc34d2b3d..1fcb1c5f5280d 100644 --- a/src/test/run-pass/issue-11205.rs +++ b/src/test/run-pass/issue-11205.rs @@ -49,7 +49,7 @@ fn main() { foog(x, &[box 1i]); struct T<'a> { - t: [&'a Foo, ..2] + t: [&'a Foo+'a, ..2] } let _n = T { t: [&1i, &2i] @@ -64,7 +64,7 @@ fn main() { }; struct F<'b> { - t: &'b [&'b Foo] + t: &'b [&'b Foo+'b] } let _n = F { t: &[&1i, &2i] @@ -80,7 +80,7 @@ fn main() { }; struct M<'a> { - t: &'a [Box] + t: &'a [Box] } let _n = M { t: &[box 1i, box 2i] diff --git a/src/test/run-pass/issue-11677.rs b/src/test/run-pass/issue-11677.rs index 5a244250852ae..ebc850760ec4a 100644 --- a/src/test/run-pass/issue-11677.rs +++ b/src/test/run-pass/issue-11677.rs @@ -14,7 +14,7 @@ trait X {} -struct S {f: Box>, g: Box>} +struct S {f: Box+'static>, g: Box+'static>} struct F; impl X for F {} diff --git a/src/test/run-pass/issue-11881.rs b/src/test/run-pass/issue-11881.rs index e0cd91adb1c59..aceb082e12750 100644 --- a/src/test/run-pass/issue-11881.rs +++ b/src/test/run-pass/issue-11881.rs @@ -32,7 +32,8 @@ enum WireProtocol { } fn encode_json<'a, - T: Encodable, + 'b, + T: Encodable, std::io::IoError>>(val: &T, wr: &'a mut MemWriter) { let mut encoder = json::Encoder::new(wr); diff --git a/src/test/run-pass/issue-14958.rs b/src/test/run-pass/issue-14958.rs index b53c2258736ff..9f999712249d4 100644 --- a/src/test/run-pass/issue-14958.rs +++ b/src/test/run-pass/issue-14958.rs @@ -14,8 +14,8 @@ trait Foo {} struct Bar; -impl<'a> std::ops::Fn<(&'a Foo,), ()> for Bar { - extern "rust-call" fn call(&self, _: (&'a Foo,)) {} +impl<'a> std::ops::Fn<(&'a Foo+'a,), ()> for Bar { + extern "rust-call" fn call(&self, _: (&'a Foo+'a,)) {} } struct Baz; diff --git a/src/test/run-pass/issue-14959.rs b/src/test/run-pass/issue-14959.rs index af0bc78094e5f..74b9df9b88d87 100644 --- a/src/test/run-pass/issue-14959.rs +++ b/src/test/run-pass/issue-14959.rs @@ -33,8 +33,8 @@ impl Alloy { } } -impl<'a, 'b> Fn<(&'b mut Response,),()> for SendFile<'a> { - extern "rust-call" fn call(&self, (_res,): (&'b mut Response,)) {} +impl<'a, 'b> Fn<(&'b mut Response+'b,),()> for SendFile<'a> { + extern "rust-call" fn call(&self, (_res,): (&'b mut Response+'b,)) {} } impl Ingot for HelloWorld { diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 11ebf014bc65e..9eec2d048d473 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -12,8 +12,8 @@ trait hax { } impl hax for A { } -fn perform_hax(x: Box) -> Box { - box x as Box +fn perform_hax(x: Box) -> Box { + box x as Box } fn deadcode() { diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 1a5b175cffcee..74b64bb87cfc5 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -12,8 +12,8 @@ trait hax { } impl hax for A { } -fn perform_hax(x: Box) -> Box { - box x as Box +fn perform_hax(x: Box) -> Box { + box x as Box } fn deadcode() { diff --git a/src/test/run-pass/issue-5192.rs b/src/test/run-pass/issue-5192.rs index 0dd6623a34907..52cdd29e7473e 100644 --- a/src/test/run-pass/issue-5192.rs +++ b/src/test/run-pass/issue-5192.rs @@ -28,12 +28,12 @@ impl EventLoop for UvEventLoop { } pub struct Scheduler { - event_loop: Box, + event_loop: Box, } impl Scheduler { - pub fn new(event_loop: Box) -> Scheduler { + pub fn new(event_loop: Box) -> Scheduler { Scheduler { event_loop: event_loop, } @@ -41,5 +41,6 @@ impl Scheduler { } pub fn main() { - let _sched = Scheduler::new(box UvEventLoop::new() as Box); + let _sched = + Scheduler::new(box UvEventLoop::new() as Box); } diff --git a/src/test/run-pass/issue-5708.rs b/src/test/run-pass/issue-5708.rs index 2bb320e556235..2e9af9ce57397 100644 --- a/src/test/run-pass/issue-5708.rs +++ b/src/test/run-pass/issue-5708.rs @@ -29,11 +29,11 @@ impl Inner for int { } struct Outer<'a> { - inner: &'a Inner + inner: &'a Inner+'a } impl<'a> Outer<'a> { - fn new(inner: &Inner) -> Outer { + fn new(inner: &'a Inner+'a) -> Outer<'a> { Outer { inner: inner } @@ -51,11 +51,11 @@ pub fn main() { trait MyTrait { } pub struct MyContainer<'a, T> { - foos: Vec<&'a MyTrait> , + foos: Vec<&'a MyTrait+'a> , } impl<'a, T> MyContainer<'a, T> { - pub fn add (&mut self, foo: &'a MyTrait) { + pub fn add (&mut self, foo: &'a MyTrait+'a) { self.foos.push(foo); } } diff --git a/src/test/run-pass/issue-6318.rs b/src/test/run-pass/issue-6318.rs index 6512db3b1c58a..a4576bc7c8ceb 100644 --- a/src/test/run-pass/issue-6318.rs +++ b/src/test/run-pass/issue-6318.rs @@ -10,7 +10,7 @@ pub enum Thing { - A(Box) + A(Box) } pub trait Foo {} @@ -20,7 +20,7 @@ pub struct Struct; impl Foo for Struct {} pub fn main() { - match A(box Struct as Box) { + match A(box Struct as Box) { A(_a) => 0i, }; } diff --git a/src/test/run-pass/issue-8249.rs b/src/test/run-pass/issue-8249.rs index 3ca6c806ef59d..320cce73a28a1 100644 --- a/src/test/run-pass/issue-8249.rs +++ b/src/test/run-pass/issue-8249.rs @@ -13,11 +13,13 @@ struct B; impl A for B {} struct C<'a> { - foo: &'a mut A, + foo: &'a mut A+'a, } -fn foo(a: &mut A) { - C{ foo: a }; +fn foo<'a>(a: &'a mut A+'a) { + C { + foo: a, + }; } pub fn main() { diff --git a/src/test/run-pass/issue-9719.rs b/src/test/run-pass/issue-9719.rs index ac200e6c1ac48..5589b045972b5 100644 --- a/src/test/run-pass/issue-9719.rs +++ b/src/test/run-pass/issue-9719.rs @@ -16,7 +16,7 @@ mod a { pub trait X {} impl X for int {} - pub struct Z<'a>(Enum<&'a X>); + pub struct Z<'a>(Enum<&'a X+'a>); fn foo() { let x = 42i; let z = Z(A(&x as &X)); let _ = z; } } @@ -24,7 +24,7 @@ mod b { trait X {} impl X for int {} struct Y<'a>{ - x:Option<&'a X>, + x: Option<&'a X+'a>, } fn bar() { @@ -36,8 +36,12 @@ mod b { mod c { pub trait X { fn f(&self); } impl X for int { fn f(&self) {} } - pub struct Z<'a>(Option<&'a X>); - fn main() { let x = 42i; let z = Z(Some(&x as &X)); let _ = z; } + pub struct Z<'a>(Option<&'a X+'a>); + fn main() { + let x = 42i; + let z = Z(Some(&x as &X)); + let _ = z; + } } pub fn main() {} diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 511629a6d7a34..f35f10cad641b 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -17,9 +17,9 @@ impl repeat for Box { } } -fn repeater(v: Box) -> Box> { +fn repeater(v: Box) -> Box+'static> { // Note: owned kind is not necessary as A appears in the trait type - box v as Box> // No + box v as Box+'static> // No } pub fn main() { diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index 6deae8618fa69..3e0438bfdd794 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -30,7 +30,7 @@ fn object_invoke1<'d>(x: &'d Trait<'d>) -> (int, int) { } struct Struct1<'e> { - f: &'e Trait<'e> + f: &'e Trait<'e>+'e } fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (int,int) { @@ -40,7 +40,7 @@ fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (int,int) { } struct Struct2<'h, 'i> { - f: &'h Trait<'i> + f: &'h Trait<'i>+'i } fn object_invoke2<'j, 'k>(x: &'k Trait<'j>) -> int { @@ -78,8 +78,8 @@ impl<'s> Trait<'s> for (int,int) { } } -impl<'t> MakerTrait<'t> for Box> { - fn mk() -> Box> { box() (4i,5i) as Box } +impl<'t> MakerTrait<'t> for Box+'t> { + fn mk() -> Box+'t> { box() (4i,5i) as Box+'t> } } enum List<'l> { diff --git a/src/test/run-pass/task-stderr.rs b/src/test/run-pass/task-stderr.rs index ceffd1e363667..d4498b8ccb8ab 100644 --- a/src/test/run-pass/task-stderr.rs +++ b/src/test/run-pass/task-stderr.rs @@ -16,7 +16,9 @@ fn main() { let mut reader = ChanReader::new(rx); let stderr = ChanWriter::new(tx); - let res = TaskBuilder::new().stderr(box stderr as Box).try(proc() -> () { + let res = + TaskBuilder::new().stderr(box stderr as Box) + .try(proc() -> () { fail!("Hello, world!") }); assert!(res.is_err()); diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index 30acf07ae60c7..3956b0e3436e5 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -20,7 +20,7 @@ struct Tree(Gc>); struct TreeR { left: Option, right: Option, - val: Box + val: Box } trait to_str { @@ -55,12 +55,16 @@ impl to_str for Tree { fn foo(x: T) -> String { x.to_str_() } pub fn main() { - let t1 = Tree(box(GC) RefCell::new(TreeR{left: None, - right: None, - val: box 1i as Box})); - let t2 = Tree(box(GC) RefCell::new(TreeR{left: Some(t1), - right: Some(t1), - val: box 2i as Box})); + let t1 = Tree(box(GC) RefCell::new(TreeR{ + left: None, + right: None, + val: box 1i as Box + })); + let t2 = Tree(box(GC) RefCell::new(TreeR{ + left: Some(t1), + right: Some(t1), + val: box 2i as Box + })); let expected = "[2, some([1, none, none]), some([1, none, none])]".to_string(); assert!(t2.to_str_() == expected); diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index 3c5ae6b57a3a9..18fbca29285fa 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -21,7 +21,7 @@ pub struct Impl { * task failed at 'index out of bounds: the len is 1 but the index is 1', * src/librustc/middle/subst.rs:58 */ - t: Box> + t: Box+'static> } impl Impl { @@ -43,6 +43,6 @@ impl Trait for () { } pub fn main() { - let a = box() () as Box>; + let a = box() () as Box+'static>; assert_eq!(a.method(Constant), 0); } diff --git a/src/test/run-pass/unboxed-closures-boxed.rs b/src/test/run-pass/unboxed-closures-boxed.rs index c4b990abf7e65..3bbc9603d5029 100644 --- a/src/test/run-pass/unboxed-closures-boxed.rs +++ b/src/test/run-pass/unboxed-closures-boxed.rs @@ -12,8 +12,8 @@ use std::ops::FnMut; -fn make_adder(x: int) -> Box> { - (box |&mut: y: int| -> int { x + y }) as Box> +fn make_adder(x: int) -> Box+'static> { + (box |&mut: y: int| -> int { x + y }) as Box+'static> } pub fn main() {