diff --git a/src/doc/rust.md b/src/doc/rust.md index 9fe61eb3fe3b0..b015cb0fbb8c6 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -3864,13 +3864,13 @@ Function parameters are immutable unless declared with `mut`. The and `fn f(mut x: Box, y: Box)` declare one mutable variable `x` and one immutable variable `y`). -Methods that take either `self` or `~self` can optionally place them in a +Methods that take either `self` or `Box` can optionally place them in a mutable slot by prefixing them with `mut` (similar to regular arguments): ~~~ trait Changer { fn change(mut self) -> Self; - fn modify(mut ~self) -> Box; + fn modify(mut self: Box) -> Box; } ~~~ diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 2b85bc50de3ab..b6485f711ee7a 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1971,7 +1971,7 @@ like any other function, except for the name `self`. The type of `self` is the type on which the method is implemented, or a pointer thereof. As an argument it is written either `self`, -`&self`, or `~self`. +`&self`, or `self: TYPE`. A caller must in turn have a compatible pointer type to call the method. ~~~ @@ -1984,7 +1984,7 @@ A caller must in turn have a compatible pointer type to call the method. # } impl Shape { fn draw_reference(&self) { /* ... */ } - fn draw_owned(~self) { /* ... */ } + fn draw_owned(self: Box) { /* ... */ } fn draw_value(self) { /* ... */ } } @@ -2009,7 +2009,7 @@ to a reference. # } # impl Shape { # fn draw_reference(&self) { /* ... */ } -# fn draw_owned(~self) { /* ... */ } +# fn draw_owned(self: Box) { /* ... */ } # fn draw_value(self) { /* ... */ } # } # let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0); diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index 7151a78eacd43..38bb6e355a771 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -180,7 +180,7 @@ 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) { + pub fn bootstrap(mut self: Box) { // Build an Idle callback. let cb = box SchedRunner as Box; @@ -224,7 +224,8 @@ impl Scheduler { // This does not return a scheduler, as the scheduler is placed // inside the task. - pub fn run(mut ~self, stask: Box) -> Box { + pub fn run(mut self: Box, stask: Box) + -> Box { // This is unsafe because we need to place the scheduler, with // the event_loop inside, inside our task. But we still need a @@ -271,7 +272,7 @@ impl Scheduler { // If we try really hard to do some work, but no work is available to be // done, then we fall back to epoll() to block this thread waiting for more // work (instead of busy waiting). - fn run_sched_once(mut ~self, stask: Box) { + fn run_sched_once(mut self: Box, stask: Box) { // Make sure that we're not lying in that the `stask` argument is indeed // the scheduler task for this scheduler. assert!(self.sched_task.is_none()); @@ -349,11 +350,10 @@ impl Scheduler { // returns the still-available scheduler. At this point all // message-handling will count as a turn of work, and as a result // return None. - fn interpret_message_queue(mut ~self, stask: Box, + fn interpret_message_queue(mut self: Box, + stask: Box, effort: EffortLevel) - -> (Box, Box, bool) - { - + -> (Box, Box, bool) { let msg = if effort == DontTryTooHard { self.message_queue.casual_pop() } else { @@ -432,7 +432,7 @@ impl Scheduler { } } - fn do_work(mut ~self, stask: Box) + fn do_work(mut self: Box, stask: Box) -> (Box, Box, bool) { rtdebug!("scheduler calling do work"); match self.find_work() { @@ -517,7 +517,7 @@ impl Scheduler { // * Task Routing Functions - Make sure tasks send up in the right // place. - fn process_task(mut ~self, + fn process_task(mut self: Box, cur: Box, mut next: Box, schedule_fn: SchedulingFn) @@ -610,7 +610,7 @@ impl Scheduler { // cleanup function f, which takes the scheduler and the // old task as inputs. - pub fn change_task_context(mut ~self, + pub fn change_task_context(mut self: Box, mut current_task: Box, mut next_task: Box, f: |&mut Scheduler, Box|) @@ -693,7 +693,7 @@ impl Scheduler { // * Context Swapping Helpers - Here be ugliness! - pub fn resume_task_immediately(~self, + pub fn resume_task_immediately(self: Box, cur: Box, next: Box) -> (Box, Box) { @@ -733,7 +733,7 @@ impl Scheduler { /// This situation is currently prevented, or in other words it is /// guaranteed that this function will not return before the given closure /// has returned. - pub fn deschedule_running_task_and_then(mut ~self, + pub fn deschedule_running_task_and_then(mut self: Box, cur: Box, f: |&mut Scheduler, BlockedTask|) { // Trickier - we need to get the scheduler task out of self @@ -743,7 +743,7 @@ impl Scheduler { self.switch_running_tasks_and_then(cur, stask, f) } - pub fn switch_running_tasks_and_then(~self, + pub fn switch_running_tasks_and_then(self: Box, cur: Box, next: Box, f: |&mut Scheduler, BlockedTask|) { @@ -795,7 +795,9 @@ impl Scheduler { /// Called by a running task to end execution, after which it will /// be recycled by the scheduler for reuse in a new task. - pub fn terminate_current_task(mut ~self, cur: Box) -> ! { + pub fn terminate_current_task(mut self: Box, + cur: Box) + -> ! { // Similar to deschedule running task and then, but cannot go through // the task-blocking path. The task is already dying. let stask = self.sched_task.take_unwrap(); @@ -807,7 +809,9 @@ impl Scheduler { fail!("should never return!"); } - pub fn run_task(~self, cur: Box, next: Box) { + pub fn run_task(self: Box, + cur: Box, + next: Box) { let (sched, task) = self.process_task(cur, next, Scheduler::switch_task); task.put_with_sched(sched); @@ -823,7 +827,7 @@ impl Scheduler { /// to introduce some amount of randomness to the scheduler. Currently the /// randomness is a result of performing a round of work stealing (which /// may end up stealing from the current scheduler). - pub fn yield_now(mut ~self, cur: Box) { + pub fn yield_now(mut self: Box, cur: Box) { // Async handles trigger the scheduler by calling yield_now on the local // task, which eventually gets us to here. See comments in SchedRunner // for more info on this. @@ -842,7 +846,7 @@ impl Scheduler { } } - pub fn maybe_yield(mut ~self, cur: Box) { + pub fn maybe_yield(mut self: Box, cur: Box) { // It's possible for sched tasks to possibly call this function, and it // just means that they're likely sending on channels (which // occasionally call this function). Sched tasks follow different paths diff --git a/src/libgreen/simple.rs b/src/libgreen/simple.rs index 874ddbfe7ed0e..6254e8c55f007 100644 --- a/src/libgreen/simple.rs +++ b/src/libgreen/simple.rs @@ -27,7 +27,9 @@ struct SimpleTask { impl Runtime for SimpleTask { // Implement the simple tasks of descheduling and rescheduling, but only in // a simple number of cases. - fn deschedule(mut ~self, times: uint, mut cur_task: Box, + fn deschedule(mut self: Box, + times: uint, + mut cur_task: Box, f: |BlockedTask| -> Result<(), BlockedTask>) { assert!(times == 1); @@ -54,7 +56,7 @@ impl Runtime for SimpleTask { } Local::put(cur_task); } - fn reawaken(mut ~self, mut to_wake: Box) { + fn reawaken(mut self: Box, mut to_wake: Box) { let me = &mut *self as *mut SimpleTask; to_wake.put_runtime(self); unsafe { @@ -69,9 +71,9 @@ impl Runtime for SimpleTask { // purpose. A "simple task" is just that, a very simple task that can't // really do a whole lot. The only purpose of the task is to get us off our // feet and running. - fn yield_now(~self, _cur_task: Box) { fail!() } - fn maybe_yield(~self, _cur_task: Box) { fail!() } - fn spawn_sibling(~self, + fn yield_now(self: Box, _cur_task: Box) { fail!() } + fn maybe_yield(self: Box, _cur_task: Box) { fail!() } + fn spawn_sibling(self: Box, _cur_task: Box, _opts: TaskOpts, _f: proc():Send) { @@ -80,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 { fail!() } + fn wrap(self: Box) -> Box { fail!() } } pub fn task() -> Box { diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index 68a454233cf9a..3d3b413384050 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -265,7 +265,7 @@ impl GreenTask { // Runtime glue functions and helpers - pub fn put_with_sched(mut ~self, sched: Box) { + pub fn put_with_sched(mut self: Box, sched: Box) { assert!(self.sched.is_none()); self.sched = Some(sched); self.put(); @@ -276,18 +276,18 @@ impl GreenTask { self.task = Some(task); } - pub fn swap(mut ~self) -> Box { + pub fn swap(mut self: Box) -> Box { let mut task = self.task.take_unwrap(); task.put_runtime(self); return task; } - pub fn put(~self) { + pub fn put(self: Box) { assert!(self.sched.is_some()); Local::put(self.swap()); } - fn terminate(mut ~self) -> ! { + fn terminate(mut self: Box) -> ! { let sched = self.sched.take_unwrap(); sched.terminate_current_task(self) } @@ -311,7 +311,7 @@ impl GreenTask { // *not* a cheap operation to clone a handle. Until the day comes that we // need to optimize this, a lock should do just fine (it's completely // uncontended except for when the task is rescheduled). - fn reawaken_remotely(mut ~self) { + fn reawaken_remotely(mut self: Box) { unsafe { let mtx = &mut self.nasty_deschedule_lock as *mut NativeMutex; let handle = self.handle.get_mut_ref() as *mut SchedHandle; @@ -322,19 +322,21 @@ impl GreenTask { } impl Runtime for GreenTask { - fn yield_now(mut ~self, cur_task: Box) { + fn yield_now(mut self: Box, cur_task: Box) { self.put_task(cur_task); let sched = self.sched.take_unwrap(); sched.yield_now(self); } - fn maybe_yield(mut ~self, cur_task: Box) { + fn maybe_yield(mut self: Box, cur_task: Box) { self.put_task(cur_task); let sched = self.sched.take_unwrap(); sched.maybe_yield(self); } - fn deschedule(mut ~self, times: uint, cur_task: Box, + fn deschedule(mut self: Box, + times: uint, + cur_task: Box, f: |BlockedTask| -> Result<(), BlockedTask>) { self.put_task(cur_task); let mut sched = self.sched.take_unwrap(); @@ -383,7 +385,7 @@ impl Runtime for GreenTask { } } - fn reawaken(mut ~self, to_wake: Box) { + fn reawaken(mut self: Box, to_wake: Box) { self.put_task(to_wake); assert!(self.sched.is_none()); @@ -434,7 +436,7 @@ impl Runtime for GreenTask { } } - fn spawn_sibling(mut ~self, + fn spawn_sibling(mut self: Box, cur_task: Box, opts: TaskOpts, f: proc():Send) { @@ -471,7 +473,7 @@ impl Runtime for GreenTask { fn can_block(&self) -> bool { false } - fn wrap(~self) -> Box { self as Box } + fn wrap(self: Box) -> Box { self as Box } } #[cfg(test)] diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index f052826d30386..c3eb5e91e90f0 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -484,7 +484,8 @@ impl TcpListener { } impl rtio::RtioTcpListener for TcpListener { - fn listen(~self) -> IoResult> { + fn listen(self: Box) + -> IoResult> { self.native_listen(128).map(|a| { box a as Box }) diff --git a/src/libnative/io/pipe_unix.rs b/src/libnative/io/pipe_unix.rs index 0e019fa7e8fbd..075ca769d073e 100644 --- a/src/libnative/io/pipe_unix.rs +++ b/src/libnative/io/pipe_unix.rs @@ -229,7 +229,8 @@ impl UnixListener { } impl rtio::RtioUnixListener for UnixListener { - fn listen(~self) -> IoResult> { + fn listen(self: Box) + -> IoResult> { self.native_listen(128).map(|a| { box a as Box }) diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs index ec40ff89bd2cd..79ca23abed25c 100644 --- a/src/libnative/io/pipe_win32.rs +++ b/src/libnative/io/pipe_win32.rs @@ -588,7 +588,8 @@ impl Drop for UnixListener { } impl rtio::RtioUnixListener for UnixListener { - fn listen(~self) -> IoResult> { + fn listen(self: Box) + -> IoResult> { self.native_listen().map(|a| { box a as Box }) diff --git a/src/libnative/task.rs b/src/libnative/task.rs index 7ba588ac21c48..35367ff2efab3 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -131,21 +131,21 @@ struct Ops { } impl rt::Runtime for Ops { - fn yield_now(~self, mut cur_task: Box) { + fn yield_now(self: Box, mut cur_task: Box) { // put the task back in TLS and then invoke the OS thread yield cur_task.put_runtime(self); Local::put(cur_task); Thread::yield_now(); } - fn maybe_yield(~self, mut cur_task: Box) { + fn maybe_yield(self: Box, mut cur_task: Box) { // just put the task back in TLS, on OS threads we never need to // opportunistically yield b/c the OS will do that for us (preemption) cur_task.put_runtime(self); Local::put(cur_task); } - fn wrap(~self) -> Box { + fn wrap(self: Box) -> Box { self as Box } @@ -192,7 +192,9 @@ impl rt::Runtime for Ops { // `awoken` field which indicates whether we were actually woken up via some // invocation of `reawaken`. This flag is only ever accessed inside the // lock, so there's no need to make it atomic. - fn deschedule(mut ~self, times: uint, mut cur_task: Box, + fn deschedule(mut self: Box, + times: uint, + mut cur_task: Box, f: |BlockedTask| -> Result<(), BlockedTask>) { let me = &mut *self as *mut Ops; cur_task.put_runtime(self); @@ -250,7 +252,7 @@ impl rt::Runtime for Ops { // See the comments on `deschedule` for why the task is forgotten here, and // why it's valid to do so. - fn reawaken(mut ~self, mut to_wake: Box) { + fn reawaken(mut self: Box, mut to_wake: Box) { unsafe { let me = &mut *self as *mut Ops; to_wake.put_runtime(self); @@ -261,7 +263,7 @@ impl rt::Runtime for Ops { } } - fn spawn_sibling(~self, + fn spawn_sibling(self: Box, mut cur_task: Box, opts: TaskOpts, f: proc():Send) { diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index e129492dbc2f8..8f450fe3d76a7 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -1051,7 +1051,6 @@ fn determine_explicit_self_category ty::ByBoxExplicitSelfCategory, ast::SelfExplicit(ast_type, _) => { let explicit_type = ast_ty_to_ty(this, rscope, &*ast_type); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 3cb2e9c6ec9ac..57cda6c48178a 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -779,7 +779,6 @@ impl Clean for ast::ExplicitSelf_ { match *self { ast::SelfStatic => SelfStatic, ast::SelfValue(_) => SelfValue, - ast::SelfUniq(_) => SelfOwned, ast::SelfRegion(lt, mt, _) => { SelfBorrowed(lt.clean(), mt.clean()) } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d0f9b37cc4ce4..e7f9370339922 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -491,7 +491,7 @@ impl<'a> fmt::Show for Method<'a> { match *selfty { clean::SelfStatic => {}, clean::SelfValue => args.push_str("self"), - clean::SelfOwned => args.push_str("~self"), + clean::SelfOwned => args.push_str("self: Box"), clean::SelfBorrowed(Some(ref lt), mtbl) => { args.push_str(format!("&{} {}self", *lt, MutableSpace(mtbl)).as_slice()); diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index 2fe0c32153af2..e2d7f91d1a6f9 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -74,15 +74,17 @@ pub mod unwind; pub trait Runtime { // Necessary scheduling functions, used for channels and blocking I/O // (sometimes). - fn yield_now(~self, cur_task: Box); - fn maybe_yield(~self, cur_task: Box); - fn deschedule(~self, times: uint, cur_task: Box, + fn yield_now(self: Box, cur_task: Box); + fn maybe_yield(self: Box, cur_task: Box); + fn deschedule(self: Box, + times: uint, + cur_task: Box, f: |BlockedTask| -> Result<(), BlockedTask>); - fn reawaken(~self, to_wake: Box); + fn reawaken(self: Box, to_wake: Box); // Miscellaneous calls which are very different depending on what context // you're in. - fn spawn_sibling(~self, + fn spawn_sibling(self: Box, cur_task: Box, opts: TaskOpts, f: proc():Send); @@ -92,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; + fn wrap(self: Box) -> Box; } /// The default error code of the rust runtime if the main task fails instead diff --git a/src/librustrt/rtio.rs b/src/librustrt/rtio.rs index 81a033e4c987e..134453659dbf6 100644 --- a/src/librustrt/rtio.rs +++ b/src/librustrt/rtio.rs @@ -238,7 +238,7 @@ pub trait IoFactory { } pub trait RtioTcpListener : RtioSocket { - fn listen(~self) -> IoResult>; + fn listen(self: Box) -> IoResult>; } pub trait RtioTcpAcceptor : RtioSocket { @@ -329,7 +329,7 @@ pub trait RtioPipe { } pub trait RtioUnixListener { - fn listen(~self) -> IoResult>; + fn listen(self: Box) -> IoResult>; } pub trait RtioUnixAcceptor { diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 78c32889277b2..d27a4f25b4e70 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -203,7 +203,7 @@ impl Task { /// }).destroy(); /// # } /// ``` - pub fn run(~self, f: ||) -> Box { + pub fn run(self: Box, f: ||) -> Box { assert!(!self.is_destroyed(), "cannot re-use a destroyed task"); // First, make sure that no one else is in TLS. This does not allow @@ -239,7 +239,7 @@ impl Task { /// /// The returned task cannot be used for running any more code, but it may /// be used to extract the runtime as necessary. - pub fn destroy(~self) -> Box { + pub fn destroy(self: Box) -> Box { if self.is_destroyed() { self } else { @@ -252,7 +252,7 @@ impl Task { /// This function consumes ownership of the task, deallocating it once it's /// done being processed. It is assumed that TLD and the local heap have /// already been destroyed and/or annihilated. - fn cleanup(~self, result: Result) -> Box { + fn cleanup(self: Box, result: Result) -> Box { // The first thing to do when cleaning up is to deallocate our local // resources, such as TLD and GC data. // @@ -394,7 +394,9 @@ impl Task { /// Spawns a sibling to this task. The newly spawned task is configured with /// the `opts` structure and will run `f` as the body of its code. - pub fn spawn_sibling(mut ~self, opts: TaskOpts, f: proc(): Send) { + pub fn spawn_sibling(mut self: Box, + opts: TaskOpts, + f: proc(): Send) { let ops = self.imp.take_unwrap(); ops.spawn_sibling(self, opts, f) } @@ -402,7 +404,8 @@ impl Task { /// Deschedules the current task, invoking `f` `amt` times. It is not /// recommended to use this function directly, but rather communication /// primitives in `std::comm` should be used. - pub fn deschedule(mut ~self, amt: uint, + pub fn deschedule(mut self: Box, + amt: uint, f: |BlockedTask| -> ::core::result::Result<(), BlockedTask>) { let ops = self.imp.take_unwrap(); ops.deschedule(amt, self, f) @@ -411,7 +414,7 @@ impl Task { /// Wakes up a previously blocked task, optionally specifying whether the /// current task can accept a change in scheduling. This function can only /// be called on tasks that were previously blocked in `deschedule`. - pub fn reawaken(mut ~self) { + pub fn reawaken(mut self: Box) { let ops = self.imp.take_unwrap(); ops.reawaken(self); } @@ -419,14 +422,14 @@ impl Task { /// Yields control of this task to another task. This function will /// eventually return, but possibly not immediately. This is used as an /// opportunity to allow other tasks a chance to run. - pub fn yield_now(mut ~self) { + pub fn yield_now(mut self: Box) { let ops = self.imp.take_unwrap(); ops.yield_now(self); } /// Similar to `yield_now`, except that this function may immediately return /// without yielding (depending on what the runtime decides to do). - pub fn maybe_yield(mut ~self) { + pub fn maybe_yield(mut self: Box) { let ops = self.imp.take_unwrap(); ops.maybe_yield(self); } diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 2c2e134d882cb..76109eaae99bd 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -154,7 +154,7 @@ pub trait UvHandle { mem::transmute(uvll::get_data_for_uv_handle(*h)) } - fn install(~self) -> Box { + fn install(self: Box) -> Box { unsafe { let myptr = mem::transmute::<&Box, &*mut u8>(&self); uvll::set_data_for_uv_handle(self.uv_handle(), *myptr); diff --git a/src/librustuv/net.rs b/src/librustuv/net.rs index 45f93d9d12898..3cc10ae3823ac 100644 --- a/src/librustuv/net.rs +++ b/src/librustuv/net.rs @@ -389,7 +389,8 @@ impl rtio::RtioSocket for TcpListener { } impl rtio::RtioTcpListener for TcpListener { - fn listen(~self) -> Result, IoError> { + fn listen(self: Box) + -> Result, IoError> { // create the acceptor object from ourselves let mut acceptor = box TcpAcceptor { listener: self, diff --git a/src/librustuv/pipe.rs b/src/librustuv/pipe.rs index 1c53814ac2441..f0a57546ed43e 100644 --- a/src/librustuv/pipe.rs +++ b/src/librustuv/pipe.rs @@ -248,7 +248,8 @@ impl PipeListener { } impl rtio::RtioUnixListener for PipeListener { - fn listen(~self) -> IoResult> { + fn listen(self: Box) + -> IoResult> { // create the acceptor object from ourselves let mut acceptor = box PipeAcceptor { listener: self, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 614bbd1c3ed00..f05d17569f68d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -955,8 +955,6 @@ pub enum ExplicitSelf_ { SelfValue(Ident), /// `&'lt self`, `&'lt mut self` SelfRegion(Option, Mutability, Ident), - /// `~self` - SelfUniq(Ident), /// `self: TYPE` SelfExplicit(P, Ident), } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 271eee7d08a03..f48306bc6ee2f 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -340,7 +340,7 @@ pub trait Folder { fn fold_explicit_self_(&mut self, es: &ExplicitSelf_) -> ExplicitSelf_ { match *es { - SelfStatic | SelfValue(_) | SelfUniq(_) => *es, + SelfStatic | SelfValue(_) => *es, SelfRegion(ref lifetime, m, id) => { SelfRegion(fold_opt_lifetime(lifetime, self), m, id) } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index ba401d313d87f..afcf84753a612 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -31,6 +31,7 @@ pub enum ObsoleteSyntax { ObsoleteOwnedExpr, ObsoleteOwnedPattern, ObsoleteOwnedVector, + ObsoleteOwnedSelf, ObsoleteManagedType, ObsoleteManagedExpr, } @@ -70,6 +71,10 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { "`~[T]` is no longer a type", "use the `Vec` type instead" ), + ObsoleteOwnedSelf => ( + "`~self` is no longer supported", + "write `self: Box` instead" + ), ObsoleteManagedType => ( "`@` notation for managed pointers", "use `Gc` in `std::gc` instead" diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 73de47e7b12e7..e5e4109025841 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -45,7 +45,7 @@ use ast::{RetStyle, Return, BiShl, BiShr, Stmt, StmtDecl}; use ast::{StmtExpr, StmtSemi, StmtMac, StructDef, StructField}; use ast::{StructVariantKind, BiSub}; use ast::StrStyle; -use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfUniq, SelfValue}; +use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{TokenTree, TraitMethod, TraitRef, TTDelim, TTSeq, TTTok}; use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox}; use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn}; @@ -3826,10 +3826,11 @@ impl<'a> Parser<'a> { // We need to make sure it isn't a type if self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) { self.bump(); - SelfUniq(self.expect_self_ident()) - } else { - SelfStatic + drop(self.expect_self_ident()); + let last_span = self.last_span; + self.obsolete(last_span, ObsoleteOwnedSelf) } + SelfStatic } token::IDENT(..) if self.is_self_ident() => { let self_ident = self.expect_self_ident(); @@ -3877,7 +3878,10 @@ impl<'a> Parser<'a> { self.look_ahead(2, |t| token::is_keyword(keywords::Self, t)) => { mutbl_self = self.parse_mutability(); self.bump(); - SelfUniq(self.expect_self_ident()) + drop(self.expect_self_ident()); + let last_span = self.last_span; + self.obsolete(last_span, ObsoleteOwnedSelf); + SelfStatic } _ => SelfStatic }; @@ -3921,7 +3925,6 @@ impl<'a> Parser<'a> { } SelfValue(id) => parse_remaining_arguments!(id), SelfRegion(_,_,id) => parse_remaining_arguments!(id), - SelfUniq(id) => parse_remaining_arguments!(id), SelfExplicit(_,id) => parse_remaining_arguments!(id), }; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 305e67a916eb9..ac8355651916e 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1892,9 +1892,6 @@ impl<'a> State<'a> { ast::SelfValue(_) => { try!(word(&mut self.s, "self")); } - ast::SelfUniq(_) => { - try!(word(&mut self.s, "~self")); - } ast::SelfRegion(ref lt, m, _) => { try!(word(&mut self.s, "&")); try!(self.print_opt_lifetime(lt)); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 3c6f06ddfc35d..371fae53b41d0 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -216,7 +216,7 @@ pub fn walk_explicit_self>(visitor: &mut V, explicit_self: &ExplicitSelf, env: E) { match explicit_self.node { - SelfStatic | SelfValue(_) | SelfUniq(_) => {}, + SelfStatic | SelfValue(_) => {}, SelfRegion(ref lifetime, _, _) => { visitor.visit_opt_lifetime_ref(explicit_self.span, lifetime, env) }