From 299995c2b62c520708d450e4b7c6d360be0fd852 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 14 Mar 2013 11:22:51 -0700 Subject: [PATCH 1/3] librustc: Convert all uses of old lifetime notation to new lifetime notation. rs=delifetiming --- src/libcore/at_vec.rs | 4 +- src/libcore/cast.rs | 12 +- src/libcore/cleanup.rs | 4 +- src/libcore/condition.rs | 10 +- src/libcore/container.rs | 2 +- src/libcore/gc.rs | 2 +- src/libcore/hashmap.rs | 16 +-- src/libcore/io.rs | 2 +- src/libcore/iter.rs | 2 +- src/libcore/option.rs | 20 +-- src/libcore/os.rs | 44 +++---- src/libcore/pipes.rs | 2 +- src/libcore/ptr.rs | 18 +-- src/libcore/reflect.rs | 16 +-- src/libcore/result.rs | 4 +- src/libcore/rt/io.rs | 2 +- src/libcore/rt/sched.rs | 8 +- src/libcore/rt/uv.rs | 2 +- src/libcore/rt/uvio.rs | 4 +- src/libcore/str.rs | 70 +++++------ src/libcore/sys.rs | 2 +- src/libcore/task/local_data.rs | 2 +- src/libcore/task/spawn.rs | 2 +- src/libcore/to_bytes.rs | 10 +- src/libcore/to_str.rs | 4 +- src/libcore/trie.rs | 12 +- src/libcore/tuple.rs | 10 +- src/libcore/unstable.rs | 2 +- src/libcore/unstable/finally.rs | 4 +- src/libcore/unstable/global.rs | 2 +- src/libcore/vec.rs | 114 +++++++++--------- src/librust/rust.rc | 14 +-- src/librustc/front/core_inject.rs | 2 +- src/librustc/front/test.rs | 20 ++- src/librustc/metadata/decoder.rs | 4 +- src/librustc/metadata/encoder.rs | 2 +- src/librustc/metadata/filesearch.rs | 2 +- src/librustc/metadata/tydecode.rs | 2 +- src/librustc/middle/borrowck/gather_loans.rs | 2 +- src/librustc/middle/borrowck/preserve.rs | 2 +- src/librustc/middle/kind.rs | 2 +- src/librustc/middle/lang_items.rs | 6 +- src/librustc/middle/lint.rs | 8 +- src/librustc/middle/region.rs | 14 +-- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/trans/_match.rs | 4 +- src/librustc/middle/trans/callee.rs | 4 +- src/librustc/middle/trans/datum.rs | 2 +- src/librustc/middle/trans/tvec.rs | 2 +- src/librustc/middle/ty.rs | 4 +- src/librustc/middle/typeck/astconv.rs | 2 +- src/librustc/middle/typeck/check/method.rs | 2 +- src/librustc/middle/typeck/check/regionck.rs | 4 +- src/librustc/middle/typeck/coherence.rs | 4 +- src/librustc/middle/typeck/collect.rs | 4 +- src/librustc/middle/typeck/infer/lattice.rs | 4 +- .../middle/typeck/infer/region_inference.rs | 38 +++--- src/librustc/middle/typeck/infer/unify.rs | 16 +-- src/libstd/arc.rs | 14 +-- src/libstd/arena.rs | 6 +- src/libstd/base64.rs | 4 +- src/libstd/bigint.rs | 40 +++--- src/libstd/deque.rs | 8 +- src/libstd/future.rs | 2 +- src/libstd/json.rs | 6 +- src/libstd/priority_queue.rs | 4 +- src/libstd/serialize.rs | 6 +- src/libstd/smallintmap.rs | 12 +- src/libstd/sort.rs | 16 +-- src/libstd/stats.rs | 2 +- src/libstd/sync.rs | 24 ++-- src/libstd/test.rs | 2 +- src/libstd/treemap.rs | 28 ++--- src/libsyntax/ext/base.rs | 4 +- src/libsyntax/ext/deriving.rs | 4 +- src/libsyntax/ext/quote.rs | 6 + src/libsyntax/opt_vec.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/test/auxiliary/cci_const.rs | 2 +- .../compile-fail/borrowck-addr-of-upvar.rs | 4 +- .../const-cast-different-types.rs | 2 +- src/test/compile-fail/issue-2149.rs | 2 +- src/test/compile-fail/issue-2478.rs | 2 +- src/test/compile-fail/issue-3243.rs | 2 +- src/test/compile-fail/issue-3311.rs | 2 +- src/test/compile-fail/issue-3563.rs | 2 +- src/test/compile-fail/issue-3888.rs | 2 +- src/test/compile-fail/issue-4335.rs | 2 +- src/test/compile-fail/issue-4523.rs | 2 +- .../kindck-owned-trait-contains.rs | 4 +- .../compile-fail/kindck-owned-trait-scoped.rs | 2 +- src/test/compile-fail/regions-addr-of-self.rs | 4 +- src/test/compile-fail/regions-blk.rs | 6 +- src/test/compile-fail/regions-fn-bound.rs | 2 +- src/test/compile-fail/regions-fn-subtyping.rs | 50 ++++---- src/test/compile-fail/regions-fns.rs | 4 +- src/test/compile-fail/regions-freevar.rs | 2 +- .../regions-infer-borrow-scope-too-big.rs | 2 +- .../regions-infer-borrow-scope-within-loop.rs | 2 +- src/test/compile-fail/regions-infer-call-3.rs | 4 +- ...regions-infer-contravariance-due-to-ret.rs | 2 +- .../regions-infer-covariance-due-to-arg.rs | 2 +- ...ns-infer-invariance-due-to-mutability-3.rs | 2 +- ...ns-infer-invariance-due-to-mutability-4.rs | 2 +- .../regions-infer-paramd-indirect.rs | 2 +- src/test/compile-fail/regions-nested-fns-2.rs | 2 +- src/test/compile-fail/regions-nested-fns.rs | 6 +- .../regions-out-of-scope-slice.rs | 2 +- .../compile-fail/regions-ret-borrowed-1.rs | 4 +- src/test/compile-fail/regions-ret.rs | 2 +- src/test/compile-fail/regions-scoping.rs | 6 +- src/test/compile-fail/regions-trait-2.rs | 2 +- src/test/compile-fail/regions-trait-3.rs | 2 +- src/test/run-pass/assignability-trait.rs | 2 +- src/test/run-pass/bare-static-string.rs | 2 +- src/test/run-pass/borrowck-root-while-cond.rs | 2 +- .../borrowck-wg-borrow-mut-to-imm-3.rs | 2 +- src/test/run-pass/borrowed-ptr-pattern-3.rs | 2 +- .../run-pass/borrowed-ptr-pattern-option.rs | 2 +- src/test/run-pass/const-cast.rs | 2 +- src/test/run-pass/const-cross-crate-const.rs | 2 +- src/test/run-pass/const-enum-ptr.rs | 2 +- src/test/run-pass/const-enum-vec-ptr.rs | 2 +- src/test/run-pass/const-str-ptr.rs | 2 +- src/test/run-pass/explicit-self.rs | 6 +- src/test/run-pass/issue-2502.rs | 4 +- src/test/run-pass/issue-2748-b.rs | 2 +- src/test/run-pass/issue-3860.rs | 2 +- src/test/run-pass/issue-3888-2.rs | 2 +- src/test/run-pass/issue-4448.rs | 2 +- src/test/run-pass/reflect-visit-data.rs | 16 +-- src/test/run-pass/region-dependent-addr-of.rs | 18 +-- .../region-return-interior-of-option.rs | 2 +- src/test/run-pass/regions-addr-of-ret.rs | 2 +- src/test/run-pass/regions-bot.rs | 2 +- src/test/run-pass/regions-equiv-fns.rs | 2 +- .../run-pass/regions-escape-into-other-fn.rs | 2 +- src/test/run-pass/regions-fn-subtyping.rs | 4 +- .../regions-infer-borrow-scope-view.rs | 2 +- ...gions-infer-borrow-scope-within-loop-ok.rs | 2 +- .../run-pass/regions-infer-borrow-scope.rs | 2 +- src/test/run-pass/regions-infer-call-2.rs | 2 +- src/test/run-pass/regions-infer-call.rs | 2 +- ...regions-infer-contravariance-due-to-ret.rs | 2 +- .../run-pass/regions-infer-contravariance.rs | 4 +- src/test/run-pass/regions-params.rs | 2 +- src/test/run-pass/regions-trait.rs | 4 +- 147 files changed, 523 insertions(+), 501 deletions(-) diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 8cd8b297e2f..8d3c8561957 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -174,9 +174,9 @@ pub mod traits { use kinds::Copy; use ops::Add; - impl Add<&self/[const T],@[T]> for @[T] { + impl Add<&'self [const T],@[T]> for @[T] { #[inline(always)] - pure fn add(&self, rhs: & &self/[const T]) -> @[T] { + pure fn add(&self, rhs: & &'self [const T]) -> @[T] { append(*self, (*rhs)) } } diff --git a/src/libcore/cast.rs b/src/libcore/cast.rs index bc4358db56c..f752f52ce53 100644 --- a/src/libcore/cast.rs +++ b/src/libcore/cast.rs @@ -59,17 +59,17 @@ pub unsafe fn transmute(thing: L) -> G { /// Coerce an immutable reference to be mutable. #[inline(always)] -pub unsafe fn transmute_mut(ptr: &a/T) -> &a/mut T { transmute(ptr) } +pub unsafe fn transmute_mut(ptr: &'a T) -> &'a mut T { transmute(ptr) } /// Coerce a mutable reference to be immutable. #[inline(always)] -pub unsafe fn transmute_immut(ptr: &a/mut T) -> &a/T { +pub unsafe fn transmute_immut(ptr: &'a mut T) -> &'a T { transmute(ptr) } /// Coerce a borrowed pointer to have an arbitrary associated region. #[inline(always)] -pub unsafe fn transmute_region(ptr: &a/T) -> &b/T { transmute(ptr) } +pub unsafe fn transmute_region(ptr: &'a T) -> &'b T { transmute(ptr) } /// Coerce an immutable reference to be mutable. #[inline(always)] @@ -85,19 +85,19 @@ pub unsafe fn transmute_immut_unsafe(ptr: *const T) -> *T { /// Coerce a borrowed mutable pointer to have an arbitrary associated region. #[inline(always)] -pub unsafe fn transmute_mut_region(ptr: &a/mut T) -> &b/mut T { +pub unsafe fn transmute_mut_region(ptr: &'a mut T) -> &'b mut T { transmute(ptr) } /// Transforms lifetime of the second pointer to match the first. #[inline(always)] -pub unsafe fn copy_lifetime(_ptr: &a/S, ptr: &T) -> &a/T { +pub unsafe fn copy_lifetime(_ptr: &'a S, ptr: &T) -> &'a T { transmute_region(ptr) } /// Transforms lifetime of the second pointer to match the first. #[inline(always)] -pub unsafe fn copy_lifetime_vec(_ptr: &a/[S], ptr: &T) -> &a/T { +pub unsafe fn copy_lifetime_vec(_ptr: &'a [S], ptr: &T) -> &'a T { transmute_region(ptr) } diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index a46e9154703..66eeb339700 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -22,8 +22,8 @@ use cast::transmute; * NB: These must match the representation in the C++ runtime. */ -type DropGlue = &self/fn(**TypeDesc, *c_void); -type FreeGlue = &self/fn(**TypeDesc, *c_void); +type DropGlue = &'self fn(**TypeDesc, *c_void); +type FreeGlue = &'self fn(**TypeDesc, *c_void); type TaskID = uintptr_t; diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index 17d15a8886f..56b690ca8af 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -21,12 +21,12 @@ pub struct Handler { } pub struct Condition { - name: &static/str, + name: &'static str, key: task::local_data::LocalDataKey/&self> } pub impl Condition/&self { - fn trap(&self, h: &self/fn(T) -> U) -> Trap/&self { + fn trap(&self, h: &'self fn(T) -> U) -> Trap/&self { unsafe { let p : *RustClosure = ::cast::transmute(&h); let prev = task::local_data::local_data_get(self.key); @@ -65,12 +65,12 @@ pub impl Condition/&self { } struct Trap { - cond: &self/Condition/&self, + cond: &'self Condition/&self, handler: @Handler } pub impl Trap/&self { - fn in(&self, inner: &self/fn() -> V) -> V { + fn in(&self, inner: &'self fn() -> V) -> V { unsafe { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS"); @@ -81,7 +81,7 @@ pub impl Trap/&self { } struct Guard { - cond: &self/Condition/&self + cond: &'self Condition/&self } impl Drop for Guard/&self { diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 828678b65f7..efcf1e26534 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -39,7 +39,7 @@ pub trait Map: Mutable { fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool); /// Return the value corresponding to the key in the map - pure fn find(&self, key: &K) -> Option<&self/V>; + pure fn find(&self, key: &K) -> Option<&'self V>; /// Insert a key-value pair into the map. An existing value for a /// key is replaced by the new value. Return true if the key did diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index 5f84f7f0d19..3449c5ff4ba 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -122,7 +122,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option { return None; } -type Visitor = &self/fn(root: **Word, tydesc: *Word) -> bool; +type Visitor = &'self fn(root: **Word, tydesc: *Word) -> bool; // Walks the list of roots for the given safe point, and calls visitor // on each root. diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index cc7dafad169..20d207e9302 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -185,7 +185,7 @@ pub mod linear { } #[inline(always)] - pure fn value_for_bucket(&self, idx: uint) -> &self/V { + pure fn value_for_bucket(&self, idx: uint) -> &'self V { match self.buckets[idx] { Some(ref bkt) => &bkt.value, None => fail!(~"LinearMap::find: internal logic error"), @@ -270,10 +270,10 @@ pub mod linear { } impl - BaseIter<(&self/K, &self/V)> for LinearMap + BaseIter<(&'self K, &'self V)> for LinearMap { /// Visit all key-value pairs - pure fn each(&self, blk: &fn(&(&self/K, &self/V)) -> bool) { + pure fn each(&self, blk: &fn(&(&'self K, &'self V)) -> bool) { for uint::range(0, self.buckets.len()) |i| { let mut broke = false; do self.buckets[i].map |bucket| { @@ -339,7 +339,7 @@ pub mod linear { } /// Return the value corresponding to the key in the map - pure fn find(&self, k: &K) -> Option<&self/V> { + pure fn find(&self, k: &K) -> Option<&'self V> { match self.bucket_for_key(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), TableFull | FoundHole(_) => None, @@ -412,7 +412,7 @@ pub mod linear { /// Return the value corresponding to the key in the map, or insert /// and return the value if it doesn't exist. - fn find_or_insert(&mut self, k: K, v: V) -> &self/V { + fn find_or_insert(&mut self, k: K, v: V) -> &'self V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is @@ -442,7 +442,7 @@ pub mod linear { /// Return the value corresponding to the key in the map, or create, /// insert, and return a new value if it doesn't exist. - fn find_or_insert_with(&mut self, k: K, f: &fn(&K) -> V) -> &self/V { + fn find_or_insert_with(&mut self, k: K, f: &fn(&K) -> V) -> &'self V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is @@ -487,7 +487,7 @@ pub mod linear { } } - pure fn get(&self, k: &K) -> &self/V { + pure fn get(&self, k: &K) -> &'self V { match self.find(k) { Some(v) => v, None => fail!(fmt!("No entry found for key: %?", k)), @@ -509,7 +509,7 @@ pub mod linear { /// Return the value corresponding to the key in the map, using /// equivalence pure fn find_equiv>(&self, k: &Q) - -> Option<&self/V> { + -> Option<&'self V> { match self.bucket_for_key_equiv(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), TableFull | FoundHole(_) => None, diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 4942b058785..dcb9e23b45b 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -589,7 +589,7 @@ pub fn file_reader(path: &Path) -> Result<@Reader, ~str> { // Byte readers pub struct BytesReader { - bytes: &self/[u8], + bytes: &'self [u8], mut pos: uint } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index e461cb2c65f..816dc6d2255 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -20,7 +20,7 @@ use option::{None, Option, Some}; use vec; /// A function used to initialize the elements of a sequence -pub type InitOp = &self/fn(uint) -> T; +pub type InitOp = &'self fn(uint) -> T; pub trait BaseIter { pure fn each(&self, blk: &fn(v: &A) -> bool); diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 1e3bba64f27..237fc762b3c 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -122,7 +122,7 @@ pub pure fn get(opt: Option) -> T { } #[inline(always)] -pub pure fn get_ref(opt: &r/Option) -> &r/T { +pub pure fn get_ref(opt: &'r Option) -> &'r T { /*! Gets an immutable reference to the value inside an option. @@ -143,7 +143,7 @@ pub pure fn get_ref(opt: &r/Option) -> &r/T { } } -pub pure fn get_mut_ref(opt: &r/mut Option) -> &r/mut T { +pub pure fn get_mut_ref(opt: &'r mut Option) -> &'r mut T { /*! Gets a mutable reference to the value inside an option. @@ -165,7 +165,7 @@ pub pure fn get_mut_ref(opt: &r/mut Option) -> &r/mut T { } #[inline(always)] -pub pure fn map(opt: &r/Option, f: &fn(x: &r/T) -> U) -> Option { +pub pure fn map(opt: &'r Option, f: &fn(x: &'r T) -> U) -> Option { //! Maps a `some` value by reference from one type to another match *opt { Some(ref x) => Some(f(x)), None => None } @@ -256,8 +256,8 @@ pub pure fn get_or_default(opt: Option, def: T) -> T { } #[inline(always)] -pub pure fn map_default(opt: &r/Option, def: U, - f: &fn(&r/T) -> U) -> U { +pub pure fn map_default(opt: &'r Option, def: U, + f: &fn(&'r T) -> U) -> U { //! Applies a function to the contained value or returns a default match *opt { None => def, Some(ref t) => f(t) } @@ -313,7 +313,7 @@ pub pure fn expect(opt: Option, reason: &str) -> T { impl BaseIter for Option { /// Performs an operation on the contained value by reference #[inline(always)] - pure fn each(&self, f: &fn(x: &self/T) -> bool) { + pure fn each(&self, f: &fn(x: &'self T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } } @@ -350,7 +350,7 @@ pub impl Option { /// Maps a `some` value from one type to another by reference #[inline(always)] - pure fn map(&self, f: &fn(&self/T) -> U) -> Option { map(self, f) } + pure fn map(&self, f: &fn(&'self T) -> U) -> Option { map(self, f) } /// As `map`, but consumes the option and gives `f` ownership to avoid /// copying. @@ -361,7 +361,7 @@ pub impl Option { /// Applies a function to the contained value or returns a default #[inline(always)] - pure fn map_default(&self, def: U, f: &fn(&self/T) -> U) -> U { + pure fn map_default(&self, def: U, f: &fn(&'self T) -> U) -> U { map_default(self, def, f) } @@ -403,7 +403,7 @@ pub impl Option { case explicitly. */ #[inline(always)] - pure fn get_ref(&self) -> &self/T { get_ref(self) } + pure fn get_ref(&self) -> &'self T { get_ref(self) } /** Gets a mutable reference to the value inside an option. @@ -420,7 +420,7 @@ pub impl Option { case explicitly. */ #[inline(always)] - pure fn get_mut_ref(&mut self) -> &self/mut T { get_mut_ref(self) } + pure fn get_mut_ref(&mut self) -> &'self mut T { get_mut_ref(self) } /** * Gets the value out of an option without copying. diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 746c403c7bf..17ec9df9d56 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1170,11 +1170,11 @@ pub mod consts { pub use os::consts::windows::*; pub mod unix { - pub const FAMILY: &static/str = "unix"; + pub const FAMILY: &'static str = "unix"; } pub mod windows { - pub const FAMILY: &static/str = "windows"; + pub const FAMILY: &'static str = "windows"; } #[cfg(target_os = "macos")] @@ -1193,38 +1193,38 @@ pub mod consts { pub use os::consts::win32::*; pub mod macos { - pub const SYSNAME: &static/str = "macos"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".dylib"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "macos"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".dylib"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod freebsd { - pub const SYSNAME: &static/str = "freebsd"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".so"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "freebsd"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod linux { - pub const SYSNAME: &static/str = "linux"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".so"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "linux"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod android { - pub const SYSNAME: &static/str = "android"; - pub const DLL_PREFIX: &static/str = "lib"; - pub const DLL_SUFFIX: &static/str = ".so"; - pub const EXE_SUFFIX: &static/str = ""; + pub const SYSNAME: &'static str = "android"; + pub const DLL_PREFIX: &'static str = "lib"; + pub const DLL_SUFFIX: &'static str = ".so"; + pub const EXE_SUFFIX: &'static str = ""; } pub mod win32 { - pub const SYSNAME: &static/str = "win32"; - pub const DLL_PREFIX: &static/str = ""; - pub const DLL_SUFFIX: &static/str = ".dll"; - pub const EXE_SUFFIX: &static/str = ".exe"; + pub const SYSNAME: &'static str = "win32"; + pub const DLL_PREFIX: &'static str = ""; + pub const DLL_SUFFIX: &'static str = ".dll"; + pub const EXE_SUFFIX: &'static str = ".exe"; } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index fd823e9dda0..eb385d90354 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -446,7 +446,7 @@ pub fn try_recv(p: RecvPacketBuffered) let p = unsafe { &*p_ }; struct DropState { - p: &self/PacketHeader, + p: &'self PacketHeader, drop { if task::failing() { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index e6e312d01b9..481a61f4ab7 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -178,7 +178,7 @@ pub pure fn to_uint(thing: &T) -> uint { /// Determine if two borrowed pointers point to the same thing. #[inline(always)] -pub pure fn ref_eq(thing: &a/T, other: &b/T) -> bool { +pub pure fn ref_eq(thing: &'a T, other: &'b T) -> bool { to_uint(thing) == to_uint(other) } @@ -312,34 +312,34 @@ impl Ord for *const T { // Equality for region pointers #[cfg(notest)] -impl Eq for &self/const T { +impl Eq for &'self const T { #[inline(always)] - pure fn eq(&self, other: & &self/const T) -> bool { + pure fn eq(&self, other: & &'self const T) -> bool { return *(*self) == *(*other); } #[inline(always)] - pure fn ne(&self, other: & &self/const T) -> bool { + pure fn ne(&self, other: & &'self const T) -> bool { return *(*self) != *(*other); } } // Comparison for region pointers #[cfg(notest)] -impl Ord for &self/const T { +impl Ord for &'self const T { #[inline(always)] - pure fn lt(&self, other: & &self/const T) -> bool { + pure fn lt(&self, other: & &'self const T) -> bool { *(*self) < *(*other) } #[inline(always)] - pure fn le(&self, other: & &self/const T) -> bool { + pure fn le(&self, other: & &'self const T) -> bool { *(*self) <= *(*other) } #[inline(always)] - pure fn ge(&self, other: & &self/const T) -> bool { + pure fn ge(&self, other: & &'self const T) -> bool { *(*self) >= *(*other) } #[inline(always)] - pure fn gt(&self, other: & &self/const T) -> bool { + pure fn gt(&self, other: & &'self const T) -> bool { *(*self) > *(*other) } } diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 30c46cd3e35..a0f9fa7e08e 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -214,9 +214,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_estr_slice(&self) -> bool { - self.align_to::<&static/str>(); + self.align_to::<&'static str>(); if ! self.inner.visit_estr_slice() { return false; } - self.bump_past::<&static/str>(); + self.bump_past::<&'static str>(); true } @@ -251,9 +251,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_rptr(&self, mtbl: uint, inner: *TyDesc) -> bool { - self.align_to::<&static/u8>(); + self.align_to::<&'static u8>(); if ! self.inner.visit_rptr(mtbl, inner) { return false; } - self.bump_past::<&static/u8>(); + self.bump_past::<&'static u8>(); true } @@ -285,9 +285,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_evec_slice(&self, mtbl: uint, inner: *TyDesc) -> bool { - self.align_to::<&static/[u8]>(); + self.align_to::<&'static [u8]>(); if ! self.inner.visit_evec_slice(mtbl, inner) { return false; } - self.bump_past::<&static/[u8]>(); + self.bump_past::<&'static [u8]>(); true } @@ -465,9 +465,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_self(&self) -> bool { - self.align_to::<&static/u8>(); + self.align_to::<&'static u8>(); if ! self.inner.visit_self() { return false; } - self.align_to::<&static/u8>(); + self.align_to::<&'static u8>(); true } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index e3fd279a996..832071a0ba8 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -53,7 +53,7 @@ pub pure fn get(res: &Result) -> T { * If the result is an error */ #[inline(always)] -pub pure fn get_ref(res: &a/Result) -> &a/T { +pub pure fn get_ref(res: &'a Result) -> &'a T { match *res { Ok(ref t) => t, Err(ref the_err) => unsafe { @@ -229,7 +229,7 @@ pub pure fn map_err(res: &Result, op: &fn(&E) -> F) pub impl Result { #[inline(always)] - pure fn get_ref(&self) -> &self/T { get_ref(self) } + pure fn get_ref(&self) -> &'self T { get_ref(self) } #[inline(always)] pure fn is_ok(&self) -> bool { is_ok(self) } diff --git a/src/libcore/rt/io.rs b/src/libcore/rt/io.rs index 3a94c01e0a4..55e062de85b 100644 --- a/src/libcore/rt/io.rs +++ b/src/libcore/rt/io.rs @@ -22,7 +22,7 @@ pub trait EventLoop { fn run(&mut self); fn callback(&mut self, ~fn()); /// The asynchronous I/O services. Not all event loops may provide one - fn io(&mut self) -> Option<&self/mut IoFactoryObject>; + fn io(&mut self) -> Option<&'self mut IoFactoryObject>; } pub trait IoFactory { diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs index 8f315452e5e..69cbbdd2ad4 100644 --- a/src/libcore/rt/sched.rs +++ b/src/libcore/rt/sched.rs @@ -265,12 +265,12 @@ pub impl Scheduler { } } - // XXX: Hack. This should return &self/mut but I don't know how to + // XXX: Hack. This should return &'self mut but I don't know how to // make the borrowcheck happy fn task_from_last_cleanup_job(&mut self) -> &mut Task { fail_unless!(!self.cleanup_jobs.is_empty()); - let last_job: &self/mut CleanupJob = &mut self.cleanup_jobs[0]; - let last_task: &self/Task = match last_job { + let last_job: &'self mut CleanupJob = &mut self.cleanup_jobs[0]; + let last_task: &'self Task = match last_job { &RescheduleTask(~ref task) => task, &RecycleTask(~ref task) => task, &GiveTask(~ref task, _) => task, @@ -356,7 +356,7 @@ impl ThreadLocalScheduler { } } - fn get_scheduler(&mut self) -> &self/mut Scheduler { + fn get_scheduler(&mut self) -> &'self mut Scheduler { unsafe { let key = match self { &ThreadLocalScheduler(key) => key }; let mut value: *mut c_void = tls::get(key); diff --git a/src/libcore/rt/uv.rs b/src/libcore/rt/uv.rs index c947e4dde4c..80224fa523a 100644 --- a/src/libcore/rt/uv.rs +++ b/src/libcore/rt/uv.rs @@ -659,7 +659,7 @@ fn install_watcher_data>(watcher: &mut W) { } fn get_watcher_data>( - watcher: &r/mut W) -> &r/mut WatcherData { + watcher: &'r mut W) -> &'r mut WatcherData { unsafe { let data = uvll::get_data_for_uv_handle(watcher.native_handle()); diff --git a/src/libcore/rt/uvio.rs b/src/libcore/rt/uvio.rs index f7275652e7f..a971ed92b7e 100644 --- a/src/libcore/rt/uvio.rs +++ b/src/libcore/rt/uvio.rs @@ -69,7 +69,7 @@ impl EventLoop for UvEventLoop { } } - fn io(&mut self) -> Option<&self/mut IoFactoryObject> { + fn io(&mut self) -> Option<&'self mut IoFactoryObject> { Some(&mut self.uvio) } } @@ -91,7 +91,7 @@ fn test_callback_run_once() { pub struct UvIoFactory(Loop); pub impl UvIoFactory { - fn uv_loop(&mut self) -> &self/mut Loop { + fn uv_loop(&mut self) -> &'self mut Loop { match self { &UvIoFactory(ref mut ptr) => ptr } } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 23b14e243b8..3d591af6d3c 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -279,7 +279,7 @@ pub fn shift_char(s: &mut ~str) -> char { * If the string does not contain any characters */ #[inline] -pub fn view_shift_char(s: &a/str) -> (char, &a/str) { +pub fn view_shift_char(s: &'a str) -> (char, &'a str) { let CharRange {ch, next} = char_range_at(s, 0u); let next_s = unsafe { raw::view_bytes(s, next, len(s)) }; return (ch, next_s); @@ -429,7 +429,7 @@ pub pure fn slice(s: &str, begin: uint, end: uint) -> ~str { * Fails when `begin` and `end` do not point to valid characters or beyond * the last character of the string */ -pub pure fn view(s: &a/str, begin: uint, end: uint) -> &a/str { +pub pure fn view(s: &'a str, begin: uint, end: uint) -> &'a str { fail_unless!(is_char_boundary(s, begin)); fail_unless!(is_char_boundary(s, end)); unsafe { raw::view_bytes(s, begin, end) } @@ -530,7 +530,7 @@ pure fn split_inner(s: &str, sepfn: &fn(cc: char) -> bool, count: uint, } // See Issue #1932 for why this is a naive search -pure fn iter_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { +pure fn iter_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { let sep_len = len(sep), l = len(s); fail_unless!(sep_len > 0u); let mut i = 0u, match_start = 0u, match_i = 0u; @@ -557,7 +557,7 @@ pure fn iter_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { } } -pure fn iter_between_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { +pure fn iter_between_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { let mut last_end = 0u; do iter_matches(s, sep) |from, to| { f(last_end, from); @@ -575,7 +575,7 @@ pure fn iter_between_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { * fail_unless!(["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".")) * ~~~ */ -pub pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] { +pub pure fn split_str(s: &'a str, sep: &'b str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { unsafe { result.push(raw::slice_bytes(s, from, to)); } @@ -583,7 +583,7 @@ pub pure fn split_str(s: &a/str, sep: &b/str) -> ~[~str] { result } -pub pure fn split_str_nonempty(s: &a/str, sep: &b/str) -> ~[~str] { +pub pure fn split_str_nonempty(s: &'a str, sep: &'b str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { if to > from { @@ -792,7 +792,7 @@ pure fn cmp(a: &str, b: &str) -> Ordering { #[cfg(notest)] impl TotalOrd for &'self str { - pure fn cmp(&self, other: & &self/str) -> Ordering { cmp(*self, *other) } + pure fn cmp(&self, other: & &'self str) -> Ordering { cmp(*self, *other) } } #[cfg(notest)] @@ -837,13 +837,13 @@ pure fn gt(a: &str, b: &str) -> bool { } #[cfg(notest)] -impl Eq for &self/str { +impl Eq for &'self str { #[inline(always)] - pure fn eq(&self, other: & &self/str) -> bool { + pure fn eq(&self, other: & &'self str) -> bool { eq_slice((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: & &self/str) -> bool { !(*self).eq(other) } + pure fn ne(&self, other: & &'self str) -> bool { !(*self).eq(other) } } #[cfg(notest)] @@ -879,15 +879,15 @@ impl Ord for ~str { } #[cfg(notest)] -impl Ord for &self/str { +impl Ord for &'self str { #[inline(always)] - pure fn lt(&self, other: & &self/str) -> bool { lt((*self), (*other)) } + pure fn lt(&self, other: & &'self str) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: & &self/str) -> bool { le((*self), (*other)) } + pure fn le(&self, other: & &'self str) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: & &self/str) -> bool { ge((*self), (*other)) } + pure fn ge(&self, other: & &'self str) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: & &self/str) -> bool { gt((*self), (*other)) } + pure fn gt(&self, other: & &'self str) -> bool { gt((*self), (*other)) } } #[cfg(notest)] @@ -1348,7 +1348,7 @@ pub pure fn rfind_between(s: &str, start: uint, end: uint, } // Utility used by various searching functions -pure fn match_at(haystack: &a/str, needle: &b/str, at: uint) -> bool { +pure fn match_at(haystack: &'a str, needle: &'b str, at: uint) -> bool { let mut i = at; for each(needle) |c| { if haystack[i] != c { return false; } i += 1u; } return true; @@ -1367,7 +1367,7 @@ pure fn match_at(haystack: &a/str, needle: &b/str, at: uint) -> bool { * An `option` containing the byte index of the first matching substring * or `none` if there is no match */ -pub pure fn find_str(haystack: &a/str, needle: &b/str) -> Option { +pub pure fn find_str(haystack: &'a str, needle: &'b str) -> Option { find_str_between(haystack, needle, 0u, len(haystack)) } @@ -1390,7 +1390,7 @@ pub pure fn find_str(haystack: &a/str, needle: &b/str) -> Option { * * `start` must be less than or equal to `len(s)` */ -pub pure fn find_str_from(haystack: &a/str, needle: &b/str, start: uint) +pub pure fn find_str_from(haystack: &'a str, needle: &'b str, start: uint) -> Option { find_str_between(haystack, needle, start, len(haystack)) } @@ -1415,7 +1415,7 @@ pub pure fn find_str_from(haystack: &a/str, needle: &b/str, start: uint) * `start` must be less than or equal to `end` and `end` must be less than * or equal to `len(s)`. */ -pub pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint, +pub pure fn find_str_between(haystack: &'a str, needle: &'b str, start: uint, end:uint) -> Option { // See Issue #1932 for why this is a naive search @@ -1441,7 +1441,7 @@ pub pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint, * * haystack - The string to look in * * needle - The string to look for */ -pub pure fn contains(haystack: &a/str, needle: &b/str) -> bool { +pub pure fn contains(haystack: &'a str, needle: &'b str) -> bool { find_str(haystack, needle).is_some() } @@ -1465,7 +1465,7 @@ pub pure fn contains_char(haystack: &str, needle: char) -> bool { * * haystack - The string to look in * * needle - The string to look for */ -pub pure fn starts_with(haystack: &a/str, needle: &b/str) -> bool { +pub pure fn starts_with(haystack: &'a str, needle: &'b str) -> bool { let haystack_len = len(haystack), needle_len = len(needle); if needle_len == 0u { true } else if needle_len > haystack_len { false } @@ -1480,7 +1480,7 @@ pub pure fn starts_with(haystack: &a/str, needle: &b/str) -> bool { * * haystack - The string to look in * * needle - The string to look for */ -pub pure fn ends_with(haystack: &a/str, needle: &b/str) -> bool { +pub pure fn ends_with(haystack: &'a str, needle: &'b str) -> bool { let haystack_len = len(haystack), needle_len = len(needle); if needle_len == 0u { true } else if needle_len > haystack_len { false } @@ -1662,7 +1662,7 @@ pub pure fn count_chars(s: &str, start: uint, end: uint) -> uint { } /// Counts the number of bytes taken by the `n` in `s` starting from `start`. -pub pure fn count_bytes(s: &b/str, start: uint, n: uint) -> uint { +pub pure fn count_bytes(s: &'b str, start: uint, n: uint) -> uint { fail_unless!(is_char_boundary(s, start)); let mut end = start, cnt = n; let l = len(s); @@ -1905,7 +1905,7 @@ pub pure fn as_bytes(s: &const ~str, f: &fn(&~[u8]) -> T) -> T { * * The byte slice does not include the null terminator. */ -pub pure fn as_bytes_slice(s: &a/str) -> &a/[u8] { +pub pure fn as_bytes_slice(s: &'a str) -> &'a [u8] { unsafe { let (ptr, len): (*u8, uint) = ::cast::reinterpret_cast(&s); let outgoing_tuple: (*u8, uint) = (ptr, len - 1); @@ -2233,9 +2233,9 @@ pub mod traits { use ops::Add; use str::append; - impl Add<&self/str,~str> for ~str { + impl Add<&'self str,~str> for ~str { #[inline(always)] - pure fn add(&self, rhs: & &self/str) -> ~str { + pure fn add(&self, rhs: & &'self str) -> ~str { append(copy *self, (*rhs)) } } @@ -2247,7 +2247,7 @@ pub mod traits {} pub trait StrSlice { pure fn all(&self, it: &fn(char) -> bool) -> bool; pure fn any(&self, it: &fn(char) -> bool) -> bool; - pure fn contains(&self, needle: &a/str) -> bool; + pure fn contains(&self, needle: &'a str) -> bool; pure fn contains_char(&self, needle: char) -> bool; pure fn each(&self, it: &fn(u8) -> bool); pure fn eachi(&self, it: &fn(uint, u8) -> bool); @@ -2261,8 +2261,8 @@ pub trait StrSlice { pure fn slice(&self, begin: uint, end: uint) -> ~str; pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str]; pure fn split_char(&self, sep: char) -> ~[~str]; - pure fn split_str(&self, sep: &a/str) -> ~[~str]; - pure fn starts_with(&self, needle: &a/str) -> bool; + pure fn split_str(&self, sep: &'a str) -> ~[~str]; + pure fn starts_with(&self, needle: &'a str) -> bool; pure fn substr(&self, begin: uint, n: uint) -> ~str; pure fn to_lower(&self) -> ~str; pure fn to_upper(&self) -> ~str; @@ -2278,7 +2278,7 @@ pub trait StrSlice { } /// Extension methods for strings -impl StrSlice for &self/str { +impl StrSlice for &'self str { /** * Return true if a predicate matches all characters or if the string * contains no characters @@ -2293,7 +2293,7 @@ impl StrSlice for &self/str { pure fn any(&self, it: &fn(char) -> bool) -> bool { any(*self, it) } /// Returns true if one string contains another #[inline] - pure fn contains(&self, needle: &a/str) -> bool { + pure fn contains(&self, needle: &'a str) -> bool { contains(*self, needle) } /// Returns true if a string contains a char @@ -2366,10 +2366,10 @@ impl StrSlice for &self/str { * string */ #[inline] - pure fn split_str(&self, sep: &a/str) -> ~[~str] { split_str(*self, sep) } + pure fn split_str(&self, sep: &'a str) -> ~[~str] { split_str(*self, sep) } /// Returns true if one string starts with another #[inline] - pure fn starts_with(&self, needle: &a/str) -> bool { + pure fn starts_with(&self, needle: &'a str) -> bool { starts_with(*self, needle) } /** @@ -2612,8 +2612,8 @@ mod tests { #[test] fn test_split_str() { - fn t(s: &str, sep: &a/str, i: int, k: &str) { - fn borrow(x: &a/str) -> &a/str { x } + fn t(s: &str, sep: &'a str, i: int, k: &str) { + fn borrow(x: &'a str) -> &'a str { x } let v = split_str(s, sep); fail_unless!(borrow(v[i]) == k); } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index 179a33ae43e..f7eceeebc1e 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -19,7 +19,7 @@ use libc::{c_void, c_char, size_t}; use repr; use str; -pub type FreeGlue = &self/fn(*TypeDesc, *c_void); +pub type FreeGlue = &'self fn(*TypeDesc, *c_void); // Corresponds to runtime type_desc type pub struct TypeDesc { diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 690b3aedc5a..ccd91709479 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -44,7 +44,7 @@ use task::rt; * * These two cases aside, the interface is safe. */ -pub type LocalDataKey = &self/fn(v: @T); +pub type LocalDataKey = &'self fn(v: @T); /** * Remove a task-local data value from the table, returning the diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index a0db2525441..0fd373b803f 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -123,7 +123,7 @@ struct TaskGroupData { } type TaskGroupArc = unstable::Exclusive>; -type TaskGroupInner = &self/mut Option; +type TaskGroupInner = &'self mut Option; // A taskgroup is 'dead' when nothing can cause it to fail; only members can. pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index 60665bcddf6..e5fbad16717 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -19,7 +19,7 @@ use io::Writer; use option::{None, Option, Some}; use str; -pub type Cb = &self/fn(buf: &[const u8]) -> bool; +pub type Cb = &'self fn(buf: &[const u8]) -> bool; /** * A trait to implement in order to make a type hashable; @@ -197,7 +197,7 @@ impl IterBytes for int { } } -impl IterBytes for &self/[A] { +impl IterBytes for &'self [A] { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { for (*self).each |elt| { @@ -231,7 +231,7 @@ impl IterBytes for (A,B,C) { } // Move this to vec, probably. -pure fn borrow(a: &x/[A]) -> &x/[A] { +pure fn borrow(a: &'x [A]) -> &'x [A] { a } @@ -352,7 +352,7 @@ pub pure fn iter_bytes_7 IterBytes for Option { } } -impl IterBytes for &self/A { +impl IterBytes for &'self A { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 8215152ef74..0f2fd699604 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -32,7 +32,7 @@ impl ToStr for ~str { #[inline(always)] pure fn to_str(&self) -> ~str { copy *self } } -impl ToStr for &self/str { +impl ToStr for &'self str { #[inline(always)] pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } } @@ -72,7 +72,7 @@ impl ToStr for (A, B, C) { } } -impl ToStr for &self/[A] { +impl ToStr for &'self [A] { #[inline(always)] pure fn to_str(&self) -> ~str { unsafe { diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 15b0e160434..26532c1a4ff 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -32,7 +32,7 @@ pub struct TrieMap { impl BaseIter<(uint, &'self T)> for TrieMap { /// Visit all key-value pairs in order #[inline(always)] - pure fn each(&self, f: &fn(&(uint, &self/T)) -> bool) { + pure fn each(&self, f: &fn(&(uint, &'self T)) -> bool) { self.root.each(f); } #[inline(always)] @@ -42,7 +42,7 @@ impl BaseIter<(uint, &'self T)> for TrieMap { impl ReverseIter<(uint, &'self T)> for TrieMap { /// Visit all key-value pairs in reverse order #[inline(always)] - pure fn each_reverse(&self, f: &fn(&(uint, &self/T)) -> bool) { + pure fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) { self.root.each_reverse(f); } } @@ -93,8 +93,8 @@ impl Map for TrieMap { /// Return the value corresponding to the key in the map #[inline(hint)] - pure fn find(&self, key: &uint) -> Option<&self/T> { - let mut node: &self/TrieNode = &self.root; + pure fn find(&self, key: &uint) -> Option<&'self T> { + let mut node: &'self TrieNode = &self.root; let mut idx = 0; loop { match node.children[chunk(*key, idx)] { @@ -233,7 +233,7 @@ impl TrieNode { } impl TrieNode { - pure fn each(&self, f: &fn(&(uint, &self/T)) -> bool) -> bool { + pure fn each(&self, f: &fn(&(uint, &'self T)) -> bool) -> bool { for uint::range(0, self.children.len()) |idx| { match self.children[idx] { Internal(ref x) => if !x.each(f) { return false }, @@ -244,7 +244,7 @@ impl TrieNode { true } - pure fn each_reverse(&self, f: &fn(&(uint, &self/T)) -> bool) -> bool { + pure fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) -> bool { for uint::range_rev(self.children.len(), 0) |idx| { match self.children[idx - 1] { Internal(ref x) => if !x.each_reverse(f) { return false }, diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index e41ff424012..b4f68466c27 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -47,19 +47,19 @@ impl CopyableTuple for (T, U) { } pub trait ImmutableTuple { - pure fn first_ref(&self) -> &self/T; - pure fn second_ref(&self) -> &self/U; + pure fn first_ref(&self) -> &'self T; + pure fn second_ref(&self) -> &'self U; } impl ImmutableTuple for (T, U) { #[inline(always)] - pure fn first_ref(&self) -> &self/T { + pure fn first_ref(&self) -> &'self T { match *self { (ref t, _) => t, } } #[inline(always)] - pure fn second_ref(&self) -> &self/U { + pure fn second_ref(&self) -> &'self U { match *self { (_, ref u) => u, } @@ -71,7 +71,7 @@ pub trait ExtendedTupleOps { fn map(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C]; } -impl ExtendedTupleOps for (&self/[A], &self/[B]) { +impl ExtendedTupleOps for (&'self [A], &'self [B]) { #[inline(always)] fn zip(&self) -> ~[(A, B)] { match *self { diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs index 9b6dcc31234..899d01cd996 100644 --- a/src/libcore/unstable.rs +++ b/src/libcore/unstable.rs @@ -173,7 +173,7 @@ pub unsafe fn get_shared_mutable_state( } #[inline(always)] pub unsafe fn get_shared_immutable_state( - rc: &a/SharedMutableState) -> &a/T { + rc: &'a SharedMutableState) -> &'a T { unsafe { let ptr: ~ArcData = cast::reinterpret_cast(&(*rc).data); fail_unless!(ptr.count > 0); diff --git a/src/libcore/unstable/finally.rs b/src/libcore/unstable/finally.rs index 5089470e6ef..e8c27ff7d92 100644 --- a/src/libcore/unstable/finally.rs +++ b/src/libcore/unstable/finally.rs @@ -31,7 +31,7 @@ pub trait Finally { fn finally(&self, dtor: &fn()) -> T; } -impl Finally for &self/fn() -> T { +impl Finally for &'self fn() -> T { fn finally(&self, dtor: &fn()) -> T { let _d = Finallyalizer { dtor: dtor @@ -42,7 +42,7 @@ impl Finally for &self/fn() -> T { } struct Finallyalizer { - dtor: &self/fn() + dtor: &'self fn() } impl Drop for Finallyalizer/&self { diff --git a/src/libcore/unstable/global.rs b/src/libcore/unstable/global.rs index d8ded635291..66033605559 100644 --- a/src/libcore/unstable/global.rs +++ b/src/libcore/unstable/global.rs @@ -42,7 +42,7 @@ use sys::Closure; #[cfg(test)] use task::spawn; #[cfg(test)] use uint; -pub type GlobalDataKey = &self/fn(v: T); +pub type GlobalDataKey = &'self fn(v: T); pub unsafe fn global_data_clone_create( key: GlobalDataKey, create: &fn() -> ~T) -> T { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index f11a63a787d..34d3c022dca 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -217,46 +217,46 @@ pub pure fn build_sized_opt(size: Option, // Accessors /// Returns the first element of a vector -pub pure fn head(v: &r/[T]) -> &r/T { +pub pure fn head(v: &'r [T]) -> &'r T { if v.len() == 0 { fail!(~"head: empty vector") } &v[0] } /// Returns `Some(x)` where `x` is the first element of the slice `v`, /// or `None` if the vector is empty. -pub pure fn head_opt(v: &r/[T]) -> Option<&r/T> { +pub pure fn head_opt(v: &'r [T]) -> Option<&'r T> { if v.len() == 0 { None } else { Some(&v[0]) } } /// Returns a vector containing all but the first element of a slice -pub pure fn tail(v: &r/[T]) -> &r/[T] { slice(v, 1, v.len()) } +pub pure fn tail(v: &'r [T]) -> &'r [T] { slice(v, 1, v.len()) } /// Returns a vector containing all but the first `n` elements of a slice -pub pure fn tailn(v: &r/[T], n: uint) -> &r/[T] { slice(v, n, v.len()) } +pub pure fn tailn(v: &'r [T], n: uint) -> &'r [T] { slice(v, n, v.len()) } /// Returns a vector containing all but the last element of a slice -pub pure fn init(v: &r/[T]) -> &r/[T] { slice(v, 0, v.len() - 1) } +pub pure fn init(v: &'r [T]) -> &'r [T] { slice(v, 0, v.len() - 1) } /// Returns a vector containing all but the last `n' elements of a slice -pub pure fn initn(v: &r/[T], n: uint) -> &r/[T] { +pub pure fn initn(v: &'r [T], n: uint) -> &'r [T] { slice(v, 0, v.len() - n) } /// Returns the last element of the slice `v`, failing if the slice is empty. -pub pure fn last(v: &r/[T]) -> &r/T { +pub pure fn last(v: &'r [T]) -> &'r T { if v.len() == 0 { fail!(~"last: empty vector") } &v[v.len() - 1] } /// Returns `Some(x)` where `x` is the last element of the slice `v`, or /// `None` if the vector is empty. -pub pure fn last_opt(v: &r/[T]) -> Option<&r/T> { +pub pure fn last_opt(v: &'r [T]) -> Option<&'r T> { if v.len() == 0 { None } else { Some(&v[v.len() - 1]) } } /// Return a slice that points into another slice. #[inline(always)] -pub pure fn slice(v: &r/[T], start: uint, end: uint) -> &r/[T] { +pub pure fn slice(v: &'r [T], start: uint, end: uint) -> &'r [T] { fail_unless!(start <= end); fail_unless!(end <= len(v)); do as_imm_buf(v) |p, _len| { @@ -270,10 +270,10 @@ pub pure fn slice(v: &r/[T], start: uint, end: uint) -> &r/[T] { /// Return a slice that points into another slice. #[inline(always)] -pub pure fn mut_slice(v: &r/mut [T], +pub pure fn mut_slice(v: &'r mut [T], start: uint, end: uint) - -> &r/mut [T] { + -> &'r mut [T] { fail_unless!(start <= end); fail_unless!(end <= v.len()); do as_mut_buf(v) |p, _len| { @@ -287,10 +287,10 @@ pub pure fn mut_slice(v: &r/mut [T], /// Return a slice that points into another slice. #[inline(always)] -pub pure fn const_slice(v: &r/[const T], +pub pure fn const_slice(v: &'r [const T], start: uint, end: uint) - -> &r/[const T] { + -> &'r [const T] { fail_unless!(start <= end); fail_unless!(end <= len(v)); do as_const_buf(v) |p, _len| { @@ -1334,7 +1334,7 @@ pub pure fn reversed(v: &[const T]) -> ~[T] { * ~~~ */ #[inline(always)] -pub pure fn each(v: &r/[T], f: &fn(&r/T) -> bool) { +pub pure fn each(v: &'r [T], f: &fn(&'r T) -> bool) { // ^^^^ // NB---this CANNOT be &[const T]! The reason // is that you are passing it to `f()` using @@ -1389,7 +1389,7 @@ pub pure fn each_const(v: &[const T], f: &fn(elem: &const T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn eachi(v: &r/[T], f: &fn(uint, v: &r/T) -> bool) { +pub pure fn eachi(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) { let mut i = 0; for each(v) |p| { if !f(i, p) { return; } @@ -1403,7 +1403,7 @@ pub pure fn eachi(v: &r/[T], f: &fn(uint, v: &r/T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn rev_each(v: &r/[T], blk: &fn(v: &r/T) -> bool) { +pub pure fn rev_each(v: &'r [T], blk: &fn(v: &'r T) -> bool) { rev_eachi(v, |_i, v| blk(v)) } @@ -1413,7 +1413,7 @@ pub pure fn rev_each(v: &r/[T], blk: &fn(v: &r/T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn rev_eachi(v: &r/[T], blk: &fn(i: uint, v: &r/T) -> bool) { +pub pure fn rev_eachi(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) { let mut i = v.len(); while i > 0 { i -= 1; @@ -1555,11 +1555,11 @@ pure fn eq(a: &[T], b: &[T]) -> bool { } #[cfg(notest)] -impl Eq for &self/[T] { +impl Eq for &'self [T] { #[inline(always)] - pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) } + pure fn eq(&self, other: & &'self [T]) -> bool { eq((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: & &self/[T]) -> bool { !(*self).eq(other) } + pure fn ne(&self, other: & &'self [T]) -> bool { !(*self).eq(other) } } @@ -1604,7 +1604,7 @@ pure fn cmp(a: &[T], b: &[T]) -> Ordering { #[cfg(notest)] impl TotalOrd for &'self [T] { #[inline(always)] - pure fn cmp(&self, other: & &self/[T]) -> Ordering { cmp(*self, *other) } + pure fn cmp(&self, other: & &'self [T]) -> Ordering { cmp(*self, *other) } } #[cfg(notest)] @@ -1639,15 +1639,15 @@ pure fn ge(a: &[T], b: &[T]) -> bool { !lt(a, b) } pure fn gt(a: &[T], b: &[T]) -> bool { lt(b, a) } #[cfg(notest)] -impl Ord for &self/[T] { +impl Ord for &'self [T] { #[inline(always)] - pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) } + pure fn lt(&self, other: & &'self [T]) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: & &self/[T]) -> bool { le((*self), (*other)) } + pure fn le(&self, other: & &'self [T]) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: & &self/[T]) -> bool { ge((*self), (*other)) } + pure fn ge(&self, other: & &'self [T]) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: & &self/[T]) -> bool { gt((*self), (*other)) } + pure fn gt(&self, other: & &'self [T]) -> bool { gt((*self), (*other)) } } #[cfg(notest)] @@ -1680,15 +1680,15 @@ pub mod traits { use ops::Add; use vec::append; - impl Add<&self/[const T],~[T]> for ~[T] { + impl Add<&'self [const T],~[T]> for ~[T] { #[inline(always)] - pure fn add(&self, rhs: & &self/[const T]) -> ~[T] { + pure fn add(&self, rhs: & &'self [const T]) -> ~[T] { append(copy *self, (*rhs)) } } } -impl Container for &self/[const T] { +impl Container for &'self [const T] { /// Returns true if a vector contains no elements #[inline] pure fn is_empty(&self) -> bool { is_empty(*self) } @@ -1712,15 +1712,15 @@ impl CopyableVector for &'self [const T] { } pub trait ImmutableVector { - pure fn view(&self, start: uint, end: uint) -> &self/[T]; - pure fn head(&self) -> &self/T; - pure fn head_opt(&self) -> Option<&self/T>; - pure fn tail(&self) -> &self/[T]; - pure fn tailn(&self, n: uint) -> &self/[T]; - pure fn init(&self) -> &self/[T]; - pure fn initn(&self, n: uint) -> &self/[T]; - pure fn last(&self) -> &self/T; - pure fn last_opt(&self) -> Option<&self/T>; + pure fn view(&self, start: uint, end: uint) -> &'self [T]; + pure fn head(&self) -> &'self T; + pure fn head_opt(&self) -> Option<&'self T>; + pure fn tail(&self) -> &'self [T]; + pure fn tailn(&self, n: uint) -> &'self [T]; + pure fn init(&self) -> &'self [T]; + pure fn initn(&self, n: uint) -> &'self [T]; + pure fn last(&self) -> &'self T; + pure fn last_opt(&self) -> Option<&'self T>; pure fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; pure fn map(&self, f: &fn(t: &T) -> U) -> ~[U]; pure fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; @@ -1731,44 +1731,44 @@ pub trait ImmutableVector { } /// Extension methods for vectors -impl ImmutableVector for &self/[T] { +impl ImmutableVector for &'self [T] { /// Return a slice that points into another slice. #[inline] - pure fn view(&self, start: uint, end: uint) -> &self/[T] { + pure fn view(&self, start: uint, end: uint) -> &'self [T] { slice(*self, start, end) } /// Returns the first element of a vector, failing if the vector is empty. #[inline] - pure fn head(&self) -> &self/T { head(*self) } + pure fn head(&self) -> &'self T { head(*self) } /// Returns the first element of a vector #[inline] - pure fn head_opt(&self) -> Option<&self/T> { head_opt(*self) } + pure fn head_opt(&self) -> Option<&'self T> { head_opt(*self) } /// Returns all but the first element of a vector #[inline] - pure fn tail(&self) -> &self/[T] { tail(*self) } + pure fn tail(&self) -> &'self [T] { tail(*self) } /// Returns all but the first `n' elements of a vector #[inline] - pure fn tailn(&self, n: uint) -> &self/[T] { tailn(*self, n) } + pure fn tailn(&self, n: uint) -> &'self [T] { tailn(*self, n) } /// Returns all but the last elemnt of a vector #[inline] - pure fn init(&self) -> &self/[T] { init(*self) } + pure fn init(&self) -> &'self [T] { init(*self) } /// Returns all but the last `n' elemnts of a vector #[inline] - pure fn initn(&self, n: uint) -> &self/[T] { initn(*self, n) } + pure fn initn(&self, n: uint) -> &'self [T] { initn(*self, n) } /// Returns the last element of a `v`, failing if the vector is empty. #[inline] - pure fn last(&self) -> &self/T { last(*self) } + pure fn last(&self) -> &'self T { last(*self) } /// Returns the last element of a `v`, failing if the vector is empty. #[inline] - pure fn last_opt(&self) -> Option<&self/T> { last_opt(*self) } + pure fn last_opt(&self) -> Option<&'self T> { last_opt(*self) } /// Reduce a vector from right to left #[inline] @@ -1834,7 +1834,7 @@ pub trait ImmutableEqVector { pure fn rposition_elem(&self, t: &T) -> Option; } -impl ImmutableEqVector for &self/[T] { +impl ImmutableEqVector for &'self [T] { /** * Find the first index matching some predicate * @@ -1879,7 +1879,7 @@ pub trait ImmutableCopyableVector { } /// Extension methods for vectors -impl ImmutableCopyableVector for &self/[T] { +impl ImmutableCopyableVector for &'self [T] { /** * Construct a new vector from the elements of a vector for which some * predicate holds. @@ -2139,7 +2139,7 @@ pub mod raw { len: uint, f: &fn(v: &[T]) -> U) -> U { let pair = (p, len * sys::nonzero_size_of::()); - let v : *(&blk/[T]) = + let v : *(&'blk [T]) = ::cast::reinterpret_cast(&addr_of(&pair)); f(*v) } @@ -2153,7 +2153,7 @@ pub mod raw { len: uint, f: &fn(v: &mut [T]) -> U) -> U { let pair = (p, len * sys::nonzero_size_of::()); - let v : *(&blk/mut [T]) = + let v : *(&'blk mut [T]) = ::cast::reinterpret_cast(&addr_of(&pair)); f(*v) } @@ -2327,7 +2327,7 @@ impl iter::MutableIter for @mut [A] { } } -impl iter::ExtendedIter for &self/[A] { +impl iter::ExtendedIter for &'self [A] { pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } @@ -2404,7 +2404,7 @@ impl iter::ExtendedIter for @[A] { } } -impl iter::EqIter for &self/[A] { +impl iter::EqIter for &'self [A] { pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } @@ -2421,7 +2421,7 @@ impl iter::EqIter for @[A] { pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } -impl iter::CopyableIter for &self/[A] { +impl iter::CopyableIter for &'self [A] { pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } @@ -2453,7 +2453,7 @@ impl iter::CopyableIter for @[A] { } } -impl iter::CopyableOrderedIter for &self/[A] { +impl iter::CopyableOrderedIter for &'self [A] { pure fn min(&self) -> A { iter::min(self) } pure fn max(&self) -> A { iter::max(self) } } @@ -2470,7 +2470,7 @@ impl iter::CopyableOrderedIter for @[A] { pure fn max(&self) -> A { iter::max(self) } } -impl iter::CopyableNonstrictIter for &self/[A] { +impl iter::CopyableNonstrictIter for &'self [A] { pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { diff --git a/src/librust/rust.rc b/src/librust/rust.rc index 8fd9fea6bae..3ca4ef5efbd 100644 --- a/src/librust/rust.rc +++ b/src/librust/rust.rc @@ -38,23 +38,23 @@ impl ValidUsage { } enum Action { - Exec(&self/str), - Call(&self/fn(args: &[~str]) -> ValidUsage) + Exec(&'self str), + Call(&'self fn(args: &[~str]) -> ValidUsage) } enum UsageSource { - UsgExec(&self/str), - UsgStr(&self/str) + UsgExec(&'self str), + UsgStr(&'self str) } struct Command { - cmd: &self/str, + cmd: &'self str, action: Action/&self, - usage_line: &self/str, + usage_line: &'self str, usage_full: UsageSource/&self } -const commands: &static/[Command/&static] = &[ +const commands: &'static [Command/&static] = &[ Command{ cmd: "build", action: Exec("rustc"), diff --git a/src/librustc/front/core_inject.rs b/src/librustc/front/core_inject.rs index b53303c5983..0766dcd2450 100644 --- a/src/librustc/front/core_inject.rs +++ b/src/librustc/front/core_inject.rs @@ -19,7 +19,7 @@ use syntax::codemap; use syntax::codemap::dummy_sp; use syntax::fold; -const CORE_VERSION: &static/str = "0.6"; +const CORE_VERSION: &'static str = "0.6"; pub fn maybe_inject_libcore_ref(sess: Session, crate: @ast::crate) -> @ast::crate { diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 48db758ef42..ddbac4085a7 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -257,7 +257,7 @@ mod __test { std::test::test_main_static(::os::args(), tests) } - const tests : &static/[std::test::TestDescAndFn] = &[ + const tests : &'static [std::test::TestDescAndFn] = &[ ... the list of tests in the crate ... ]; } @@ -352,7 +352,7 @@ fn path_node_global(+ids: ~[ast::ident]) -> @ast::path { types: ~[] } } - +#[cfg(stage0)] fn mk_tests(cx: &TestCtxt) -> @ast::item { let ext_cx = cx.ext_cx; @@ -367,6 +367,22 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item { )).get() } +#[cfg(stage1)] +#[cfg(stage2)] +fn mk_tests(cx: &TestCtxt) -> @ast::item { + + let ext_cx = cx.ext_cx; + + // The vector of test_descs for this crate + let test_descs = mk_test_descs(cx); + + (quote_item!( + pub const tests : &'static [self::std::test::TestDescAndFn] = + $test_descs + ; + )).get() +} + fn is_std(cx: &TestCtxt) -> bool { let is_std = { let items = attr::find_linkage_metas(cx.crate.node.attrs); diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 658b32edf21..1864e1c06ae 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -66,7 +66,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: &fn(x:&[u8]) -> bool, hash: uint) -> None } -pub type GetCrateDataCb = &self/fn(ast::crate_num) -> cmd; +pub type GetCrateDataCb = &'self fn(ast::crate_num) -> cmd; pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option { fn eq_item(bytes: &[u8], item_id: int) -> bool { @@ -544,7 +544,7 @@ pub fn get_item_path(intr: @ident_interner, cdata: cmd, id: ast::node_id) item_path(intr, lookup_item(id, cdata.data)) } -pub type decode_inlined_item = &self/fn( +pub type decode_inlined_item = &'self fn( cdata: @cstore::crate_metadata, tcx: ty::ctxt, path: ast_map::path, diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 4b1260e76d0..efbde04d68e 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -1291,7 +1291,7 @@ fn encode_hash(ebml_w: writer::Encoder, hash: &str) { } // NB: Increment this as you change the metadata encoding version. -pub const metadata_encoding_version : &static/[u8] = +pub const metadata_encoding_version : &'static [u8] = &[0x72, //'r' as u8, 0x75, //'u' as u8, 0x73, //'s' as u8, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 02203222e05..ad5b0274c0d 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -21,7 +21,7 @@ use core::result::Result; use core::result; use core::str; -pub type pick = &self/fn(path: &Path) -> Option; +pub type pick = &'self fn(path: &Path) -> Option; pub fn pick_file(file: Path, path: &Path) -> Option { if path.file_path() == file { option::Some(copy *path) } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index e9cbd2685df..c87b09cde08 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -49,7 +49,7 @@ pub enum DefIdSource { // Identifies a type parameter (`fn foo() { ... }`). TypeParameter } -type conv_did = &self/fn(source: DefIdSource, ast::def_id) -> ast::def_id; +type conv_did = &'self fn(source: DefIdSource, ast::def_id) -> ast::def_id; pub struct PState { data: @~[u8], diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index f55fae12b45..2893c460fe2 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -514,7 +514,7 @@ pub impl GatherLoanCtxt { // consumes one mut pointer and returns a narrower one: // // struct Foo { f: int } - // fn foo(p: &v/mut Foo) -> &v/mut int { &mut p.f } + // fn foo(p: &'v mut Foo) -> &'v mut int { &mut p.f } // // I think this should work fine but there is more subtlety to it than // I at first imagined. Unfortunately it's a very important use case, diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 328fe1c4f3e..962af48a70c 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -64,7 +64,7 @@ pub impl BorrowckCtxt { } struct PreserveCtxt { - bccx: &self/BorrowckCtxt, + bccx: &'self BorrowckCtxt, // the region scope for which we must preserve the memory scope_region: ty::Region, diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 99781a80c62..4b1b0d0200f 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -55,7 +55,7 @@ use syntax::{visit, ast_util}; // primitives in the stdlib are explicitly annotated to only take sendable // types. -pub const try_adding: &static/str = "Try adding a move"; +pub const try_adding: &'static str = "Try adding a move"; pub type rval_map = HashMap; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 32567d71cd9..f88be89ad00 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -96,7 +96,7 @@ pub impl LanguageItems { } } - static pub fn item_name(&self, index: uint) -> &static/str { + static pub fn item_name(&self, index: uint) -> &'static str { match index { 0 => "const", 1 => "copy", @@ -257,7 +257,7 @@ pub impl LanguageItems { fn LanguageItemCollector(crate: @crate, session: Session, - items: &r/mut LanguageItems) + items: &'r mut LanguageItems) -> LanguageItemCollector/&r { let item_refs = HashMap(); @@ -312,7 +312,7 @@ fn LanguageItemCollector(crate: @crate, } struct LanguageItemCollector { - items: &self/mut LanguageItems, + items: &'self mut LanguageItems, crate: @crate, session: Session, diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 1227f7859d8..f2e736ac86d 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -90,7 +90,7 @@ pub enum lint { // dead_assignment } -pub fn level_to_str(lv: level) -> &static/str { +pub fn level_to_str(lv: level) -> &'static str { match lv { allow => "allow", warn => "warn", @@ -106,7 +106,7 @@ pub enum level { struct LintSpec { lint: lint, - desc: &static/str, + desc: &'static str, default: level } @@ -881,14 +881,14 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) { !ident.contains_char('_') } - fn ident_without_trailing_underscores(ident: &r/str) -> &r/str { + fn ident_without_trailing_underscores(ident: &'r str) -> &'r str { match str::rfind(ident, |c| c != '_') { Some(idx) => str::view(ident, 0, idx + 1), None => ident, // all underscores } } - fn ident_without_leading_underscores(ident: &r/str) -> &r/str { + fn ident_without_leading_underscores(ident: &'r str) -> &'r str { match str::find(ident, |c| c != '_') { Some(idx) => str::view(ident, idx, ident.len()), None => ident // all underscores diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index a96ed9b8fa6..05a697194c8 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -438,7 +438,7 @@ pub fn join_variance(++variance1: region_variance, /// particular site to yield the final variance of the reference. /// /// Example: if we are checking function arguments then the ambient -/// variance is contravariant. If we then find a `&r/T` pointer, `r` +/// variance is contravariant. If we then find a `&'r T` pointer, `r` /// appears in a co-variant position. This implies that this /// occurrence of `r` is contra-variant with respect to the current /// item, and hence the function returns `rv_contravariant`. @@ -517,9 +517,9 @@ pub impl DetermineRpCtxt { // concrete. // // 1. impl foo for &int { ... } - // 2. impl foo for &self/int { ... } - // 3. impl foo for bar { fn m(@self) -> &self/int { ... } } - // 4. impl foo for bar { fn m(&self) -> &self/int { ... } } + // 2. impl foo for &'self int { ... } + // 3. impl foo for bar { fn m(@self) -> &'self int { ... } } + // 4. impl foo for bar { fn m(&self) -> &'self int { ... } } // 5. impl foo for bar { fn m(&self) -> &int { ... } } // // In case 1, the anonymous region is being referenced, @@ -644,9 +644,9 @@ pub fn determine_rp_in_ty(ty: @ast::Ty, // impl etc. So we can ignore it and its components. if cx.item_id == 0 { return; } - // if this type directly references a region pointer like &r/ty, - // add to the worklist/set. Note that &r/ty is contravariant with - // respect to &r, because &r/ty can be used whereever a *smaller* + // if this type directly references a region pointer like &'r ty, + // add to the worklist/set. Note that &'r ty is contravariant with + // respect to &r, because &'r ty can be used whereever a *smaller* // region is expected (and hence is a supertype of those // locations) let sess = cx.sess; diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 16f3db6a00e..45d64cd864f 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -212,7 +212,7 @@ pub impl ResolveResult { pub enum TypeParameters/& { NoTypeParameters, //< No type parameters. - HasTypeParameters(&self/Generics, //< Type parameters. + HasTypeParameters(&'self Generics, //< Type parameters. node_id, //< ID of the enclosing item // The index to start numbering the type parameters at. diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 80631abaa55..8f0d9eb953f 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -327,7 +327,7 @@ pub type BindingsMap = HashMap; pub struct ArmData { bodycx: block, - arm: &self/ast::arm, + arm: &'self ast::arm, bindings_map: BindingsMap } @@ -391,7 +391,7 @@ pub fn expand_nested_bindings(bcx: block, m: &[@Match/&r], } } -pub type enter_pat = &self/fn(@ast::pat) -> Option<~[@ast::pat]>; +pub type enter_pat = &'self fn(@ast::pat) -> Option<~[@ast::pat]>; pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) { if !pat_is_binding_or_wild(bcx.tcx().def_map, p) { diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 15888a64e1e..81d85773ccb 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -550,8 +550,8 @@ pub fn trans_call_inner( pub enum CallArgs { - ArgExprs(&self/[@ast::expr]), - ArgVals(&self/[ValueRef]) + ArgExprs(&'self [@ast::expr]), + ArgVals(&'self [ValueRef]) } pub struct Args { diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 11d3e155202..9b3ec5ef842 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -617,7 +617,7 @@ pub impl Datum { // using `to_ref_llval()`). // Convert to ref, yielding lltype *T. Then create a Rust - // type &static/T (which translates to *T). Construct new + // type &'static T (which translates to *T). Construct new // result (which will be by-value). Note that it is not // significant *which* region we pick here. let llval = self.to_ref_llval(bcx); diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 3e4486476c0..9f66bb5b468 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -520,7 +520,7 @@ pub fn get_base_and_len(bcx: block, pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> Result; -pub type iter_vec_block = &self/fn(block, ValueRef, ty::t) -> block; +pub type iter_vec_block = &'self fn(block, ValueRef, ty::t) -> block; pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> block { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index f455e983690..fcebcaf501e 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -448,13 +448,13 @@ pub enum Region { #[auto_encode] #[auto_decode] pub enum bound_region { - /// The self region for structs, impls (&T in a type defn or &self/T) + /// The self region for structs, impls (&T in a type defn or &'self T) br_self, /// An anonymous region parameter for a given fn (&T) br_anon(uint), - /// Named region parameters for functions (a in &a/T) + /// Named region parameters for functions (a in &'a T) br_named(ast::ident), /// Fresh bound identifiers created during GLB computations. diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 61603f7b578..0186ab30464 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -46,7 +46,7 @@ * type foo/& = ...; * type bar = fn(&foo, &a.foo) * The fully expanded version of type bar is: - * type bar = fn(&foo/&, &a.foo/&a) + * type bar = fn(&'foo &, &a.foo/&a) * Note that the self region for the `foo` defaulted to `&` in the first * case but `&a` in the second. Basically, defaults that appear inside * an rptr (`&r.T`) use the region `r` that appears in the rptr. diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index d673cf6a39a..929555e3148 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -157,7 +157,7 @@ pub struct LookupContext { self_expr: @ast::expr, callee_id: node_id, m_name: ast::ident, - supplied_tps: &self/[ty::t], + supplied_tps: &'self [ty::t], impl_dups: HashMap, inherent_candidates: @mut ~[Candidate], extension_candidates: @mut ~[Candidate], diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 4ff8431d88a..6871496a805 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -18,7 +18,7 @@ know whether a given type will be a region pointer or not until this phase. In particular, we ensure that, if the type of an expression or -variable is `&r/T`, then the expression or variable must occur within +variable is `&'r T`, then the expression or variable must occur within the region scope `r`. Note that in some cases `r` may still be a region variable, so this gives us a chance to influence the value for `r` that we infer to ensure we choose a value large enough to enclose @@ -500,7 +500,7 @@ pub mod guarantor { * * struct Foo { i: int } * struct Bar { foo: Foo } - * fn get_i(x: &a/Bar) -> &a/int { + * fn get_i(x: &'a Bar) -> &'a int { * let foo = &x.foo; // Lifetime L1 * &foo.i // Lifetime L2 * } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index ed26812f44d..3d2ed867de1 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -550,8 +550,8 @@ pub impl CoherenceChecker { } fn can_unify_universally_quantified(&self, - a: &a/UniversalQuantificationResult, - b: &a/UniversalQuantificationResult) + a: &'a UniversalQuantificationResult, + b: &'a UniversalQuantificationResult) -> bool { let mut might_unify = true; let _ = do self.inference_context.probe { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 29d1f81cdd6..b9aac4b19ed 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -438,7 +438,7 @@ pub fn compare_impl_method(tcx: ty::ctxt, // Replace any references to the self region in the self type with // a free region. So, for example, if the impl type is - // "&self/str", then this would replace the self type with a free + // "&'self str", then this would replace the self type with a free // region `self`. let dummy_self_r = ty::re_free(cm.body_id, ty::br_self); let self_ty = replace_bound_self(tcx, self_ty, dummy_self_r); @@ -601,7 +601,7 @@ pub fn convert_methods(ccx: &CrateCtxt, pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt, span: span, generics: &ast::Generics, - thing: &static/str) { + thing: &'static str) { for generics.ty_params.each |ty_param| { if ty_param.bounds.len() > 0 { ccx.tcx.sess.span_err( diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 5c59f1215e4..1ce59064765 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -58,7 +58,7 @@ pub trait LatticeValue { -> cres; } -pub type LatticeOp = &self/fn(cf: &CombineFields, a: &T, b: &T) -> cres; +pub type LatticeOp = &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres; impl LatticeValue for ty::t { static fn sub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures { @@ -378,7 +378,7 @@ pub fn super_lattice_tys( } } -pub type LatticeDirOp = &self/fn(a: &T, b: &T) -> cres; +pub type LatticeDirOp = &'self fn(a: &T, b: &T) -> cres; pub enum LatticeVarResult { VarResult(V), diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 33e953b6218..534e50e115f 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -153,7 +153,7 @@ The problem we are addressing is that there is a kind of subtyping between functions with bound region parameters. Consider, for example, whether the following relation holds: - fn(&a/int) <: &fn(&b/int)? (Yes, a => b) + fn(&'a int) <: &fn(&'b int)? (Yes, a => b) The answer is that of course it does. These two types are basically the same, except that in one we used the name `a` and one we used @@ -163,14 +163,14 @@ In the examples that follow, it becomes very important to know whether a lifetime is bound in a function type (that is, is a lifetime parameter) or appears free (is defined in some outer scope). Therefore, from now on I will write the bindings explicitly, using a -notation like `fn(&a/int)` to indicate that `a` is a lifetime +notation like `fn(&'a int)` to indicate that `a` is a lifetime parameter. Now let's consider two more function types. Here, we assume that the `self` lifetime is defined somewhere outside and hence is not a lifetime parameter bound by the function type (it "appears free"): - fn(&a/int) <: &fn(&self/int)? (Yes, a => self) + fn(&'a int) <: &fn(&'self int)? (Yes, a => self) This subtyping relation does in fact hold. To see why, you have to consider what subtyping means. One way to look at `T1 <: T2` is to @@ -187,7 +187,7 @@ to the same thing: a function that accepts pointers with any lifetime So, what if we reverse the order of the two function types, like this: - fn(&self/int) <: &fn(&a/int)? (No) + fn(&'self int) <: &fn(&'a int)? (No) Does the subtyping relationship still hold? The answer of course is no. In this case, the function accepts *only the lifetime `&self`*, @@ -196,8 +196,8 @@ accepted any lifetime. What about these two examples: - fn(&a/int, &b/int) <: &fn(&a/int, &a/int)? (Yes) - fn(&a/int, &a/int) <: &fn(&a/int, &b/int)? (No) + fn(&'a int, &'b int) <: &fn(&'a int, &'a int)? (Yes) + fn(&'a int, &'a int) <: &fn(&'a int, &'b int)? (No) Here, it is true that functions which take two pointers with any two lifetimes can be treated as if they only accepted two pointers with @@ -221,12 +221,12 @@ Let's walk through some examples and see how this algorithm plays out. We'll start with the first example, which was: - 1. fn(&a/T) <: &fn(&b/T)? Yes: a -> b + 1. fn(&'a T) <: &fn(&'b T)? Yes: a -> b After steps 1 and 2 of the algorithm we will have replaced the types like so: - 1. fn(&A/T) <: &fn(&x/T)? + 1. fn(&'A T) <: &fn(&'x T)? Here the upper case `&A` indicates a *region variable*, that is, a region whose value is being inferred by the system. I also replaced @@ -238,7 +238,7 @@ region names anymore (as indicated by the absence of `<` and `>`). The next step is to check that the parameter types match. Because parameters are contravariant, this means that we check whether: - &x/T <: &A/T + &'x T <: &'A T Region pointers are contravariant so this implies that @@ -255,12 +255,12 @@ So far we have encountered no error, so the subtype check succeeds. Now let's look first at the third example, which was: - 3. fn(&self/T) <: &fn(&b/T)? No! + 3. fn(&'self T) <: &fn(&'b T)? No! After steps 1 and 2 of the algorithm we will have replaced the types like so: - 3. fn(&self/T) <: &fn(&x/T)? + 3. fn(&'self T) <: &fn(&'x T)? This looks pretty much the same as before, except that on the LHS `&self` was not bound, and hence was left as-is and not replaced with @@ -275,33 +275,33 @@ You may be wondering about that mysterious last step in the algorithm. So far it has not been relevant. The purpose of that last step is to catch something like *this*: - fn() -> fn(&a/T) <: &fn() -> fn(&b/T)? No. + fn() -> fn(&'a T) <: &fn() -> fn(&'b T)? No. Here the function types are the same but for where the binding occurs. The subtype returns a function that expects a value in precisely one region. The supertype returns a function that expects a value in any region. If we allow an instance of the subtype to be used where the supertype is expected, then, someone could call the fn and think that -the return value has type `fn(&b/T)` when it really has type -`fn(&a/T)` (this is case #3, above). Bad. +the return value has type `fn(&'b T)` when it really has type +`fn(&'a T)` (this is case #3, above). Bad. So let's step through what happens when we perform this subtype check. We first replace the bound regions in the subtype (the supertype has no bound regions). This gives us: - fn() -> fn(&A/T) <: &fn() -> fn(&b/T)? + fn() -> fn(&'A T) <: &fn() -> fn(&'b T)? Now we compare the return types, which are covariant, and hence we have: - fn(&A/T) <: &fn(&b/T)? + fn(&'A T) <: &fn(&'b T)? Here we skolemize the bound region in the supertype to yield: - fn(&A/T) <: &fn(&x/T)? + fn(&'A T) <: &fn(&'x T)? And then proceed to compare the argument types: - &x/T <: &A/T + &'x T <: &'A T &A <= &x Finally, this is where it gets interesting! This is where an error @@ -314,7 +314,7 @@ The difference between this example and the first one is that the variable `A` already existed at the point where the skolemization occurred. In the first example, you had two functions: - fn(&a/T) <: &fn(&b/T) + fn(&'a T) <: &fn(&'b T) and hence `&A` and `&x` were created "together". In general, the intention of the skolemized names is that they are supposed to be diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index d692a66f699..fe77b62de43 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -35,8 +35,8 @@ pub struct Node { } pub trait UnifyVid { - static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) - -> &v/mut ValsAndBindings; + static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt) + -> &'v mut ValsAndBindings; } pub impl InferCtxt { @@ -235,15 +235,15 @@ pub impl InferCtxt { // ______________________________________________________________________ impl UnifyVid> for ty::TyVid { - static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) - -> &v/mut ValsAndBindings> { + static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt) + -> &'v mut ValsAndBindings> { return &mut infcx.ty_var_bindings; } } impl UnifyVid> for ty::IntVid { - static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) - -> &v/mut ValsAndBindings> { + static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt) + -> &'v mut ValsAndBindings> { return &mut infcx.int_var_bindings; } } @@ -256,8 +256,8 @@ impl SimplyUnifiable for IntVarValue { } impl UnifyVid> for ty::FloatVid { - static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt) - -> &v/mut ValsAndBindings> { + static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt) + -> &'v mut ValsAndBindings> { return &mut infcx.float_var_bindings; } } diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index bd2f641c017..5a08884777c 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -27,8 +27,8 @@ use core::task; /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. pub struct Condvar { is_mutex: bool, - failed: &self/mut bool, - cond: &self/sync::Condvar/&self + failed: &'self mut bool, + cond: &'self sync::Condvar/&self } pub impl Condvar/&self { @@ -95,7 +95,7 @@ pub fn ARC(data: T) -> ARC { * Access the underlying data in an atomically reference counted * wrapper. */ -pub fn get(rc: &a/ARC) -> &a/T { +pub fn get(rc: &'a ARC) -> &'a T { unsafe { get_shared_immutable_state(&rc.x) } } @@ -193,7 +193,7 @@ pub impl MutexARC { #[inline(always)] unsafe fn access_cond( &self, - blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U + blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); @@ -239,7 +239,7 @@ impl Drop for PoisonOnFail { } } -fn PoisonOnFail(failed: &r/mut bool) -> PoisonOnFail { +fn PoisonOnFail(failed: &'r mut bool) -> PoisonOnFail { PoisonOnFail { failed: ptr::to_mut_unsafe_ptr(failed) } @@ -313,7 +313,7 @@ pub impl RWARC { } /// As write(), but with a condvar, as sync::rwlock.write_cond(). #[inline(always)] - fn write_cond(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { + fn write_cond(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { unsafe { let state = get_shared_mutable_state(&self.x); do (*borrow_rwlock(state)).write_cond |cond| { @@ -436,7 +436,7 @@ pub impl RWWriteMode/&self { } } /// Access the pre-downgrade RWARC in write mode with a condvar. - fn write_cond(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U { + fn write_cond(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U { match *self { RWWriteMode { data: ref data, diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 6b5f806f7df..68132a1c08d 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -201,7 +201,7 @@ pub impl Arena { } #[inline(always)] - fn alloc_pod(&self, op: &fn() -> T) -> &self/T { + fn alloc_pod(&self, op: &fn() -> T) -> &'self T { unsafe { let tydesc = sys::get_type_desc::(); let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align); @@ -246,7 +246,7 @@ pub impl Arena { } #[inline(always)] - fn alloc_nonpod(&self, op: &fn() -> T) -> &self/T { + fn alloc_nonpod(&self, op: &fn() -> T) -> &'self T { unsafe { let tydesc = sys::get_type_desc::(); let (ty_ptr, ptr) = @@ -268,7 +268,7 @@ pub impl Arena { // The external interface #[inline(always)] - fn alloc(&self, op: &fn() -> T) -> &self/T { + fn alloc(&self, op: &fn() -> T) -> &'self T { unsafe { if !rusti::needs_drop::() { self.alloc_pod(op) diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 0bd9e1eac51..56ce54be44e 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -16,7 +16,7 @@ pub trait ToBase64 { pure fn to_base64(&self) -> ~str; } -impl ToBase64 for &self/[u8] { +impl ToBase64 for &'self [u8] { pure fn to_base64(&self) -> ~str { let chars = str::chars( ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" @@ -69,7 +69,7 @@ impl ToBase64 for &self/[u8] { } } -impl ToBase64 for &self/str { +impl ToBase64 for &'self str { pure fn to_base64(&self) -> ~str { str::to_bytes(*self).to_base64() } diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 5c3f37faca7..e128859bb7d 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -1045,9 +1045,9 @@ mod biguint_tests { fail_unless!(BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value); } - const sum_triples: &static/[(&static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit])] = &[ + const sum_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[ 1]), (&[ 1], &[ 1], &[ 2]), @@ -1085,9 +1085,9 @@ mod biguint_tests { } } - const mul_triples: &static/[(&static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit])] = &[ + const mul_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[]), (&[ 2], &[], &[]), @@ -1111,10 +1111,10 @@ mod biguint_tests { (&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1]) ]; - const divmod_quadruples: &static/[(&static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit])] + const divmod_quadruples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[ 1], &[ 2], &[], &[1]), (&[ 1, 1], &[ 2], &[-1/2+1], &[1]), @@ -1399,9 +1399,9 @@ mod bigint_tests { ).to_uint() == 0); } - const sum_triples: &static/[(&static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit])] = &[ + const sum_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[ 1]), (&[ 1], &[ 1], &[ 2]), @@ -1451,9 +1451,9 @@ mod bigint_tests { } } - const mul_triples: &static/[(&static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit])] = &[ + const mul_triples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[], &[], &[]), (&[], &[ 1], &[]), (&[ 2], &[], &[]), @@ -1477,10 +1477,10 @@ mod bigint_tests { (&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1]) ]; - const divmod_quadruples: &static/[(&static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit], - &static/[BigDigit])] + const divmod_quadruples: &'static [(&'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit], + &'static [BigDigit])] = &[ (&[ 1], &[ 2], &[], &[1]), (&[ 1, 1], &[ 2], &[-1/2+1], &[1]), diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 15131093acb..90269e28b8a 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -49,17 +49,17 @@ pub impl Deque { /// Return a reference to the first element in the deque /// /// Fails if the deque is empty - fn peek_front(&self) -> &self/T { get(self.elts, self.lo) } + fn peek_front(&self) -> &'self T { get(self.elts, self.lo) } /// Return a reference to the last element in the deque /// /// Fails if the deque is empty - fn peek_back(&self) -> &self/T { get(self.elts, self.hi - 1u) } + fn peek_back(&self) -> &'self T { get(self.elts, self.hi - 1u) } /// Retrieve an element in the deque by index /// /// Fails if there is no element with the given index - fn get(&self, i: int) -> &self/T { + fn get(&self, i: int) -> &'self T { let idx = (self.lo + (i as uint)) % self.elts.len(); get(self.elts, idx) } @@ -130,7 +130,7 @@ fn grow(nelts: uint, lo: uint, elts: &mut [Option]) -> ~[Option] { rv } -fn get(elts: &r/[Option], i: uint) -> &r/T { +fn get(elts: &'r [Option], i: uint) -> &'r T { match elts[i] { Some(ref t) => t, _ => fail!() } } diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 5dc264cb878..4867204ea39 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -55,7 +55,7 @@ pub impl Future { pub impl Future { - pure fn get_ref(&self) -> &self/A { + pure fn get_ref(&self) -> &'self A { /*! * Executes the future's closure and then returns a borrowed * pointer to the result. The borrowed pointer lasts as long as diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 56f2611c914..e52d08c40fe 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -748,7 +748,7 @@ pub fn from_str(s: &str) -> Result { pub struct Decoder { priv json: Json, - priv mut stack: ~[&self/Json], + priv mut stack: ~[&'self Json], } pub fn Decoder(json: Json) -> Decoder { @@ -756,12 +756,12 @@ pub fn Decoder(json: Json) -> Decoder { } priv impl Decoder/&self { - fn peek(&self) -> &self/Json { + fn peek(&self) -> &'self Json { if self.stack.len() == 0 { self.stack.push(&self.json); } self.stack[self.stack.len() - 1] } - fn pop(&self) -> &self/Json { + fn pop(&self) -> &'self Json { if self.stack.len() == 0 { self.stack.push(&self.json); } self.stack.pop() } diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 99d19c4839c..b9b5075c434 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -50,10 +50,10 @@ impl Mutable for PriorityQueue { pub impl PriorityQueue { /// Returns the greatest item in the queue - fails if empty - pure fn top(&self) -> &self/T { &self.data[0] } + pure fn top(&self) -> &'self T { &self.data[0] } /// Returns the greatest item in the queue - None if empty - pure fn maybe_top(&self) -> Option<&self/T> { + pure fn maybe_top(&self) -> Option<&'self T> { if self.is_empty() { None } else { Some(self.top()) } } diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 0288155d29e..2c927b5db16 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -213,7 +213,7 @@ impl Decodable for i64 { } } -impl Encodable for &self/str { +impl Encodable for &'self str { fn encode(&self, s: &S) { s.emit_borrowed_str(*self) } } @@ -286,7 +286,7 @@ impl Decodable for () { } } -impl> Encodable for &self/T { +impl> Encodable for &'self T { fn encode(&self, s: &S) { s.emit_borrowed(|| (**self).encode(s)) } @@ -316,7 +316,7 @@ impl> Decodable for @T { } } -impl> Encodable for &self/[T] { +impl> Encodable for &'self [T] { fn encode(&self, s: &S) { do s.emit_borrowed_vec(self.len()) { for self.eachi |i, e| { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index bdce257e347..c63ef9b7258 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -22,9 +22,9 @@ pub struct SmallIntMap { priv v: ~[Option], } -impl BaseIter<(uint, &self/V)> for SmallIntMap { +impl BaseIter<(uint, &'self V)> for SmallIntMap { /// Visit all key-value pairs in order - pure fn each(&self, it: &fn(&(uint, &self/V)) -> bool) { + pure fn each(&self, it: &fn(&(uint, &'self V)) -> bool) { for uint::range(0, self.v.len()) |i| { match self.v[i] { Some(ref elt) => if !it(&(i, elt)) { break }, @@ -36,9 +36,9 @@ impl BaseIter<(uint, &self/V)> for SmallIntMap { pure fn size_hint(&self) -> Option { Some(self.len()) } } -impl ReverseIter<(uint, &self/V)> for SmallIntMap { +impl ReverseIter<(uint, &'self V)> for SmallIntMap { /// Visit all key-value pairs in reverse order - pure fn each_reverse(&self, it: &fn(&(uint, &self/V)) -> bool) { + pure fn each_reverse(&self, it: &fn(&(uint, &'self V)) -> bool) { for uint::range_rev(self.v.len(), 0) |i| { match self.v[i - 1] { Some(ref elt) => if !it(&(i - 1, elt)) { break }, @@ -96,7 +96,7 @@ impl Map for SmallIntMap { } /// Iterate over the map and mutate the contained values - pure fn find(&self, key: &uint) -> Option<&self/V> { + pure fn find(&self, key: &uint) -> Option<&'self V> { if *key < self.v.len() { match self.v[*key] { Some(ref value) => Some(value), @@ -136,7 +136,7 @@ pub impl SmallIntMap { /// Create an empty SmallIntMap static pure fn new() -> SmallIntMap { SmallIntMap{v: ~[]} } - pure fn get(&self, key: &uint) -> &self/V { + pure fn get(&self, key: &uint) -> &'self V { self.find(key).expect("key not present") } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index e0828d981d7..43c68196eb8 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -16,7 +16,7 @@ use core::util; use core::vec::{len, push}; use core::vec; -type Le = &self/pure fn(v1: &T, v2: &T) -> bool; +type Le = &'self pure fn(v1: &T, v2: &T) -> bool; /** * Merge sort. Returns a new vector containing the sorted list. @@ -168,7 +168,7 @@ pub trait Sort { fn qsort(self); } -impl Sort for &self/mut [T] { +impl Sort for &'self mut [T] { fn qsort(self) { quick_sort3(self); } } @@ -868,7 +868,7 @@ mod tests { #[test] pub fn test_merge_sort_stability() { // tjc: funny that we have to use parens - pure fn ile(x: &(&static/str), y: &(&static/str)) -> bool + pure fn ile(x: &(&'static str), y: &(&'static str)) -> bool { unsafe // to_lower is not pure... { @@ -1172,7 +1172,7 @@ mod big_tests { struct LVal { val: uint, - key: &self/fn(@uint), + key: &'self fn(@uint), } impl Drop for LVal/&self { @@ -1190,16 +1190,16 @@ mod big_tests { } impl Ord for LVal/&self { - pure fn lt(&self, other: &a/LVal/&self) -> bool { + pure fn lt(&self, other: &'a LVal/&self) -> bool { (*self).val < other.val } - pure fn le(&self, other: &a/LVal/&self) -> bool { + pure fn le(&self, other: &'a LVal/&self) -> bool { (*self).val <= other.val } - pure fn gt(&self, other: &a/LVal/&self) -> bool { + pure fn gt(&self, other: &'a LVal/&self) -> bool { (*self).val > other.val } - pure fn ge(&self, other: &a/LVal/&self) -> bool { + pure fn ge(&self, other: &'a LVal/&self) -> bool { (*self).val >= other.val } } diff --git a/src/libstd/stats.rs b/src/libstd/stats.rs index 2a62ebadd2b..cecf9686327 100644 --- a/src/libstd/stats.rs +++ b/src/libstd/stats.rs @@ -30,7 +30,7 @@ pub trait Stats { fn median_abs_dev_pct(self) -> f64; } -impl Stats for &self/[f64] { +impl Stats for &'self [f64] { fn sum(self) -> f64 { vec::foldl(0.0, self, |p,q| p + *q) } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 1d1ec0e11f7..d556be6b85b 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -165,7 +165,7 @@ pub impl Sem<~[Waitqueue]> { #[doc(hidden)] type SemRelease = SemReleaseGeneric/&self<()>; type SemAndSignalRelease = SemReleaseGeneric/&self<~[Waitqueue]>; -struct SemReleaseGeneric { sem: &self/Sem } +struct SemReleaseGeneric { sem: &'self Sem } impl Drop for SemReleaseGeneric/&self { fn finalize(&self) { @@ -173,13 +173,13 @@ impl Drop for SemReleaseGeneric/&self { } } -fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r { +fn SemRelease(sem: &'r Sem<()>) -> SemRelease/&r { SemReleaseGeneric { sem: sem } } -fn SemAndSignalRelease(sem: &r/Sem<~[Waitqueue]>) +fn SemAndSignalRelease(sem: &'r Sem<~[Waitqueue]>) -> SemAndSignalRelease/&r { SemReleaseGeneric { sem: sem @@ -187,7 +187,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[Waitqueue]>) } /// A mechanism for atomic-unlock-and-deschedule blocking and signalling. -pub struct Condvar { priv sem: &self/Sem<~[Waitqueue]> } +pub struct Condvar { priv sem: &'self Sem<~[Waitqueue]> } impl Drop for Condvar/&self { fn finalize(&self) {} } @@ -258,7 +258,7 @@ pub impl Condvar/&self { // mutex during unwinding. As long as the wrapper (mutex, etc) is // bounded in when it gets released, this shouldn't hang forever. struct SemAndSignalReacquire { - sem: &self/Sem<~[Waitqueue]>, + sem: &'self Sem<~[Waitqueue]>, } impl Drop for SemAndSignalReacquire/&self { @@ -272,7 +272,7 @@ pub impl Condvar/&self { } } - fn SemAndSignalReacquire(sem: &r/Sem<~[Waitqueue]>) + fn SemAndSignalReacquire(sem: &'r Sem<~[Waitqueue]>) -> SemAndSignalReacquire/&r { SemAndSignalReacquire { sem: sem @@ -610,7 +610,7 @@ pub impl RWlock { // FIXME(#3588) should go inside of read() #[doc(hidden)] struct RWlockReleaseRead { - lock: &self/RWlock, + lock: &'self RWlock, } impl Drop for RWlockReleaseRead/&self { @@ -635,7 +635,7 @@ impl Drop for RWlockReleaseRead/&self { } } -fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r { +fn RWlockReleaseRead(lock: &'r RWlock) -> RWlockReleaseRead/&r { RWlockReleaseRead { lock: lock } @@ -644,7 +644,7 @@ fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r { // FIXME(#3588) should go inside of downgrade() #[doc(hidden)] struct RWlockReleaseDowngrade { - lock: &self/RWlock, + lock: &'self RWlock, } impl Drop for RWlockReleaseDowngrade/&self { @@ -677,18 +677,18 @@ impl Drop for RWlockReleaseDowngrade/&self { } } -fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r { +fn RWlockReleaseDowngrade(lock: &'r RWlock) -> RWlockReleaseDowngrade/&r { RWlockReleaseDowngrade { lock: lock } } /// The "write permission" token used for rwlock.write_downgrade(). -pub struct RWlockWriteMode { priv lock: &self/RWlock } +pub struct RWlockWriteMode { priv lock: &'self RWlock } impl Drop for RWlockWriteMode/&self { fn finalize(&self) {} } /// The "read permission" token used for rwlock.write_downgrade(). -pub struct RWlockReadMode { priv lock: &self/RWlock } +pub struct RWlockReadMode { priv lock: &'self RWlock } impl Drop for RWlockReadMode/&self { fn finalize(&self) {} } pub impl RWlockWriteMode/&self { diff --git a/src/libstd/test.rs b/src/libstd/test.rs index cec9f56708f..63cf4c998df 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -49,7 +49,7 @@ pub mod rustrt { // hierarchically it may. pub enum TestName { - StaticTestName(&static/str), + StaticTestName(&'static str), DynTestName(~str) } impl ToStr for TestName { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 8e204014975..7192da7b88e 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -88,7 +88,7 @@ impl Ord for TreeMap { impl<'self, K: TotalOrd, V> BaseIter<(&'self K, &'self V)> for TreeMap { /// Visit all key-value pairs in order - pure fn each(&self, f: &fn(&(&self/K, &self/V)) -> bool) { + pure fn each(&self, f: &fn(&(&'self K, &'self V)) -> bool) { each(&self.root, f) } pure fn size_hint(&self) -> Option { Some(self.len()) } @@ -99,7 +99,7 @@ impl<'self, K: TotalOrd, V> for TreeMap { /// Visit all key-value pairs in reverse order - pure fn each_reverse(&self, f: &fn(&(&self/K, &self/V)) -> bool) { + pure fn each_reverse(&self, f: &fn(&(&'self K, &'self V)) -> bool) { each_reverse(&self.root, f); } } @@ -140,8 +140,8 @@ impl Map for TreeMap { } /// Return the value corresponding to the key in the map - pure fn find(&self, key: &K) -> Option<&self/V> { - let mut current: &self/Option<~TreeNode> = &self.root; + pure fn find(&self, key: &K) -> Option<&'self V> { + let mut current: &'self Option<~TreeNode> = &self.root; loop { match *current { Some(ref r) => { @@ -197,15 +197,15 @@ pub impl TreeMap { /// Lazy forward iterator over a map pub struct TreeMapIterator { - priv stack: ~[&self/~TreeNode], - priv node: &self/Option<~TreeNode> + priv stack: ~[&'self ~TreeNode], + priv node: &'self Option<~TreeNode> } /// Advance the iterator to the next node (in order) and return a /// tuple with a reference to the key and value. If there are no /// more nodes, return `None`. pub fn map_next(iter: &mut TreeMapIterator/&r) - -> Option<(&r/K, &r/V)> { + -> Option<(&'r K, &'r V)> { while !iter.stack.is_empty() || iter.node.is_some() { match *iter.node { Some(ref x) => { @@ -224,7 +224,7 @@ pub fn map_next(iter: &mut TreeMapIterator/&r) /// Advance the iterator through the map pub fn map_advance(iter: &mut TreeMapIterator/&r, - f: &fn((&r/K, &r/V)) -> bool) { + f: &fn((&'r K, &'r V)) -> bool) { loop { match map_next(iter) { Some(x) => { @@ -519,14 +519,14 @@ pub struct TreeSetIterator { /// Advance the iterator to the next node (in order). If this iterator is /// finished, does nothing. #[inline(always)] -pub fn set_next(iter: &mut TreeSetIterator/&r) -> Option<&r/T> { +pub fn set_next(iter: &mut TreeSetIterator/&r) -> Option<&'r T> { do map_next(&mut iter.iter).map |&(value, _)| { value } } /// Advance the iterator through the set #[inline(always)] pub fn set_advance(iter: &mut TreeSetIterator/&r, - f: &fn(&r/T) -> bool) { + f: &fn(&'r T) -> bool) { do map_advance(&mut iter.iter) |(k, _)| { f(k) } } @@ -547,16 +547,16 @@ pub impl TreeNode { } } -pure fn each(node: &r/Option<~TreeNode>, - f: &fn(&(&r/K, &r/V)) -> bool) { +pure fn each(node: &'r Option<~TreeNode>, + f: &fn(&(&'r K, &'r V)) -> bool) { for node.each |x| { each(&x.left, f); if f(&(&x.key, &x.value)) { each(&x.right, f) } } } -pure fn each_reverse(node: &r/Option<~TreeNode>, - f: &fn(&(&r/K, &r/V)) -> bool) { +pure fn each_reverse(node: &'r Option<~TreeNode>, + f: &fn(&(&'r K, &'r V)) -> bool) { for node.each |x| { each_reverse(&x.right, f); if f(&(&x.key, &x.value)) { each_reverse(&x.left, f) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index f0822ea4d25..652bc541a1f 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -421,7 +421,7 @@ pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree]) // use a top-level managed pointer by some difficulties // with pushing and popping functionally, and the ownership // issues. As a result, the values returned by the table -// also need to be managed; the &self/... type that Maps +// also need to be managed; the &'self ... type that Maps // return won't work for things that need to get outside // of that managed pointer. The easiest way to do this // is just to insist that the values in the tables are @@ -454,7 +454,7 @@ impl MapChain{ // ugh: can't get this to compile with mut because of the // lack of flow sensitivity. - fn get_map(&self) -> &self/LinearMap { + fn get_map(&self) -> &'self LinearMap { match *self { BaseMapChain (~ref map) => map, ConsMapChain (~ref map,_) => map diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index 26b5b4566b7..54b123bff2f 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -45,12 +45,12 @@ pub impl Junction { } } -type ExpandDerivingStructDefFn = &self/fn(@ext_ctxt, +type ExpandDerivingStructDefFn = &'self fn(@ext_ctxt, span, x: &struct_def, ident, y: &Generics) -> @item; -type ExpandDerivingEnumDefFn = &self/fn(@ext_ctxt, +type ExpandDerivingEnumDefFn = &'self fn(@ext_ctxt, span, x: &enum_def, ident, diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 6deffbe0ae1..2cf52c47959 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -392,6 +392,12 @@ fn mk_token(cx: @ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { build::mk_lit(cx, sp, ast::lit_bool(b))]); } + LIFETIME(ident) => { + return build::mk_call(cx, sp, + ids_ext(cx, ~[~"LIFETIME"]), + ~[mk_ident(cx, sp, ident)]); + } + DOC_COMMENT(ident) => { return build::mk_call(cx, sp, ids_ext(cx, ~[~"DOC_COMMENT"]), diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index ba0c7a71b7c..dbabca55a11 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -61,7 +61,7 @@ impl OptVec { } } - pure fn get(&self, i: uint) -> &self/T { + pure fn get(&self, i: uint) -> &'self T { match *self { Empty => fail!(fmt!("Invalid index %u", i)), Vec(ref v) => &v[i] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a30b910b347..7b7d246c324 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -708,7 +708,7 @@ pub impl Parser { } fn parse_borrowed_pointee(&self) -> ty_ { - // look for `&'lt` or `&foo/` and interpret `foo` as the region name: + // look for `&'lt` or `&'foo ` and interpret `foo` as the region name: let opt_lifetime = self.parse_opt_lifetime(); if self.token_is_closure_keyword(© *self.token) { diff --git a/src/test/auxiliary/cci_const.rs b/src/test/auxiliary/cci_const.rs index b2dd0cc8e58..945004ede6d 100644 --- a/src/test/auxiliary/cci_const.rs +++ b/src/test/auxiliary/cci_const.rs @@ -11,6 +11,6 @@ pub extern fn bar() { } -pub const foopy: &static/str = "hi there"; +pub const foopy: &'static str = "hi there"; pub const uint_val: uint = 12; pub const uint_expr: uint = (1 << uint_val) - 1; diff --git a/src/test/compile-fail/borrowck-addr-of-upvar.rs b/src/test/compile-fail/borrowck-addr-of-upvar.rs index 4e8af4f0421..640bc887731 100644 --- a/src/test/compile-fail/borrowck-addr-of-upvar.rs +++ b/src/test/compile-fail/borrowck-addr-of-upvar.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: @int) -> @fn() -> &static/int { - let result: @fn() -> &static/int = || &*x; //~ ERROR illegal borrow +fn foo(x: @int) -> @fn() -> &'static int { + let result: @fn() -> &'static int = || &*x; //~ ERROR illegal borrow result } diff --git a/src/test/compile-fail/const-cast-different-types.rs b/src/test/compile-fail/const-cast-different-types.rs index 08fa6915106..45e39b47d23 100644 --- a/src/test/compile-fail/const-cast-different-types.rs +++ b/src/test/compile-fail/const-cast-different-types.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -const a: &static/str = &"foo"; +const a: &'static str = &"foo"; const b: *u8 = a as *u8; //~ ERROR non-scalar cast const c: *u8 = &a as *u8; //~ ERROR mismatched types diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index def1fa30f3b..da3728ff3ae 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -22,6 +22,6 @@ impl vec_monad for ~[A] { } fn main() { ["hi"].bind(|x| [x] ); - //~^ ERROR type `[&static/str * 1]` does not implement any method in scope named `bind` + //~^ ERROR type `[&'static str * 1]` does not implement any method in scope named `bind` //~^^ ERROR Unconstrained region variable } diff --git a/src/test/compile-fail/issue-2478.rs b/src/test/compile-fail/issue-2478.rs index 5bde7c67935..2b52cab7fe7 100644 --- a/src/test/compile-fail/issue-2478.rs +++ b/src/test/compile-fail/issue-2478.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -fn foo() -> &a/int { +fn foo() -> &'a int { return &x; } const x: int = 5; diff --git a/src/test/compile-fail/issue-3243.rs b/src/test/compile-fail/issue-3243.rs index 443fae619ba..f235c4bc97c 100644 --- a/src/test/compile-fail/issue-3243.rs +++ b/src/test/compile-fail/issue-3243.rs @@ -10,7 +10,7 @@ // xfail-test fn function() -> &mut [int] { - let mut x: &static/mut [int] = &[1,2,3]; + let mut x: &'static mut [int] = &[1,2,3]; x[0] = 12345; x //~ ERROR bad } diff --git a/src/test/compile-fail/issue-3311.rs b/src/test/compile-fail/issue-3311.rs index 8872357a8d4..1b83cefbf33 100644 --- a/src/test/compile-fail/issue-3311.rs +++ b/src/test/compile-fail/issue-3311.rs @@ -15,7 +15,7 @@ struct Foo { } pub impl Foo<'self> { - fn get_s(&self) -> &self/str { + fn get_s(&self) -> &'self str { self.s } } diff --git a/src/test/compile-fail/issue-3563.rs b/src/test/compile-fail/issue-3563.rs index 9f7a0745c3b..0388f0fd290 100644 --- a/src/test/compile-fail/issue-3563.rs +++ b/src/test/compile-fail/issue-3563.rs @@ -10,7 +10,7 @@ trait A { fn a(&self) { - || self.b() //~ ERROR type `&self/self` does not implement any method in scope named `b` + || self.b() //~ ERROR type `&'self self` does not implement any method in scope named `b` } } fn main() {} diff --git a/src/test/compile-fail/issue-3888.rs b/src/test/compile-fail/issue-3888.rs index 779265e5a29..482d1e9fe8a 100644 --- a/src/test/compile-fail/issue-3888.rs +++ b/src/test/compile-fail/issue-3888.rs @@ -10,7 +10,7 @@ // n.b. This should be a run-pass test, but for now I'm testing // that we don't see an "unknown scope" error. -fn vec_peek(v: &r/[T]) -> Option< (&r/T, &r/[T]) > { +fn vec_peek(v: &'r [T]) -> Option< (&'r T, &'r [T]) > { if v.len() == 0 { None } else { diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 7242d993f33..ae147e628e4 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -11,7 +11,7 @@ // xfail-test fn id(t: T) -> T { t } -fn f(v: &r/T) -> &r/fn()->T { id::<&r/fn()->T>(|| *v) } //~ ERROR ??? +fn f(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR ??? fn main() { let v = &5; diff --git a/src/test/compile-fail/issue-4523.rs b/src/test/compile-fail/issue-4523.rs index 6045ac6cba3..e8e27029371 100644 --- a/src/test/compile-fail/issue-4523.rs +++ b/src/test/compile-fail/issue-4523.rs @@ -10,7 +10,7 @@ fn foopy() {} -const f: &'static fn() = foopy; //~ ERROR mismatched types: expected `&static/fn()` +const f: &'static fn() = foopy; //~ ERROR mismatched types: expected `&'static fn()` fn main () { f(); diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index 305f4bd6bef..dadc66b5029 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -21,10 +21,10 @@ fn repeater(v: @A) -> @repeat { fn main() { // Error results because the type of is inferred to be - // @repeat<&blk/int> where blk is the lifetime of the block below. + // @repeat<&'blk int> where blk is the lifetime of the block below. let y = { //~ ERROR reference is not valid - let x: &blk/int = &3; + let x: &'blk int = &3; repeater(@x) }; fail_unless!(3 == *(y.get())); //~ ERROR reference is not valid diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs index 0ccc5ac8bf0..63690f03093 100644 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ b/src/test/compile-fail/kindck-owned-trait-scoped.rs @@ -12,7 +12,7 @@ // except according to those terms. // A dummy trait/impl that work close over any type. The trait will -// be parameterized by a region due to the &self/int constraint. +// be parameterized by a region due to the &'self int constraint. trait foo { fn foo(&self, i: &'self int) -> int; diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index 96657edb5b1..732d946bf9e 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -14,12 +14,12 @@ struct dog { pub impl dog { fn chase_cat(&mut self) { - let p: &static/mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements + let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements *p += 1u; } fn chase_cat_2(&mut self) { - let p: &blk/mut uint = &mut self.cats_chased; + let p: &'blk mut uint = &mut self.cats_chased; *p += 1u; } } diff --git a/src/test/compile-fail/regions-blk.rs b/src/test/compile-fail/regions-blk.rs index 9b1895ba4bd..893e4c41178 100644 --- a/src/test/compile-fail/regions-blk.rs +++ b/src/test/compile-fail/regions-blk.rs @@ -10,13 +10,13 @@ fn foo(cond: bool) { let x = 5; - let mut y: &blk/int = &x; + let mut y: &'blk int = &x; - let mut z: &blk/int; + let mut z: &'blk int; if cond { z = &x; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements } else { - let w: &blk/int = &x; + let w: &'blk int = &x; z = w; } } diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index 6deef8cee9e..df078bbb54b 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -11,7 +11,7 @@ fn of() -> @fn(T) { fail!(); } fn subtype(x: @fn(T)) { fail!(); } -fn test_fn(_x: &x/T, _y: &y/T, _z: &z/T) { +fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters // are bound. Note that the arrangement // subtype::(of::()) will typecheck diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index 50674ac81fe..a90b3d0f429 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -11,47 +11,47 @@ fn of() -> @fn(T) { fail!(); } fn subtype(x: @fn(T)) { fail!(); } -fn test_fn(_x: &x/T, _y: &y/T, _z: &z/T) { +fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters // are bound. Note that the arrangement // subtype::(of::()) will typecheck // iff T1 <: T2. - subtype::<&fn(&a/T)>( - of::<&fn(&a/T)>()); + subtype::<&fn(&'a T)>( + of::<&fn(&'a T)>()); - subtype::<&fn(&a/T)>( - of::<&fn(&b/T)>()); + subtype::<&fn(&'a T)>( + of::<&fn(&'b T)>()); - subtype::<&fn(&b/T)>( - of::<&fn(&x/T)>()); + subtype::<&fn(&'b T)>( + of::<&fn(&'x T)>()); - subtype::<&fn(&x/T)>( - of::<&fn(&b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&'x T)>( + of::<&fn(&'b T)>()); //~ ERROR mismatched types - subtype::<&fn(&a/T, &b/T)>( - of::<&fn(&a/T, &a/T)>()); + subtype::<&fn(&'a T, &'b T)>( + of::<&fn(&'a T, &'a T)>()); - subtype::<&fn(&a/T, &a/T)>( - of::<&fn(&a/T, &b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&'a T, &'a T)>( + of::<&fn(&'a T, &'b T)>()); //~ ERROR mismatched types - subtype::<&fn(&a/T, &b/T)>( - of::<&fn(&x/T, &y/T)>()); + subtype::<&fn(&'a T, &'b T)>( + of::<&fn(&'x T, &'y T)>()); - subtype::<&fn(&x/T, &y/T)>( - of::<&fn(&a/T, &b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&'x T, &'y T)>( + of::<&fn(&'a T, &'b T)>()); //~ ERROR mismatched types - subtype::<&fn(&x/T) -> @fn(&a/T)>( - of::<&fn(&x/T) -> @fn(&a/T)>()); + subtype::<&fn(&'x T) -> @fn(&'a T)>( + of::<&fn(&'x T) -> @fn(&'a T)>()); - subtype::<&fn(&a/T) -> @fn(&a/T)>( - of::<&fn(&a/T) -> @fn(&b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&'a T) -> @fn(&'a T)>( + of::<&fn(&'a T) -> @fn(&'b T)>()); //~ ERROR mismatched types - subtype::<&fn(&a/T) -> @fn(&a/T)>( - of::<&fn(&x/T) -> @fn(&b/T)>()); //~ ERROR mismatched types + subtype::<&fn(&'a T) -> @fn(&'a T)>( + of::<&fn(&'x T) -> @fn(&'b T)>()); //~ ERROR mismatched types - subtype::<&fn(&a/T) -> @fn(&b/T)>( - of::<&fn(&a/T) -> @fn(&a/T)>()); + subtype::<&fn(&'a T) -> @fn(&'b T)>( + of::<&fn(&'a T) -> @fn(&'a T)>()); } fn main() {} diff --git a/src/test/compile-fail/regions-fns.rs b/src/test/compile-fail/regions-fns.rs index a4f1825fcae..50eba71ac56 100644 --- a/src/test/compile-fail/regions-fns.rs +++ b/src/test/compile-fail/regions-fns.rs @@ -11,8 +11,8 @@ // Before fn subtyping was properly implemented, // we reported errors in this case: -fn not_ok(a: &uint, b: &b/uint) { - let mut g: @fn(x: &uint) = |x: &b/uint| {}; +fn not_ok(a: &uint, b: &'b uint) { + let mut g: @fn(x: &uint) = |x: &'b uint| {}; //~^ ERROR mismatched types g(a); } diff --git a/src/test/compile-fail/regions-freevar.rs b/src/test/compile-fail/regions-freevar.rs index 6545892d0bb..f89c5eaa9c1 100644 --- a/src/test/compile-fail/regions-freevar.rs +++ b/src/test/compile-fail/regions-freevar.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn wants_static_fn(_x: &static/fn()) {} +fn wants_static_fn(_x: &'static fn()) {} fn main() { let i = 3; diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index 82d75bcf5db..6402982a9e1 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -13,7 +13,7 @@ struct point { y: int, } -fn x_coord(p: &r/point) -> &r/int { +fn x_coord(p: &'r point) -> &'r int { return &p.x; } diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index ef8f6748d36..c873e2519bd 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(x: &r/T) -> &r/T {x} +fn borrow(x: &'r T) -> &'r T {x} fn foo(cond: &fn() -> bool, box: &fn() -> @int) { let mut y: ∫ diff --git a/src/test/compile-fail/regions-infer-call-3.rs b/src/test/compile-fail/regions-infer-call-3.rs index 49d3f6aee65..a3bc55228d8 100644 --- a/src/test/compile-fail/regions-infer-call-3.rs +++ b/src/test/compile-fail/regions-infer-call-3.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn select(x: &r/int, y: &r/int) -> &r/int { x } +fn select(x: &'r int, y: &'r int) -> &'r int { x } fn with(f: &fn(x: &int) -> T) -> T { f(&20) } -fn manip(x: &a/int) -> int { +fn manip(x: &'a int) -> int { let z = do with |y| { select(x, y) }; //~^ ERROR cannot infer an appropriate lifetime *z diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs index 936aa79d032..d93713f3f23 100644 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs +++ b/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs @@ -14,7 +14,7 @@ // the normal case. struct contravariant { - f: @fn() -> &self/int + f: @fn() -> &'self int } fn to_same_lifetime(bi: contravariant/&r) { diff --git a/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs b/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs index 27e1452d957..c527cdf233d 100644 --- a/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs +++ b/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs @@ -13,7 +13,7 @@ // You can upcast to a *larger region* but not a smaller one. struct covariant { - f: @fn(x: &self/int) -> int + f: @fn(x: &'self int) -> int } fn to_same_lifetime(bi: covariant/&r) { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs index c84afc6ca64..15b39d772f0 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs @@ -9,7 +9,7 @@ // except according to those terms. struct invariant { - f: @fn(x: @mut &self/int) + f: @fn(x: @mut &'self int) } fn to_same_lifetime(bi: invariant/&r) { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index b958aa70aa4..ff2b4246f01 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -9,7 +9,7 @@ // except according to those terms. struct invariant { - f: @fn() -> @mut &self/int + f: @fn() -> @mut &'self int } fn to_same_lifetime(bi: invariant/&r) { diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index 99a3cc0ab6f..e4ad93bde17 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -29,7 +29,7 @@ impl<'self> set_f for c<'self> { } fn set_f_bad(&self, b: @b) { - self.f = b; //~ ERROR mismatched types: expected `@@&self/int` but found `@@&int` + self.f = b; //~ ERROR mismatched types: expected `@@&'self int` but found `@@&int` } } diff --git a/src/test/compile-fail/regions-nested-fns-2.rs b/src/test/compile-fail/regions-nested-fns-2.rs index b4cbbacea3f..26d6bbd5303 100644 --- a/src/test/compile-fail/regions-nested-fns-2.rs +++ b/src/test/compile-fail/regions-nested-fns-2.rs @@ -12,7 +12,7 @@ fn ignore(_t: T) {} fn nested() { let y = 3; - ignore(|z: &z/int| -> &z/int { + ignore(|z: &'z int| -> &'z int { if false { &y } else { z } //~ ERROR illegal borrow }); } diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index 714b863ca1d..6ef37efeb41 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -10,17 +10,17 @@ fn ignore(t: T) {} -fn nested(x: &x/int) { +fn nested(x: &'x int) { let y = 3; let mut ay = &y; //~ ERROR cannot infer an appropriate lifetime - ignore(|z: &z/int| { + ignore(|z: &'z int| { ay = x; ay = &y; //~ ERROR cannot infer an appropriate lifetime ay = z; }); - ignore(|z: &z/int| -> &z/int { + ignore(|z: &'z int| -> &'z int { if false { return x; } //~ ERROR mismatched types if false { return ay; } return z; diff --git a/src/test/compile-fail/regions-out-of-scope-slice.rs b/src/test/compile-fail/regions-out-of-scope-slice.rs index 102ff8b3998..b3db225700a 100644 --- a/src/test/compile-fail/regions-out-of-scope-slice.rs +++ b/src/test/compile-fail/regions-out-of-scope-slice.rs @@ -15,7 +15,7 @@ fn foo(cond: bool) { let mut x; //~ ERROR foo if cond { - x = &blk/[1,2,3]; + x = &'blk [1,2,3]; } } diff --git a/src/test/compile-fail/regions-ret-borrowed-1.rs b/src/test/compile-fail/regions-ret-borrowed-1.rs index ab6a37b58de..7218dcf379b 100644 --- a/src/test/compile-fail/regions-ret-borrowed-1.rs +++ b/src/test/compile-fail/regions-ret-borrowed-1.rs @@ -12,11 +12,11 @@ // some point regions-ret-borrowed reported an error but this file did // not, due to special hardcoding around the anonymous region. -fn with(f: &fn(x: &a/int) -> R) -> R { +fn with(f: &fn(x: &'a int) -> R) -> R { f(&3) } -fn return_it() -> &a/int { +fn return_it() -> &'a int { with(|o| o) //~ ERROR mismatched types //~^ ERROR reference is not valid outside of its lifetime } diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs index d43065e12fb..cecd847843c 100644 --- a/src/test/compile-fail/regions-ret.rs +++ b/src/test/compile-fail/regions-ret.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(_x : &a/int) -> &a/int { +fn f(_x : &'a int) -> &'a int { return &3; //~ ERROR illegal borrow } diff --git a/src/test/compile-fail/regions-scoping.rs b/src/test/compile-fail/regions-scoping.rs index e675d4d455f..f0c81d16b03 100644 --- a/src/test/compile-fail/regions-scoping.rs +++ b/src/test/compile-fail/regions-scoping.rs @@ -17,7 +17,7 @@ fn nested<'x>(x: &'x int) { // (1) z: &fn<'z>(x: &'x int, // Refers to `x` at (1) y: &'y int, // Refers to `y` at (2) z: &'z int) -> &'z int| // A fresh region `z` (3) - -> &x/int { + -> &'x int { if false { return z(x, y, x); } if false { return z(x, y, y); } @@ -40,9 +40,9 @@ fn nested<'x>(x: &'x int) { // (1) // anymore but rather borrowck. Therefore, it doesn't end up // getting printed out since compilation fails after typeck. // - // let f: &x/int = foo(&z, &z, |_x, _y, z| z ); // ERROR mismatched types: expected `&x/int` but found + // let f: &'x int = foo(&z, &z, |_x, _y, z| z ); // ERROR mismatched types: expected `&'x int` but found - foo(x, &z, |x, _y, _z| x); //~ ERROR mismatched types: expected `&z/int` but found `&x/int` + foo(x, &z, |x, _y, _z| x); //~ ERROR mismatched types: expected `&'z int` but found `&'x int` // Note: originally I had foo(x, &z, ...) here, but in that // case the region inferencer deduced that this was valid if diff --git a/src/test/compile-fail/regions-trait-2.rs b/src/test/compile-fail/regions-trait-2.rs index bbaed2ab600..5811496cab4 100644 --- a/src/test/compile-fail/regions-trait-2.rs +++ b/src/test/compile-fail/regions-trait-2.rs @@ -17,7 +17,7 @@ trait get_ctxt { struct has_ctxt<'self> { c: &'self ctxt } impl<'self> get_ctxt for has_ctxt<'self> { - fn get_ctxt(&self) -> &self/ctxt { self.c } + fn get_ctxt(&self) -> &'self ctxt { self.c } } fn make_gc() -> @get_ctxt { diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index 10b7b1058d8..e947dbf9308 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -12,7 +12,7 @@ // except according to those terms. trait get_ctxt { - fn get_ctxt(self) -> &self/uint; + fn get_ctxt(self) -> &'self uint; } fn make_gc1(gc: @get_ctxt/&a) -> @get_ctxt/&b { diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 16cd51c8f27..78bdee1430c 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -16,7 +16,7 @@ trait iterable { fn iterate(&self, blk: &fn(x: &A) -> bool); } -impl iterable for &self/[A] { +impl iterable for &'self [A] { fn iterate(&self, f: &fn(x: &A) -> bool) { for vec::each(*self) |e| { if !f(e) { break; } diff --git a/src/test/run-pass/bare-static-string.rs b/src/test/run-pass/bare-static-string.rs index ceae1392d3b..d8015f0b92c 100644 --- a/src/test/run-pass/bare-static-string.rs +++ b/src/test/run-pass/bare-static-string.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let x: &static/str = "foo"; + let x: &'static str = "foo"; io::println(x); } diff --git a/src/test/run-pass/borrowck-root-while-cond.rs b/src/test/run-pass/borrowck-root-while-cond.rs index 285796db20e..a8823c477aa 100644 --- a/src/test/run-pass/borrowck-root-while-cond.rs +++ b/src/test/run-pass/borrowck-root-while-cond.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(x: &r/T) -> &r/T {x} +fn borrow(x: &'r T) -> &'r T {x} struct Rec { f: @int } diff --git a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs index d8612155f6c..0699df703c6 100644 --- a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs +++ b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs @@ -1,5 +1,5 @@ struct Wizard { - spells: ~[&static/str] + spells: ~[&'static str] } pub impl Wizard { diff --git a/src/test/run-pass/borrowed-ptr-pattern-3.rs b/src/test/run-pass/borrowed-ptr-pattern-3.rs index 9043018b816..1e9175ac196 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-3.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(s: &r/uint) -> bool { +fn foo(s: &'r uint) -> bool { match s { &3 => true, _ => false diff --git a/src/test/run-pass/borrowed-ptr-pattern-option.rs b/src/test/run-pass/borrowed-ptr-pattern-option.rs index d0d276a8c8c..42c0795b3dd 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-option.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-option.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn select(x: &r/Option, y: &r/Option) -> &r/Option { +fn select(x: &'r Option, y: &'r Option) -> &'r Option { match (x, y) { (&None, &None) => x, (&Some(_), _) => x, diff --git a/src/test/run-pass/const-cast.rs b/src/test/run-pass/const-cast.rs index dca68b4c2a3..64c6f368f2b 100644 --- a/src/test/run-pass/const-cast.rs +++ b/src/test/run-pass/const-cast.rs @@ -12,7 +12,7 @@ extern fn foo() {} const x: *u8 = foo; const y: *libc::c_void = x as *libc::c_void; -const a: &static/int = &10; +const a: &'static int = &10; const b: *int = a as *int; fn main() { diff --git a/src/test/run-pass/const-cross-crate-const.rs b/src/test/run-pass/const-cross-crate-const.rs index a7c30593ecb..e01519ae8a5 100644 --- a/src/test/run-pass/const-cross-crate-const.rs +++ b/src/test/run-pass/const-cross-crate-const.rs @@ -12,7 +12,7 @@ // aux-build:cci_const.rs extern mod cci_const; -const foo: &static/str = cci_const::foopy; +const foo: &'static str = cci_const::foopy; const a: uint = cci_const::uint_val; const b: uint = cci_const::uint_expr + 5; diff --git a/src/test/run-pass/const-enum-ptr.rs b/src/test/run-pass/const-enum-ptr.rs index 6004f9b9001..594350d2988 100644 --- a/src/test/run-pass/const-enum-ptr.rs +++ b/src/test/run-pass/const-enum-ptr.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V0, V1(int) } -const C: &static/E = &V0; +const C: &'static E = &V0; pub fn main() { match *C { diff --git a/src/test/run-pass/const-enum-vec-ptr.rs b/src/test/run-pass/const-enum-vec-ptr.rs index c4017b549e6..b398bfbf0d5 100644 --- a/src/test/run-pass/const-enum-vec-ptr.rs +++ b/src/test/run-pass/const-enum-vec-ptr.rs @@ -9,7 +9,7 @@ // except according to those terms. enum E { V1(int), V0 } -const C: &static/[E] = &[V0, V1(0xDEADBEE), V0]; +const C: &'static [E] = &[V0, V1(0xDEADBEE), V0]; pub fn main() { match C[1] { diff --git a/src/test/run-pass/const-str-ptr.rs b/src/test/run-pass/const-str-ptr.rs index d0773a73923..a1637f6ebb8 100644 --- a/src/test/run-pass/const-str-ptr.rs +++ b/src/test/run-pass/const-str-ptr.rs @@ -9,7 +9,7 @@ // except according to those terms. const a: [u8 * 3] = ['h' as u8, 'i' as u8, 0 as u8]; -const c: &static/[u8 * 3] = &a; +const c: &'static [u8 * 3] = &a; const b: *u8 = c as *u8; fn main() { diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 44edbd44bd3..1a21fa0a5d7 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -29,13 +29,13 @@ fn compute_area(shape: &shape) -> float { pub impl shape { // self is in the implicit self region fn select(&self, threshold: float, - a: &r/T, b: &r/T) -> &r/T { + a: &'r T, b: &'r T) -> &'r T { if compute_area(self) > threshold {a} else {b} } } fn select_based_on_unit_circle( - threshold: float, a: &r/T, b: &r/T) -> &r/T { + threshold: float, a: &'r T, b: &'r T) -> &'r T { let shape = &circle(Point{x: 0.0, y: 0.0}, 1.0); shape.select(threshold, a, b) @@ -58,7 +58,7 @@ pub impl thing { fn foo(@self) -> int { *self.x.a } fn bar(~self) -> int { *self.x.a } fn quux(&self) -> int { *self.x.a } - fn baz(&self) -> &self/A { &self.x } + fn baz(&self) -> &'self A { &self.x } fn spam(self) -> int { *self.x.a } } diff --git a/src/test/run-pass/issue-2502.rs b/src/test/run-pass/issue-2502.rs index 9af41e48aa2..cfae757aee8 100644 --- a/src/test/run-pass/issue-2502.rs +++ b/src/test/run-pass/issue-2502.rs @@ -13,12 +13,12 @@ struct font { } pub impl font/&self { - fn buf(&self) -> &self/~[u8] { + fn buf(&self) -> &'self ~[u8] { self.fontbuf } } -fn font(fontbuf: &r/~[u8]) -> font/&r { +fn font(fontbuf: &'r ~[u8]) -> font/&r { font { fontbuf: fontbuf } diff --git a/src/test/run-pass/issue-2748-b.rs b/src/test/run-pass/issue-2748-b.rs index 7e5730a3db1..62016abf74b 100644 --- a/src/test/run-pass/issue-2748-b.rs +++ b/src/test/run-pass/issue-2748-b.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn thing(x: &r/[int]) -> &r/[int] { x } +fn thing(x: &'r [int]) -> &'r [int] { x } pub fn main() { let x = &[1,2,3]; let y = x; diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs index b113e902963..18839fa3c7f 100644 --- a/src/test/run-pass/issue-3860.rs +++ b/src/test/run-pass/issue-3860.rs @@ -11,7 +11,7 @@ struct Foo { x: int } pub impl Foo { - fn stuff(&mut self) -> &self/mut Foo { + fn stuff(&mut self) -> &'self mut Foo { return self; } } diff --git a/src/test/run-pass/issue-3888-2.rs b/src/test/run-pass/issue-3888-2.rs index 06e652cc7cd..38aeab0888c 100644 --- a/src/test/run-pass/issue-3888-2.rs +++ b/src/test/run-pass/issue-3888-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn vec_peek(v: &r/[T]) -> &r/[T] { +fn vec_peek(v: &'r [T]) -> &'r [T] { // This doesn't work, and should. // v.slice(1, 5) vec::slice(v, 1, 5) diff --git a/src/test/run-pass/issue-4448.rs b/src/test/run-pass/issue-4448.rs index 80cc9a72c33..0a9c731e9b8 100644 --- a/src/test/run-pass/issue-4448.rs +++ b/src/test/run-pass/issue-4448.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - let (port, chan) = comm::stream::<&static/str>(); + let (port, chan) = comm::stream::<&'static str>(); do task::spawn { fail_unless!(port.recv() == "hello, world"); diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 9f093812d8a..8e363c3d5db 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -201,9 +201,9 @@ impl TyVisitor for ptr_visit_adaptor { } fn visit_estr_slice(&self) -> bool { - self.align_to::<&static/str>(); + self.align_to::<&'static str>(); if ! self.inner.visit_estr_slice() { return false; } - self.bump_past::<&static/str>(); + self.bump_past::<&'static str>(); true } @@ -238,9 +238,9 @@ impl TyVisitor for ptr_visit_adaptor { } fn visit_rptr(&self, mtbl: uint, inner: *TyDesc) -> bool { - self.align_to::<&static/u8>(); + self.align_to::<&'static u8>(); if ! self.inner.visit_rptr(mtbl, inner) { return false; } - self.bump_past::<&static/u8>(); + self.bump_past::<&'static u8>(); true } @@ -276,9 +276,9 @@ impl TyVisitor for ptr_visit_adaptor { } fn visit_evec_slice(&self, mtbl: uint, inner: *TyDesc) -> bool { - self.align_to::<&static/[u8]>(); + self.align_to::<&'static [u8]>(); if ! self.inner.visit_evec_slice(mtbl, inner) { return false; } - self.bump_past::<&static/[u8]>(); + self.bump_past::<&'static [u8]>(); true } @@ -439,9 +439,9 @@ impl TyVisitor for ptr_visit_adaptor { } fn visit_self(&self) -> bool { - self.align_to::<&static/u8>(); + self.align_to::<&'static u8>(); if ! self.inner.visit_self() { return false; } - self.align_to::<&static/u8>(); + self.align_to::<&'static u8>(); true } diff --git a/src/test/run-pass/region-dependent-addr-of.rs b/src/test/run-pass/region-dependent-addr-of.rs index a3f5c41e1ac..6cad8c74592 100644 --- a/src/test/run-pass/region-dependent-addr-of.rs +++ b/src/test/run-pass/region-dependent-addr-of.rs @@ -25,54 +25,54 @@ struct C { f: int } -fn get_v1(a: &v/A) -> &v/int { +fn get_v1(a: &'v A) -> &'v int { // Region inferencer must deduce that &v < L2 < L1 let foo = &a.value; // L1 &foo.v1 // L2 } -fn get_v2(a: &v/A, i: uint) -> &v/int { +fn get_v2(a: &'v A, i: uint) -> &'v int { let foo = &a.value; &foo.v2[i] } -fn get_v3(a: &v/A, i: uint) -> &v/int { +fn get_v3(a: &'v A, i: uint) -> &'v int { let foo = &a.value; &foo.v3[i] } -fn get_v4(a: &v/A, i: uint) -> &v/int { +fn get_v4(a: &'v A, i: uint) -> &'v int { let foo = &a.value; &foo.v4.f } -fn get_v5(a: &v/A, i: uint) -> &v/int { +fn get_v5(a: &'v A, i: uint) -> &'v int { let foo = &a.value; &foo.v5.f } -fn get_v6_a(a: &v/A, i: uint) -> &v/int { +fn get_v6_a(a: &'v A, i: uint) -> &'v int { match a.value.v6 { Some(ref v) => &v.f, None => fail!() } } -fn get_v6_b(a: &v/A, i: uint) -> &v/int { +fn get_v6_b(a: &'v A, i: uint) -> &'v int { match *a { A { value: B { v6: Some(ref v), _ } } => &v.f, _ => fail!() } } -fn get_v6_c(a: &v/A, i: uint) -> &v/int { +fn get_v6_c(a: &'v A, i: uint) -> &'v int { match a { &A { value: B { v6: Some(ref v), _ } } => &v.f, _ => fail!() } } -fn get_v5_ref(a: &v/A, i: uint) -> &v/int { +fn get_v5_ref(a: &'v A, i: uint) -> &'v int { match &a.value { &B {v5: ~C {f: ref v}, _} => v } diff --git a/src/test/run-pass/region-return-interior-of-option.rs b/src/test/run-pass/region-return-interior-of-option.rs index 59dbbde7b77..ced2948545f 100644 --- a/src/test/run-pass/region-return-interior-of-option.rs +++ b/src/test/run-pass/region-return-interior-of-option.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn get(opt: &r/Option) -> &r/T { +fn get(opt: &'r Option) -> &'r T { match *opt { Some(ref v) => v, None => fail!(~"none") diff --git a/src/test/run-pass/regions-addr-of-ret.rs b/src/test/run-pass/regions-addr-of-ret.rs index 38e0ac02139..622a1eb9954 100644 --- a/src/test/run-pass/regions-addr-of-ret.rs +++ b/src/test/run-pass/regions-addr-of-ret.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(x : &a/int) -> &a/int { +fn f(x : &'a int) -> &'a int { return &*x; } diff --git a/src/test/run-pass/regions-bot.rs b/src/test/run-pass/regions-bot.rs index 3be9d72c690..96ae71f0ff3 100644 --- a/src/test/run-pass/regions-bot.rs +++ b/src/test/run-pass/regions-bot.rs @@ -10,7 +10,7 @@ // A very limited test of the "bottom" region -fn produce_static() -> &static/T { fail!(); } +fn produce_static() -> &'static T { fail!(); } fn foo(x: &T) -> &uint { produce_static() } diff --git a/src/test/run-pass/regions-equiv-fns.rs b/src/test/run-pass/regions-equiv-fns.rs index e78a6e69bdd..86b997a6008 100644 --- a/src/test/run-pass/regions-equiv-fns.rs +++ b/src/test/run-pass/regions-equiv-fns.rs @@ -13,7 +13,7 @@ fn ok(a: &uint) { // Here &r is an alias for &: - let mut g: @fn(x: &uint) = |x: &r/uint| {}; + let mut g: @fn(x: &uint) = |x: &'r uint| {}; g(a); } diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index 6a03b4f910b..e38bd64da64 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: &r/uint) -> &r/uint { x } +fn foo(x: &'r uint) -> &'r uint { x } fn bar(x: &uint) -> uint { *x } pub fn main() { diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index b28d8534fec..981eace6754 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -18,14 +18,14 @@ fn ok(f: @fn(x: &uint)) { // f's type should be a subtype of g's type), because f can be // used in any context that expects g's type. But this currently // fails. - let mut g: @fn(y: &r/uint) = |x: &r/uint| { }; + let mut g: @fn(y: &'r uint) = |x: &'r uint| { }; g = f; } // This version is the same as above, except that here, g's type is // inferred. fn ok_inferred(f: @fn(x: &uint)) { - let mut g: @fn(x: &r/uint) = |_| {}; + let mut g: @fn(x: &'r uint) = |_| {}; g = f; } diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index e5e24a55843..5aff0274dc4 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn view(x: &r/[T]) -> &r/[T] {x} +fn view(x: &'r [T]) -> &'r [T] {x} pub fn main() { let v = ~[1, 2, 3]; diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 69945a31f6d..fd48402dd10 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn borrow(x: &r/T) -> &r/T {x} +fn borrow(x: &'r T) -> &'r T {x} pub fn main() { let x = @3; diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index 9c4cb0d436d..b5dbf0fde5c 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -10,7 +10,7 @@ struct Point {x: int, y: int} -fn x_coord(p: &r/Point) -> &r/int { +fn x_coord(p: &'r Point) -> &'r int { return &p.x; } diff --git a/src/test/run-pass/regions-infer-call-2.rs b/src/test/run-pass/regions-infer-call-2.rs index dc38a7baacd..74c4c4260fc 100644 --- a/src/test/run-pass/regions-infer-call-2.rs +++ b/src/test/run-pass/regions-infer-call-2.rs @@ -14,7 +14,7 @@ fn with(f: &fn(x: &int) -> T) -> T { f(&20) } -fn has_one(x: &a/int) -> int { +fn has_one(x: &'a int) -> int { do with |y| { takes_two(x, y) } } diff --git a/src/test/run-pass/regions-infer-call.rs b/src/test/run-pass/regions-infer-call.rs index 0477bd2d196..66baaf40108 100644 --- a/src/test/run-pass/regions-infer-call.rs +++ b/src/test/run-pass/regions-infer-call.rs @@ -10,7 +10,7 @@ fn takes_two(x: &int, y: &int) -> int { *x + *y } -fn has_two(x: &a/int, y: &b/int) -> int { +fn has_two(x: &'a int, y: &'b int) -> int { takes_two(x, y) } diff --git a/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs b/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs index b1fa7287fdb..c45212eaa62 100644 --- a/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs +++ b/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs @@ -12,7 +12,7 @@ struct boxed_int { f: &'self int, } -fn max(bi: &r/boxed_int, f: &r/int) -> int { +fn max(bi: &'r boxed_int, f: &'r int) -> int { if *bi.f > *f {*bi.f} else {*f} } diff --git a/src/test/run-pass/regions-infer-contravariance.rs b/src/test/run-pass/regions-infer-contravariance.rs index 1c263a6f0c6..7d966b06e35 100644 --- a/src/test/run-pass/regions-infer-contravariance.rs +++ b/src/test/run-pass/regions-infer-contravariance.rs @@ -16,11 +16,11 @@ fn get(bi: &'r boxed_int<'r>) -> &'r int { bi.f } -fn with(bi: &r/boxed_int) { +fn with(bi: &'r boxed_int) { // Here, the upcast is allowed because the `boxed_int` type is // contravariant with respect to `&r`. See also // compile-fail/regions-infer-invariance-due-to-mutability.rs - let bi: &blk/boxed_int/&blk = bi; + let bi: &'blk boxed_int/&blk = bi; fail_unless!(*get(bi) == 22); } diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index 0049653dea9..1066c5fd4ca 100644 --- a/src/test/run-pass/regions-params.rs +++ b/src/test/run-pass/regions-params.rs @@ -10,7 +10,7 @@ // xfail-fast -fn region_identity(x: &r/uint) -> &r/uint { x } +fn region_identity(x: &'r uint) -> &'r uint { x } fn apply(t: T, f: &fn(T) -> T) -> T { f(t) } diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index 5ca4af37737..481f25745cd 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -11,13 +11,13 @@ struct Ctxt { v: uint } trait get_ctxt { - fn get_ctxt(&self) -> &self/Ctxt; + fn get_ctxt(&self) -> &'self Ctxt; } struct HasCtxt { c: &'self Ctxt } impl get_ctxt for HasCtxt<'self> { - fn get_ctxt(&self) -> &self/Ctxt { + fn get_ctxt(&self) -> &'self Ctxt { self.c } } From fc8c80890844a18ce96a695b5323bf221ca59121 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 14 Mar 2013 12:25:48 -0700 Subject: [PATCH 2/3] libsyntax: Stop parsing old lifetimes, except for the ones on data type declarations. --- src/libcore/io.rs | 2 +- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/typeck/astconv.rs | 4 +-- src/librustc/util/ppaux.rs | 43 +++++++++++------------ src/libstd/sync.rs | 4 +-- src/libsyntax/parse/obsolete.rs | 6 ++++ src/libsyntax/parse/parser.rs | 5 +++ src/test/compile-fail/regions-bounds.rs | 4 +-- src/test/compile-fail/regions-fn-bound.rs | 19 +++++----- 9 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index dcb9e23b45b..b580d9c84a8 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -593,7 +593,7 @@ pub struct BytesReader { mut pos: uint } -impl Reader for BytesReader/&self { +impl Reader for BytesReader<'self> { fn read(&self, bytes: &mut [u8], len: uint) -> uint { let count = uint::min(len, self.bytes.len() - self.pos); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 45d64cd864f..8127f88f250 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -210,7 +210,7 @@ pub impl ResolveResult { } } -pub enum TypeParameters/& { +pub enum TypeParameters<'self> { NoTypeParameters, //< No type parameters. HasTypeParameters(&'self Generics, //< Type parameters. node_id, //< ID of the enclosing item diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 0186ab30464..8e0633c10cd 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -43,10 +43,10 @@ * as it does not already appear in scope. * * Case (b) says that if you have a type: - * type foo/& = ...; + * type foo<'self> = ...; * type bar = fn(&foo, &a.foo) * The fully expanded version of type bar is: - * type bar = fn(&'foo &, &a.foo/&a) + * type bar = fn(&'foo &, &a.foo<'a>) * Note that the self region for the `foo` defaulted to `&` in the first * case but `&a` in the second. Basically, defaults that appear inside * an rptr (`&r.T`) use the region `r` that appears in the rptr. diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 05dc967e379..77258d0b329 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -132,21 +132,21 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) } pub fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { - bound_region_to_str_adorned(cx, "&", br, "") + bound_region_to_str_space(cx, "&", br) } -pub fn bound_region_to_str_adorned(cx: ctxt, prefix: &str, - br: bound_region, sep: &str) -> ~str { - if cx.sess.verbose() { return fmt!("%s%?%s", prefix, br, sep); } +pub fn bound_region_to_str_space(cx: ctxt, + prefix: &str, + br: bound_region) + -> ~str { + if cx.sess.verbose() { return fmt!("%s%? ", prefix, br); } match br { - br_named(id) => fmt!("%s%s%s", prefix, *cx.sess.str_of(id), - sep), - br_self => fmt!("%sself%s", prefix, sep), + br_named(id) => fmt!("%s'%s ", prefix, *cx.sess.str_of(id)), + br_self => fmt!("%s'self ", prefix), br_anon(_) => prefix.to_str(), br_fresh(_) => prefix.to_str(), - br_cap_avoid(_, br) => bound_region_to_str_adorned(cx, prefix, - *br, sep) + br_cap_avoid(_, br) => bound_region_to_str_space(cx, prefix, *br) } } @@ -194,13 +194,12 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { // you should use `explain_region()` or, better yet, // `note_and_explain_region()` pub fn region_to_str(cx: ctxt, region: Region) -> ~str { - region_to_str_adorned(cx, "&", region, "") + region_to_str_space(cx, "&", region) } -pub fn region_to_str_adorned(cx: ctxt, prefix: &str, - region: Region, sep: &str) -> ~str { +pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str { if cx.sess.verbose() { - return fmt!("%s%?%s", prefix, region, sep); + return fmt!("%s%? ", prefix, region); } // These printouts are concise. They do not contain all the information @@ -209,13 +208,13 @@ pub fn region_to_str_adorned(cx: ctxt, prefix: &str, // `explain_region()` or `note_and_explain_region()`. match region { re_scope(_) => prefix.to_str(), - re_bound(br) => bound_region_to_str_adorned(cx, prefix, br, sep), - re_free(_, br) => bound_region_to_str_adorned(cx, prefix, br, sep), + re_bound(br) => bound_region_to_str_space(cx, prefix, br), + re_free(_, br) => bound_region_to_str_space(cx, prefix, br), re_infer(ReSkolemized(_, br)) => { - bound_region_to_str_adorned(cx, prefix, br, sep) + bound_region_to_str_space(cx, prefix, br) } re_infer(ReVar(_)) => prefix.to_str(), - re_static => fmt!("%sstatic%s", prefix, sep) + re_static => fmt!("%s'static ", prefix) } } @@ -233,7 +232,7 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { ty::vstore_fixed(n) => fmt!("%u", n), ty::vstore_uniq => ~"~", ty::vstore_box => ~"@", - ty::vstore_slice(r) => region_to_str_adorned(cx, "&", r, "/") + ty::vstore_slice(r) => region_to_str_space(cx, "&", r) } } @@ -242,7 +241,7 @@ pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str { ty::BareTraitStore => ~"", ty::UniqTraitStore => ~"~", ty::BoxTraitStore => ~"@", - ty::RegionTraitStore(r) => region_to_str_adorned(cx, "&", r, "") + ty::RegionTraitStore(r) => region_to_str_space(cx, "&", r) } } @@ -252,7 +251,7 @@ pub fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str { fmt!("[%s * %s]", ty, vstore_to_str(cx, vs)) } ty::vstore_slice(_) => { - fmt!("%s/%s", vstore_to_str(cx, vs), ty) + fmt!("%s %s", vstore_to_str(cx, vs), ty) } _ => fmt!("%s[%s]", vstore_to_str(cx, vs), ty) } @@ -344,7 +343,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { (ast::OwnedSigil, ty::re_static) => {} (_, region) => { - s.push_str(region_to_str_adorned(cx, "", region, "/")); + s.push_str(region_to_str_space(cx, "", region)); } } @@ -418,7 +417,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { ty_uniq(tm) => ~"~" + mt_to_str(cx, tm), ty_ptr(tm) => ~"*" + mt_to_str(cx, tm), ty_rptr(r, tm) => { - region_to_str_adorned(cx, ~"&", r, ~"/") + mt_to_str(cx, tm) + region_to_str_space(cx, ~"&", r) + mt_to_str(cx, tm) } ty_unboxed_vec(tm) => { ~"unboxed_vec<" + mt_to_str(cx, tm) + ~">" } ty_type => ~"type", diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index d556be6b85b..d47232cc535 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -163,8 +163,8 @@ pub impl Sem<~[Waitqueue]> { // FIXME(#3588) should go inside of access() #[doc(hidden)] -type SemRelease = SemReleaseGeneric/&self<()>; -type SemAndSignalRelease = SemReleaseGeneric/&self<~[Waitqueue]>; +type SemRelease = SemReleaseGeneric<'self, ()>; +type SemAndSignalRelease = SemReleaseGeneric<'self, ~[Waitqueue]>; struct SemReleaseGeneric { sem: &'self Sem } impl Drop for SemReleaseGeneric/&self { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 9f5a79c4f81..f5e83a1beae 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -57,6 +57,7 @@ pub enum ObsoleteSyntax { ObsoleteNewtypeEnum, ObsoleteMode, ObsoleteImplicitSelf, + ObsoleteLifetimeNotation, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -187,6 +188,11 @@ pub impl Parser { "use an explicit `self` declaration or declare the method as \ static" ), + ObsoleteLifetimeNotation => ( + "`/` lifetime notation", + "instead of `&foo/bar`, write `&'foo bar`; instead of \ + `bar/&foo`, write `&bar<'foo>" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7b7d246c324..2ea304a0a9b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -79,6 +79,7 @@ use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern}; use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil}; use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum}; use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf}; +use parse::obsolete::{ObsoleteLifetimeNotation}; use parse::prec::{as_prec, token_to_binop}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; @@ -686,6 +687,7 @@ pub impl Parser { self.token_is_closure_keyword(&self.look_ahead(2u)) { let lifetime = @self.parse_lifetime(); + self.obsolete(*self.last_span, ObsoleteLifetimeNotation); return self.parse_ty_closure(sigil, Some(lifetime)); } else if self.token_is_closure_keyword(© *self.token) { return self.parse_ty_closure(sigil, None); @@ -963,6 +965,7 @@ pub impl Parser { // Also accept the (obsolete) syntax `foo/` token::IDENT(*) => { if self.look_ahead(1u) == token::BINOP(token::SLASH) { + self.obsolete(*self.last_span, ObsoleteLifetimeNotation); Some(@self.parse_lifetime()) } else { None @@ -997,6 +1000,7 @@ pub impl Parser { let span = copy self.span; self.bump(); self.expect(&token::BINOP(token::SLASH)); + self.obsolete(*self.last_span, ObsoleteLifetimeNotation); return ast::Lifetime { id: self.get_id(), span: *span, @@ -3653,6 +3657,7 @@ pub impl Parser { fn parse_region_param(&self) { if self.eat(&token::BINOP(token::SLASH)) { + self.obsolete(*self.last_span, ObsoleteLifetimeNotation); self.expect(&token::BINOP(token::AND)); } } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index e38b0ff58d3..3821035a0f6 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -16,11 +16,11 @@ struct an_enum(&'self int); struct a_class { x:&'self int } fn a_fn1(e: an_enum<'a>) -> an_enum<'b> { - return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a` + return e; //~ ERROR mismatched types: expected `an_enum/&'b ` but found `an_enum/&'a ` } fn a_fn3(e: a_class<'a>) -> a_class<'b> { - return e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a` + return e; //~ ERROR mismatched types: expected `a_class/&'b ` but found `a_class/&'a ` } fn a_fn4(e: int<'a>) -> int<'b> { diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index df078bbb54b..add53d3d9b0 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -1,3 +1,6 @@ +// xfail-test +// xfail'd because the first error does not show up. + // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -8,8 +11,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of() -> @fn(T) { fail!(); } -fn subtype(x: @fn(T)) { fail!(); } +fn of() -> &fn(T) { fail!(); } +fn subtype(x: &fn(T)) { fail!(); } fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters @@ -18,14 +21,14 @@ fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { // iff T1 <: T2. // should be the default: - subtype::<@static/fn()>(of::<@fn()>()); - subtype::<@fn()>(of::<@static/fn()>()); + subtype::<&'static fn()>(of::<&fn()>()); + subtype::<&fn()>(of::<&'static fn()>()); // - subtype::<@x/fn()>(of::<@fn()>()); //~ ERROR mismatched types - subtype::<@x/fn()>(of::<@y/fn()>()); //~ ERROR mismatched types + subtype::<&'x fn()>(of::<&fn()>()); //~ ERROR mismatched types + subtype::<&'x fn()>(of::<&'y fn()>()); //~ ERROR mismatched types - subtype::<@x/fn()>(of::<@static/fn()>()); //~ ERROR mismatched types - subtype::<@static/fn()>(of::<@x/fn()>()); + subtype::<&'x fn()>(of::<&'static fn()>()); //~ ERROR mismatched types + subtype::<&'static fn()>(of::<&'x fn()>()); } From dc6901849584da2fe08a52001b7e6bc2c432bfdc Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Sat, 16 Mar 2013 11:11:31 -0700 Subject: [PATCH 3/3] librustc: Make the compiler ignore purity. For bootstrapping purposes, this commit does not remove all uses of the keyword "pure" -- doing so would cause the compiler to no longer bootstrap due to some syntax extensions ("deriving" in particular). Instead, it makes the compiler ignore "pure". Post-snapshot, we can remove "pure" from the language. There are quite a few (~100) borrow check errors that were essentially all the result of mutable fields or partial borrows of `@mut`. Per discussions with Niko I think we want to allow partial borrows of `@mut` but detect obvious footguns. We should also improve the error message when `@mut` is erroneously reborrowed. --- doc/rust.md | 45 +---------- doc/tutorial-borrowed-ptr.md | 34 ++++---- src/libcore/cell.rs | 13 ++- src/libcore/comm.rs | 10 ++- src/libcore/container.rs | 4 +- src/libcore/hashmap.rs | 8 +- src/libcore/io.rs | 4 +- src/libcore/mutable.rs | 6 +- src/libcore/option.rs | 8 +- src/libcore/ptr.rs | 12 +-- src/libcore/repr.rs | 4 +- src/libcore/task/spawn.rs | 2 +- src/libcore/trie.rs | 8 +- src/libcore/vec.rs | 23 +++++- src/librustc/front/test.rs | 4 +- src/librustc/metadata/creader.rs | 2 + src/librustc/metadata/cstore.rs | 2 + src/librustc/middle/borrowck/check_loans.rs | 1 + src/librustc/middle/borrowck/gather_loans.rs | 21 ++--- src/librustc/middle/liveness.rs | 9 ++- src/librustc/middle/region.rs | 25 +++--- src/librustc/middle/resolve.rs | 81 +++++++++++-------- src/librustc/middle/trans/base.rs | 6 +- src/librustc/middle/trans/build.rs | 2 +- src/librustc/middle/trans/controlflow.rs | 14 ++-- src/librustc/middle/trans/debuginfo.rs | 3 +- src/librustc/middle/trans/glue.rs | 27 ++++--- src/librustc/middle/trans/type_use.rs | 6 +- src/librustc/middle/ty.rs | 4 +- src/librustc/middle/typeck/check/mod.rs | 2 +- src/librustc/middle/typeck/check/vtable.rs | 2 + src/librustc/middle/typeck/coherence.rs | 5 +- src/librustc/middle/typeck/infer/mod.rs | 9 ++- src/libstd/bitv.rs | 4 +- src/libstd/deque.rs | 4 +- src/libstd/flatpipes.rs | 6 +- src/libstd/json.rs | 10 ++- src/libstd/net_tcp.rs | 5 +- src/libstd/oldmap.rs | 18 ++--- src/libstd/priority_queue.rs | 4 +- src/libstd/sha1.rs | 2 +- src/libstd/smallintmap.rs | 11 +-- src/libstd/sort.rs | 33 +++++--- src/libstd/test.rs | 6 +- src/libstd/treemap.rs | 8 +- src/libsyntax/codemap.rs | 22 ++--- src/libsyntax/ext/deriving.rs | 4 +- src/libsyntax/ext/pipes/check.rs | 3 +- src/libsyntax/ext/pipes/liveness.rs | 4 +- src/libsyntax/ext/pipes/proto.rs | 8 +- src/libsyntax/ext/tt/transcribe.rs | 33 +++++--- src/libsyntax/parse/lexer.rs | 4 +- src/libsyntax/parse/parser.rs | 15 ++-- src/libsyntax/print/pp.rs | 8 +- src/libsyntax/print/pprust.rs | 5 +- src/libsyntax/util/interner.rs | 10 ++- .../compile-fail/borrowck-pat-enum-in-box.rs | 11 --- .../borrowck-pure-scope-in-call.rs | 33 -------- .../nontrivial-fn-arg-pattern-in-pure-fn.rs | 16 ---- src/test/compile-fail/pure-higher-order.rs | 64 --------------- src/test/compile-fail/pure-loop-body.rs | 35 -------- .../compile-fail/pure-modifies-aliased.rs | 32 -------- src/test/compile-fail/pure-subtyping.rs | 48 ----------- src/test/compile-fail/purity-infer-fail.rs | 16 ---- .../trait-impl-method-mismatch.rs | 6 +- src/test/run-pass/auto-ref-slice-plus-ref.rs | 3 - .../class-impl-very-parameterized-trait.rs | 4 +- .../run-pass/coerce-reborrow-imm-ptr-arg.rs | 4 - .../run-pass/coerce-reborrow-imm-ptr-rcvr.rs | 2 +- .../run-pass/coerce-reborrow-imm-vec-arg.rs | 2 + .../run-pass/coerce-reborrow-imm-vec-rcvr.rs | 2 + src/test/run-pass/lambda-infer-unresolved.rs | 2 +- 72 files changed, 373 insertions(+), 540 deletions(-) delete mode 100644 src/test/compile-fail/borrowck-pure-scope-in-call.rs delete mode 100644 src/test/compile-fail/nontrivial-fn-arg-pattern-in-pure-fn.rs delete mode 100644 src/test/compile-fail/pure-higher-order.rs delete mode 100644 src/test/compile-fail/pure-loop-body.rs delete mode 100644 src/test/compile-fail/pure-modifies-aliased.rs delete mode 100644 src/test/compile-fail/pure-subtyping.rs delete mode 100644 src/test/compile-fail/purity-infer-fail.rs diff --git a/doc/rust.md b/doc/rust.md index f64877a69ba..6be428ef279 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -214,7 +214,7 @@ false fn for if impl let loop match mod mut -priv pub pure +priv pub ref return self static struct super true trait type @@ -936,7 +936,6 @@ Specifically, the following operations are considered unsafe: - Dereferencing a [raw pointer](#pointer-types). - Casting a [raw pointer](#pointer-types) to a safe pointer type. - - Breaking the [purity-checking rules](#pure-functions) in a `pure` function. - Calling an unsafe function. ##### Unsafe blocks @@ -946,42 +945,6 @@ This facility exists because the static semantics of Rust are a necessary approx When a programmer has sufficient conviction that a sequence of unsafe operations is actually safe, they can encapsulate that sequence (taken as a whole) within an `unsafe` block. The compiler will consider uses of such code "safe", to the surrounding context. -#### Pure functions - -A pure function declaration is identical to a function declaration, except that -it is declared with the additional keyword `pure`. In addition, the typechecker -checks the body of a pure function with a restricted set of typechecking rules. -A pure function may only modify data owned by its own stack frame. -So, a pure function may modify a local variable allocated on the stack, but not a mutable reference that it takes as an argument. -A pure function may only call other pure functions, not general functions. - -An example of a pure function: - -~~~~ -pure fn lt_42(x: int) -> bool { - return (x < 42); -} -~~~~ - -Pure functions may call other pure functions: - -~~~~{.xfail-test} -pure fn pure_length(ls: List) -> uint { ... } - -pure fn nonempty_list(ls: List) -> bool { pure_length(ls) > 0u } -~~~~ - -These purity-checking rules approximate the concept of referential transparency: -that a call-expression could be rewritten with the literal-expression of its return value, without changing the meaning of the program. -Since they are an approximation, sometimes these rules are *too* restrictive. -Rust allows programmers to violate these rules using [`unsafe` blocks](#unsafe-blocks), which we already saw. -As with any `unsafe` block, those that violate static purity carry transfer the burden of safety-proof from the compiler to the programmer. -Programmers should exercise caution when breaking such rules. - -For more details on purity, see [the borrowed pointer tutorial][borrow]. - -[borrow]: tutorial-borrowed-ptr.html - #### Diverging functions A special kind of function can be declared with a `!` character where the @@ -1246,10 +1209,10 @@ For example: ~~~~ trait Num { - static pure fn from_int(n: int) -> Self; + static fn from_int(n: int) -> Self; } impl Num for float { - static pure fn from_int(n: int) -> float { n as float } + static fn from_int(n: int) -> float { n as float } } let x: float = Num::from_int(42); ~~~~ @@ -2643,7 +2606,7 @@ Raw pointers (`*`) ### Function types The function type-constructor `fn` forms new function types. A function type -consists of a set of function-type modifiers (`pure`, `unsafe`, `extern`, etc.), +consists of a set of function-type modifiers (`unsafe`, `extern`, etc.), a sequence of input slots and an output slot. An example of a `fn` type: diff --git a/doc/tutorial-borrowed-ptr.md b/doc/tutorial-borrowed-ptr.md index e638579253f..8e0ca297f65 100644 --- a/doc/tutorial-borrowed-ptr.md +++ b/doc/tutorial-borrowed-ptr.md @@ -486,12 +486,12 @@ For example, we could write a subroutine like this: ~~~ struct Point {x: float, y: float} -fn get_x(p: &r/Point) -> &r/float { &p.x } +fn get_x(p: &'r Point) -> &'r float { &p.x } ~~~ Here, the function `get_x()` returns a pointer into the structure it -was given. The type of the parameter (`&r/Point`) and return type -(`&r/float`) both use a new syntactic form that we have not seen so +was given. The type of the parameter (`&'r Point`) and return type +(`&'r float`) both use a new syntactic form that we have not seen so far. Here the identifier `r` names the lifetime of the pointer explicitly. So in effect, this function declares that it takes a pointer with lifetime `r` and returns a pointer with that same @@ -572,8 +572,8 @@ function: # Rectangle(Point, Size) // upper-left, dimensions # } # fn compute_area(shape: &Shape) -> float { 0f } -fn select(shape: &r/Shape, threshold: float, - a: &r/T, b: &r/T) -> &r/T { +fn select(shape: &'r Shape, threshold: float, + a: &'r T, b: &'r T) -> &'r T { if compute_area(shape) > threshold {a} else {b} } ~~~ @@ -593,17 +593,17 @@ example: # } # fn compute_area(shape: &Shape) -> float { 0f } # fn select(shape: &Shape, threshold: float, -# a: &r/T, b: &r/T) -> &r/T { +# a: &'r T, b: &'r T) -> &'r T { # if compute_area(shape) > threshold {a} else {b} # } - // -+ r -fn select_based_on_unit_circle( // |-+ B - threshold: float, a: &r/T, b: &r/T) -> &r/T { // | | - // | | - let shape = Circle(Point {x: 0., y: 0.}, 1.); // | | - select(&shape, threshold, a, b) // | | -} // |-+ - // -+ + // -+ r +fn select_based_on_unit_circle( // |-+ B + threshold: float, a: &'r T, b: &'r T) -> &'r T { // | | + // | | + let shape = Circle(Point {x: 0., y: 0.}, 1.); // | | + select(&shape, threshold, a, b) // | | +} // |-+ + // -+ ~~~ In this call to `select()`, the lifetime of the first parameter shape @@ -629,8 +629,8 @@ returned. Here is how the new `select()` might look: # Rectangle(Point, Size) // upper-left, dimensions # } # fn compute_area(shape: &Shape) -> float { 0f } -fn select(shape: &tmp/Shape, threshold: float, - a: &r/T, b: &r/T) -> &r/T { +fn select(shape: &'tmp Shape, threshold: float, + a: &'r T, b: &'r T) -> &'r T { if compute_area(shape) > threshold {a} else {b} } ~~~ @@ -649,7 +649,7 @@ concise to just omit the named lifetime for `shape` altogether: # } # fn compute_area(shape: &Shape) -> float { 0f } fn select(shape: &Shape, threshold: float, - a: &r/T, b: &r/T) -> &r/T { + a: &'r T, b: &'r T) -> &'r T { if compute_area(shape) > threshold {a} else {b} } ~~~ diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index da247c648fc..cfd1b8dfef0 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use cast::transmute; use option; use prelude::*; @@ -15,11 +16,21 @@ use prelude::*; /// /// Similar to a mutable option type, but friendlier. -#[deriving_eq] pub struct Cell { mut value: Option } +impl cmp::Eq for Cell { + pure fn eq(&self, other: &Cell) -> bool { + unsafe { + let frozen_self: &Option = transmute(&mut self.value); + let frozen_other: &Option = transmute(&mut other.value); + frozen_self == frozen_other + } + } + pure fn ne(&self, other: &Cell) -> bool { !self.eq(other) } +} + /// Creates a new full cell with the given value. pub fn Cell(value: T) -> Cell { Cell { value: Some(value) } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 5b189abf4a3..12dc2d7e341 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use cast; use either::{Either, Left, Right}; use kinds::Owned; use option; use option::{Option, Some, None, unwrap}; +use uint; use unstable; use vec; @@ -283,8 +285,12 @@ impl Peekable for PortSet { pure fn port_set_peek(self: &PortSet) -> bool { // It'd be nice to use self.port.each, but that version isn't // pure. - for vec::each(self.ports) |p| { - if p.peek() { return true } + for uint::range(0, vec::uniq_len(&const self.ports)) |i| { + // XXX: Botch pending demuting. + unsafe { + let port: &Port = cast::transmute(&mut self.ports[i]); + if port.peek() { return true } + } } false } diff --git a/src/libcore/container.rs b/src/libcore/container.rs index efcf1e26534..5044b3a6c5d 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -14,10 +14,10 @@ use option::Option; pub trait Container { /// Return the number of elements in the container - pure fn len(&self) -> uint; + pure fn len(&const self) -> uint; /// Return true if the container contains no elements - pure fn is_empty(&self) -> bool; + pure fn is_empty(&const self) -> bool; } pub trait Mutable: Container { diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 20d207e9302..68a55792077 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -290,10 +290,10 @@ pub mod linear { impl Container for LinearMap { /// Return the number of elements in the map - pure fn len(&self) -> uint { self.size } + pure fn len(&const self) -> uint { self.size } /// Return true if the map contains no elements - pure fn is_empty(&self) -> bool { self.len() == 0 } + pure fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for LinearMap { @@ -555,10 +555,10 @@ pub mod linear { impl Container for LinearSet { /// Return the number of elements in the set - pure fn len(&self) -> uint { self.map.len() } + pure fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements - pure fn is_empty(&self) -> bool { self.map.is_empty() } + pure fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for LinearSet { diff --git a/src/libcore/io.rs b/src/libcore/io.rs index b580d9c84a8..50e7a42b7b1 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1116,7 +1116,7 @@ pub struct BytesWriter { impl Writer for BytesWriter { fn write(&self, v: &[const u8]) { let v_len = v.len(); - let bytes_len = self.bytes.len(); + let bytes_len = vec::uniq_len(&const self.bytes); let count = uint::max(bytes_len, self.pos + v_len); vec::reserve(&mut self.bytes, count); @@ -1131,7 +1131,7 @@ impl Writer for BytesWriter { } fn seek(&self, offset: int, whence: SeekStyle) { let pos = self.pos; - let len = self.bytes.len(); + let len = vec::uniq_len(&const self.bytes); self.pos = seek_in_buf(offset, pos, len, whence); } fn tell(&self) -> uint { self.pos } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index 875d378b645..d0aa6e050f5 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -46,8 +46,7 @@ pub fn unwrap(m: Mut) -> T { pub impl Data { fn borrow_mut(&self, op: &fn(t: &mut T) -> R) -> R { match self.mode { - Immutable => fail!(fmt!("%? currently immutable", - self.value)), + Immutable => fail!(~"currently immutable"), ReadOnly | Mutable => {} } @@ -62,8 +61,7 @@ pub impl Data { fn borrow_imm(&self, op: &fn(t: &T) -> R) -> R { match self.mode { - Mutable => fail!(fmt!("%? currently mutable", - self.value)), + Mutable => fail!(~"currently mutable"), ReadOnly | Immutable => {} } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 237fc762b3c..5e5396ea121 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -228,14 +228,14 @@ pub pure fn while_some(x: Option, blk: &fn(v: T) -> Option) { } #[inline(always)] -pub pure fn is_none(opt: &Option) -> bool { +pub pure fn is_none(opt: &const Option) -> bool { //! Returns true if the option equals `none` match *opt { None => true, Some(_) => false } } #[inline(always)] -pub pure fn is_some(opt: &Option) -> bool { +pub pure fn is_some(opt: &const Option) -> bool { //! Returns true if the option contains some value !is_none(opt) @@ -333,11 +333,11 @@ impl MutableIter for Option { pub impl Option { /// Returns true if the option equals `none` #[inline(always)] - pure fn is_none(&self) -> bool { is_none(self) } + pure fn is_none(&const self) -> bool { is_none(self) } /// Returns true if the option contains some value #[inline(always)] - pure fn is_some(&self) -> bool { is_some(self) } + pure fn is_some(&const self) -> bool { is_some(self) } /** * Update an optional value by optionally running its content by reference diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 481a61f4ab7..c1b6b26d86a 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -223,8 +223,8 @@ pub unsafe fn array_each(arr: **T, cb: &fn(*T)) { } pub trait Ptr { - pure fn is_null(&self) -> bool; - pure fn is_not_null(&self) -> bool; + pure fn is_null(&const self) -> bool; + pure fn is_not_null(&const self) -> bool; pure fn offset(&self, count: uint) -> Self; } @@ -232,11 +232,11 @@ pub trait Ptr { impl Ptr for *T { /// Returns true if the pointer is equal to the null pointer. #[inline(always)] - pure fn is_null(&self) -> bool { is_null(*self) } + pure fn is_null(&const self) -> bool { is_null(*self) } /// Returns true if the pointer is not equal to the null pointer. #[inline(always)] - pure fn is_not_null(&self) -> bool { is_not_null(*self) } + pure fn is_not_null(&const self) -> bool { is_not_null(*self) } /// Calculates the offset from a pointer. #[inline(always)] @@ -247,11 +247,11 @@ impl Ptr for *T { impl Ptr for *mut T { /// Returns true if the pointer is equal to the null pointer. #[inline(always)] - pure fn is_null(&self) -> bool { is_null(*self) } + pure fn is_null(&const self) -> bool { is_null(*self) } /// Returns true if the pointer is not equal to the null pointer. #[inline(always)] - pure fn is_not_null(&self) -> bool { is_not_null(*self) } + pure fn is_not_null(&const self) -> bool { is_not_null(*self) } /// Calculates the offset from a mutable pointer. #[inline(always)] diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index e6a4a99df44..83df9b7c00f 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -499,7 +499,7 @@ impl TyVisitor for ReprVisitor { } fn visit_enum_variant_field(&self, i: uint, inner: *TyDesc) -> bool { - match self.var_stk[self.var_stk.len() - 1] { + match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { Degenerate | TagMatch => { if i != 0 { self.writer.write_str(", "); @@ -517,7 +517,7 @@ impl TyVisitor for ReprVisitor { _disr_val: int, n_fields: uint, _name: &str) -> bool { - match self.var_stk[self.var_stk.len() - 1] { + match self.var_stk[vec::uniq_len(&const self.var_stk) - 1] { Degenerate | TagMatch => { if n_fields > 0 { self.writer.write_char(')'); diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 0fd373b803f..40a6873ad67 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -127,7 +127,7 @@ type TaskGroupInner = &'self mut Option; // A taskgroup is 'dead' when nothing can cause it to fail; only members can. pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { - (&tg.members).is_empty() + (&const tg.members).is_empty() } // A list-like structure by which taskgroups keep track of all ancestor groups diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 26532c1a4ff..6b2f2bb6a7d 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -50,11 +50,11 @@ impl ReverseIter<(uint, &'self T)> for TrieMap { impl Container for TrieMap { /// Return the number of elements in the map #[inline(always)] - pure fn len(&self) -> uint { self.length } + pure fn len(&const self) -> uint { self.length } /// Return true if the map contains no elements #[inline(always)] - pure fn is_empty(&self) -> bool { self.len() == 0 } + pure fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for TrieMap { @@ -178,11 +178,11 @@ impl ReverseIter for TrieSet { impl Container for TrieSet { /// Return the number of elements in the set #[inline(always)] - pure fn len(&self) -> uint { self.map.len() } + pure fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements #[inline(always)] - pure fn is_empty(&self) -> bool { self.map.is_empty() } + pure fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for TrieSet { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 34d3c022dca..dc220eaed1b 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -118,6 +118,14 @@ pub pure fn len(v: &[const T]) -> uint { as_const_buf(v, |_p, len| len) } +// A botch to tide us over until core and std are fully demuted. +pub pure fn uniq_len(v: &const ~[T]) -> uint { + unsafe { + let v: &~[T] = ::cast::transmute(v); + as_const_buf(*v, |_p, len| len) + } +} + /** * Creates and initializes an immutable vector. * @@ -1691,11 +1699,11 @@ pub mod traits { impl Container for &'self [const T] { /// Returns true if a vector contains no elements #[inline] - pure fn is_empty(&self) -> bool { is_empty(*self) } + pure fn is_empty(&const self) -> bool { is_empty(*self) } /// Returns the length of a vector #[inline] - pure fn len(&self) -> uint { len(*self) } + pure fn len(&const self) -> uint { len(*self) } } pub trait CopyableVector { @@ -1707,7 +1715,14 @@ impl CopyableVector for &'self [const T] { /// Returns a copy of the elements from [`start`..`end`) from `v`. #[inline] pure fn slice(&self, start: uint, end: uint) -> ~[T] { - slice(*self, start, end).to_vec() + // XXX: Purity workaround for stage0. + unsafe { + let mut result = ~[]; + for uint::range(start, end) |i| { + result.push(copy self[i]); + } + result + } } } @@ -2484,7 +2499,7 @@ impl iter::CopyableNonstrictIter for &'self [A] { impl iter::CopyableNonstrictIter for ~[A] { pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; - while i < self.len() { + while i < uniq_len(self) { if !f(copy self[i]) { break; } i += 1; } diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index ddbac4085a7..434d992f501 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -142,7 +142,7 @@ fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: @fold::ast_fold) -> Option<@ast::item> { cx.path.push(i.ident); debug!("current path: %s", - ast_util::path_name_i(cx.path, cx.sess.parse_sess.interner)); + ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner)); if is_test_fn(i) || is_bench_fn(i) { match i.node { @@ -162,7 +162,7 @@ fn fold_item(cx: @mut TestCtxt, &&i: @ast::item, fld: @fold::ast_fold) should_fail: should_fail(i) }; cx.testfns.push(test); - debug!("have %u test/bench functions", cx.testfns.len()); + // debug!("have %u test/bench functions", cx.testfns.len()); } } } diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index a9aa5491631..92de7f3f5e6 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -79,6 +79,8 @@ fn warn_if_multiple_versions(e: @mut Env, crate_cache: @mut ~[cache_entry]) { use core::either::*; + let crate_cache = &mut *crate_cache; + if crate_cache.len() != 0u { let name = loader::crate_name_from_metas( *crate_cache[crate_cache.len() - 1].metas diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 0909a443736..ee52b48bc32 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -96,6 +96,7 @@ pub fn iter_crate_data(cstore: @mut CStore, } pub fn add_used_crate_file(cstore: @mut CStore, lib: &Path) { + let cstore = &mut *cstore; if !vec::contains(cstore.used_crate_files, lib) { cstore.used_crate_files.push(copy *lib); } @@ -108,6 +109,7 @@ pub fn get_used_crate_files(cstore: @mut CStore) -> ~[Path] { pub fn add_used_library(cstore: @mut CStore, lib: @~str) -> bool { fail_unless!(*lib != ~""); + let cstore = &mut *cstore; if cstore.used_libraries.contains(&*lib) { return false; } cstore.used_libraries.push(/*bad*/ copy *lib); true diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 89700427d96..17bdf318e07 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -271,6 +271,7 @@ pub impl CheckLoanCtxt { None => return, Some(loans) => loans }; + let new_loans: &mut ~[Loan] = new_loans; debug!("new_loans has length %?", new_loans.len()); diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 2893c460fe2..e5f056619cc 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -129,9 +129,12 @@ fn req_loans_in_expr(ex: @ast::expr, ex.id, pprust::expr_to_str(ex, tcx.sess.intr())); // If this expression is borrowed, have to ensure it remains valid: - if !self.ignore_adjustments.contains(&ex.id) { - for tcx.adjustments.find(&ex.id).each |adjustments| { - self.guarantee_adjustments(ex, *adjustments); + { + let mut this = &mut *self; + if !this.ignore_adjustments.contains(&ex.id) { + for tcx.adjustments.find(&ex.id).each |adjustments| { + this.guarantee_adjustments(ex, *adjustments); + } } } @@ -288,9 +291,9 @@ fn req_loans_in_expr(ex: @ast::expr, } pub impl GatherLoanCtxt { - fn tcx(@mut self) -> ty::ctxt { self.bccx.tcx } + fn tcx(&mut self) -> ty::ctxt { self.bccx.tcx } - fn guarantee_adjustments(@mut self, + fn guarantee_adjustments(&mut self, expr: @ast::expr, adjustment: &ty::AutoAdjustment) { debug!("guarantee_adjustments(expr=%s, adjustment=%?)", @@ -348,7 +351,7 @@ pub impl GatherLoanCtxt { // out loans, which will be added to the `req_loan_map`. This can // also entail "rooting" GC'd pointers, which means ensuring // dynamically that they are not freed. - fn guarantee_valid(@mut self, + fn guarantee_valid(&mut self, cmt: cmt, req_mutbl: ast::mutability, scope_r: ty::Region) @@ -465,7 +468,7 @@ pub impl GatherLoanCtxt { // has type `@mut{f:int}`, this check might fail because `&x.f` // reqires an immutable pointer, but `f` lives in (aliased) // mutable memory. - fn check_mutbl(@mut self, + fn check_mutbl(&mut self, loan_kind: LoanKind, cmt: cmt) -> bckres { @@ -498,7 +501,7 @@ pub impl GatherLoanCtxt { } } - fn add_loans(@mut self, + fn add_loans(&mut self, cmt: cmt, loan_kind: LoanKind, scope_r: ty::Region, @@ -563,7 +566,7 @@ pub impl GatherLoanCtxt { } } - fn add_loans_to_scope_id(@mut self, + fn add_loans_to_scope_id(&mut self, scope_id: ast::node_id, +loans: ~[Loan]) { debug!("adding %u loans to scope_id %?: %s", diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 2afe9564b20..a8af6a18c00 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -849,21 +849,24 @@ pub impl Liveness { _ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \ doesn't refer to a loop") }, - None => + None => { // Vanilla 'break' or 'loop', so use the enclosing // loop scope - if self.loop_scope.len() == 0 { + let loop_scope = &mut *self.loop_scope; + if loop_scope.len() == 0 { self.tcx.sess.span_bug(sp, ~"break outside loop"); } else { // FIXME(#5275): this shouldn't have to be a method... self.last_loop_scope() } + } } } fn last_loop_scope(&self) -> node_id { - *self.loop_scope.last() + let loop_scope = &mut *self.loop_scope; + *loop_scope.last() } fn ln_str(&self, ln: LiveNode) -> ~str { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 05a697194c8..6dcf1ba8128 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -818,18 +818,21 @@ pub fn determine_rp_in_crate(sess: Session, // C). For each dependent item D, we combine the variance of C // with the ambient variance where the reference occurred and then // update the region-parameterization of D to reflect the result. - while cx.worklist.len() != 0 { - let c_id = cx.worklist.pop(); - let c_variance = cx.region_paramd_items.get(&c_id); - debug!("popped %d from worklist", c_id); - match cx.dep_map.find(&c_id) { - None => {} - Some(deps) => { - for deps.each |dep| { - let v = add_variance(dep.ambient_variance, c_variance); - cx.add_rp(dep.id, v); + { + let cx = &mut *cx; + while cx.worklist.len() != 0 { + let c_id = cx.worklist.pop(); + let c_variance = cx.region_paramd_items.get(&c_id); + debug!("popped %d from worklist", c_id); + match cx.dep_map.find(&c_id) { + None => {} + Some(deps) => { + for deps.each |dep| { + let v = add_variance(dep.ambient_variance, c_variance); + cx.add_rp(dep.id, v); + } + } } - } } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 8127f88f250..6561da0862a 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -457,7 +457,7 @@ pub struct Module { kind: ModuleKind, children: @HashMap, - imports: ~[@ImportDirective], + imports: @mut ~[@ImportDirective], // The anonymous children of this node. Anonymous children are pseudo- // modules that are implicitly created around items contained within @@ -495,7 +495,7 @@ pub fn Module(parent_link: ParentLink, def_id: def_id, kind: kind, children: @HashMap(), - imports: ~[], + imports: @mut ~[], anonymous_children: @HashMap(), import_resolutions: @HashMap(), glob_count: 0, @@ -505,7 +505,8 @@ pub fn Module(parent_link: ParentLink, pub impl Module { fn all_imports_resolved(&self) -> bool { - return self.imports.len() == self.resolved_import_count; + let imports = &mut *self.imports; + return imports.len() == self.resolved_import_count; } } @@ -647,6 +648,7 @@ pub impl NameBindings { None => { match (*type_def).module_def { Some(module_def) => { + let module_def = &mut *module_def; module_def.def_id.map(|def_id| def_mod(*def_id)) } @@ -1978,10 +1980,11 @@ pub impl Resolver { return; } - let import_count = module.imports.len(); + let imports = &mut *module.imports; + let import_count = imports.len(); while module.resolved_import_count < import_count { let import_index = module.resolved_import_count; - let import_directive = module.imports[import_index]; + let import_directive = imports[import_index]; match self.resolve_import_for_module(module, import_directive) { Failed => { // We presumably emitted an error. Continue. @@ -2288,7 +2291,8 @@ pub impl Resolver { (None, None) => { return Failed; } // If it's private, it's also unresolved. (Some(t), None) | (None, Some(t)) => { - match t.bindings.type_def { + let bindings = &mut *t.bindings; + match bindings.type_def { Some(ref type_def) => { if type_def.privacy == Private { return Failed; @@ -2296,7 +2300,7 @@ pub impl Resolver { } _ => () } - match t.bindings.value_def { + match bindings.value_def { Some(ref value_def) => { if value_def.privacy == Private { return Failed; @@ -2483,7 +2487,7 @@ pub impl Resolver { debug!("(resolving glob import) writing module resolution \ %? into `%s`", - is_none(&target_import_resolution.type_target), + is_none(&mut target_import_resolution.type_target), self.module_to_str(module_)); // Here we merge two import resolutions. @@ -2551,7 +2555,7 @@ pub impl Resolver { *self.session.str_of(ident), self.module_to_str(containing_module), self.module_to_str(module_), - dest_import_resolution.privacy); + copy dest_import_resolution.privacy); // Merge the child item into the import resolution. if (*name_bindings).defined_in_public_namespace(ValueNS) { @@ -2864,7 +2868,8 @@ pub impl Resolver { module_, name, TypeNS, DontSearchThroughModules); match resolve_result { Success(target) => { - match target.bindings.type_def { + let bindings = &mut *target.bindings; + match bindings.type_def { Some(ref type_def) => { match (*type_def).module_def { None => { @@ -3061,10 +3066,10 @@ pub impl Resolver { fn report_unresolved_imports(@mut self, module_: @mut Module) { let index = module_.resolved_import_count; - let import_count = module_.imports.len(); + let imports: &mut ~[@ImportDirective] = &mut *module_.imports; + let import_count = imports.len(); if index != import_count { - self.session.span_err(module_.imports[index].span, - ~"unresolved import"); + self.session.span_err(imports[index].span, ~"unresolved import"); } // Descend into children and anonymous children. @@ -4253,10 +4258,10 @@ pub impl Resolver { match bindings_list { Some(bindings_list) - if !bindings_list.contains_key(&ident) - => { - let last_rib = self.value_ribs[ - self.value_ribs.len() - 1]; + if !bindings_list.contains_key(&ident) => { + let this = &mut *self; + let last_rib = this.value_ribs[ + this.value_ribs.len() - 1]; last_rib.bindings.insert(ident, dl_def(def)); bindings_list.insert(ident, pat_id); @@ -4275,8 +4280,9 @@ pub impl Resolver { // Not bound in the same pattern: do nothing } None => { - let last_rib = self.value_ribs[ - self.value_ribs.len() - 1]; + let this = &mut *self; + let last_rib = this.value_ribs[ + this.value_ribs.len() - 1]; last_rib.bindings.insert(ident, dl_def(def)); } @@ -4723,14 +4729,16 @@ pub impl Resolver { } fn find_best_match_for_name(@mut self, name: &str) -> Option<~str> { + let this = &mut *self; + let mut maybes: ~[~str] = ~[]; let mut values: ~[uint] = ~[]; - let mut j = self.value_ribs.len(); + let mut j = this.value_ribs.len(); while j != 0 { j -= 1; - for self.value_ribs[j].bindings.each_entry |e| { - vec::push(&mut maybes, copy *self.session.str_of(e.key)); + for this.value_ribs[j].bindings.each_entry |e| { + vec::push(&mut maybes, copy *this.session.str_of(e.key)); vec::push(&mut values, uint::max_value); } } @@ -4758,12 +4766,14 @@ pub impl Resolver { } fn name_exists_in_scope_struct(@mut self, name: &str) -> bool { - let mut i = self.type_ribs.len(); + let this = &mut *self; + + let mut i = this.type_ribs.len(); while i != 0 { i -= 1; - match self.type_ribs[i].kind { + match this.type_ribs[i].kind { MethodRibKind(node_id, _) => - for self.crate.node.module.items.each |item| { + for this.crate.node.module.items.each |item| { if item.id == node_id { match item.node { item_struct(class_def, _) => { @@ -4771,7 +4781,7 @@ pub impl Resolver { match field.node.kind { unnamed_field => {}, named_field(ident, _, _) => { - if str::eq_slice(*self.session.str_of(ident), + if str::eq_slice(*this.session.str_of(ident), name) { return true } @@ -4877,8 +4887,9 @@ pub impl Resolver { expr_loop(_, Some(label)) => { do self.with_label_rib { + let this = &mut *self; let def_like = dl_def(def_label(expr.id)); - let rib = self.label_ribs[self.label_ribs.len() - 1]; + let rib = this.label_ribs[this.label_ribs.len() - 1]; rib.bindings.insert(label, def_like); visit_expr(expr, (), visitor); @@ -5144,21 +5155,21 @@ pub impl Resolver { // be sure that there is only one main function // fn check_duplicate_main(@mut self) { - if self.attr_main_fn.is_none() { - if self.main_fns.len() >= 1u { + let this = &mut *self; + if this.attr_main_fn.is_none() { + if this.main_fns.len() >= 1u { let mut i = 1u; - while i < self.main_fns.len() { - let (_, dup_main_span) = - option::unwrap(self.main_fns[i]); - self.session.span_err( + while i < this.main_fns.len() { + let (_, dup_main_span) = option::unwrap(this.main_fns[i]); + this.session.span_err( dup_main_span, ~"multiple 'main' functions"); i += 1; } - *self.session.main_fn = self.main_fns[0]; + *this.session.main_fn = this.main_fns[0]; } } else { - *self.session.main_fn = self.attr_main_fn; + *this.session.main_fn = this.attr_main_fn; } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index a340e6472b8..4836ce062c9 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -854,7 +854,9 @@ pub fn need_invoke(bcx: block) -> bool { // Walk the scopes to look for cleanups let mut cur = bcx; loop { - match *cur.kind { + let current = &mut *cur; + let kind = &mut *current.kind; + match *kind { block_scope(ref mut inf) => { for vec::each((*inf).cleanups) |cleanup| { match *cleanup { @@ -868,7 +870,7 @@ pub fn need_invoke(bcx: block) -> bool { } _ => () } - cur = match cur.parent { + cur = match current.parent { Some(next) => next, None => return false } diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 1d31dc4fb8a..96c124d60de 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -50,7 +50,7 @@ pub fn count_insn(cx: block, category: &str) { if cx.ccx().sess.count_llvm_insns() { let h = cx.ccx().stats.llvm_insns; - let v = cx.ccx().stats.llvm_insn_ctxt; + let v = &*cx.ccx().stats.llvm_insn_ctxt; // Build version of path with cycles removed. diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 40394391f1a..616a5f99499 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -186,12 +186,14 @@ pub fn trans_log(log_ex: @ast::expr, return expr::trans_into(bcx, lvl, expr::Ignore); } - let modpath = vec::append( - ~[path_mod(ccx.sess.ident_of(ccx.link_meta.name.to_owned()))], - bcx.fcx.path.filtered(|e| - match *e { path_mod(_) => true, _ => false } - )); - let modname = path_str(ccx.sess, modpath); + let (modpath, modname) = { + let path = &mut bcx.fcx.path; + let modpath = vec::append( + ~[path_mod(ccx.sess.ident_of(ccx.link_meta.name.to_owned()))], + path.filtered(|e| match *e { path_mod(_) => true, _ => false })); + let modname = path_str(ccx.sess, modpath); + (modpath, modname) + }; let global = if ccx.module_data.contains_key(&modname) { ccx.module_data.get(&modname) diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 4a1837fd9d0..e4b9d01c509 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -845,7 +845,8 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { let dbg_cx = (/*bad*/copy cx.dbg_cx).get(); debug!("~~"); - debug!("%?", fcx.id); + + let fcx = &mut *fcx; let sp = fcx.span.get(); debug!("%s", cx.sess.codemap.span_to_str(sp)); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 8302f46120e..284a5eac39d 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -234,18 +234,21 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext, if simpl != ti.ty { let simpl_ti = get_tydesc(ccx, simpl); lazily_emit_tydesc_glue(ccx, field, simpl_ti); - if field == abi::tydesc_field_take_glue { - ti.take_glue = - simpl_ti.take_glue.map(|v| cast_glue(ccx, ti, *v)); - } else if field == abi::tydesc_field_drop_glue { - ti.drop_glue = - simpl_ti.drop_glue.map(|v| cast_glue(ccx, ti, *v)); - } else if field == abi::tydesc_field_free_glue { - ti.free_glue = - simpl_ti.free_glue.map(|v| cast_glue(ccx, ti, *v)); - } else if field == abi::tydesc_field_visit_glue { - ti.visit_glue = - simpl_ti.visit_glue.map(|v| cast_glue(ccx, ti, *v)); + { + let simpl_ti = &mut *simpl_ti; + if field == abi::tydesc_field_take_glue { + ti.take_glue = + simpl_ti.take_glue.map(|v| cast_glue(ccx, ti, *v)); + } else if field == abi::tydesc_field_drop_glue { + ti.drop_glue = + simpl_ti.drop_glue.map(|v| cast_glue(ccx, ti, *v)); + } else if field == abi::tydesc_field_free_glue { + ti.free_glue = + simpl_ti.free_glue.map(|v| cast_glue(ccx, ti, *v)); + } else if field == abi::tydesc_field_visit_glue { + ti.visit_glue = + simpl_ti.visit_glue.map(|v| cast_glue(ccx, ti, *v)); + } } return true; } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 692dc392173..593919d108b 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -185,7 +185,11 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint) pub fn type_needs(cx: Context, use_: uint, ty: ty::t) { // Optimization -- don't descend type if all params already have this use - for uint::range(0, cx.uses.len()) |i| { + let len = { + let uses = &*cx.uses; + uses.len() + }; + for uint::range(0, len) |i| { if cx.uses[i] & use_ != use_ { type_needs_inner(cx, use_, ty, @Nil); return; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index fcebcaf501e..599fa28e242 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2184,7 +2184,7 @@ pub fn type_moves_by_default(cx: ctxt, ty: t) -> bool { // True if instantiating an instance of `r_ty` requires an instance of `r_ty`. pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { - fn type_requires(cx: ctxt, seen: @mut ~[def_id], + fn type_requires(cx: ctxt, seen: &mut ~[def_id], r_ty: t, ty: t) -> bool { debug!("type_requires(%s, %s)?", ::util::ppaux::ty_to_str(cx, r_ty), @@ -2202,7 +2202,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { return r; } - fn subtypes_require(cx: ctxt, seen: @mut ~[def_id], + fn subtypes_require(cx: ctxt, seen: &mut ~[def_id], r_ty: t, ty: t) -> bool { debug!("subtypes_require(%s, %s)?", ::util::ppaux::ty_to_str(cx, r_ty), diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index f3fff416c55..752d9107d82 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1696,7 +1696,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fcx.write_ty(expr.id, fty); let inherited_purity = - ty::determine_inherited_purity(fcx.purity, purity, + ty::determine_inherited_purity(copy fcx.purity, purity, fn_ty.sigil); // We inherit the same self info as the enclosing scope, diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 48a37c9e72a..6e86bbca0d1 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -10,6 +10,7 @@ use core::prelude::*; +use middle::resolve::Impl; use middle::ty::{param_ty, substs}; use middle::ty; use middle::typeck::check::{FnCtxt, impl_self_ty}; @@ -240,6 +241,7 @@ pub fn lookup_vtable(vcx: &VtableContext, // Nothing found. Continue. } Some(implementations) => { + let implementations: &mut ~[@Impl] = implementations; // implementations is the list of all impls in scope for // trait_ty. (Usually, there's just one.) for uint::range(0, implementations.len()) |i| { diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 3d2ed867de1..699b8ad74e4 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -466,14 +466,13 @@ pub impl CoherenceChecker { } } - fn iter_impls_of_trait(&self, trait_def_id: def_id, - f: &fn(@Impl)) { - + fn iter_impls_of_trait(&self, trait_def_id: def_id, f: &fn(@Impl)) { let coherence_info = &mut self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; match extension_methods.find(&trait_def_id) { Some(impls) => { + let impls: &mut ~[@Impl] = impls; for uint::range(0, impls.len()) |i| { f(impls[i]); } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 03649faff63..11da6b60328 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -559,15 +559,16 @@ pub impl InferCtxt { } fn start_snapshot(@mut self) -> Snapshot { + let this = &mut *self; Snapshot { ty_var_bindings_len: - self.ty_var_bindings.bindings.len(), + this.ty_var_bindings.bindings.len(), int_var_bindings_len: - self.int_var_bindings.bindings.len(), + this.int_var_bindings.bindings.len(), float_var_bindings_len: - self.float_var_bindings.bindings.len(), + this.float_var_bindings.bindings.len(), region_vars_snapshot: - self.region_vars.start_snapshot(), + this.region_vars.start_snapshot(), } } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 9cf2d145eac..430a5eab64e 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -700,8 +700,8 @@ impl cmp::Eq for BitvSet { } impl Container for BitvSet { - pure fn len(&self) -> uint { self.size } - pure fn is_empty(&self) -> bool { self.size == 0 } + pure fn len(&const self) -> uint { self.size } + pure fn is_empty(&const self) -> bool { self.size == 0 } } impl Mutable for BitvSet { diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 90269e28b8a..86304f48e79 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -23,10 +23,10 @@ pub struct Deque { impl Container for Deque { /// Return the number of elements in the deque - pure fn len(&self) -> uint { self.nelts } + pure fn len(&const self) -> uint { self.nelts } /// Return true if the deque contains no elements - pure fn is_empty(&self) -> bool { self.len() == 0 } + pure fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for Deque { diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index e2e09f1d675..c5515c63b29 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -569,12 +569,12 @@ pub mod bytepipes { impl BytePort for PipeBytePort { fn try_recv(&self, count: uint) -> Option<~[u8]> { - if self.buf.len() >= count { + if vec::uniq_len(&const self.buf) >= count { let mut bytes = ::core::util::replace(&mut self.buf, ~[]); self.buf = bytes.slice(count, bytes.len()); bytes.truncate(count); return Some(bytes); - } else if self.buf.len() > 0 { + } else if vec::uniq_len(&const self.buf) > 0 { let mut bytes = ::core::util::replace(&mut self.buf, ~[]); fail_unless!(count > bytes.len()); match self.try_recv(count - bytes.len()) { @@ -584,7 +584,7 @@ pub mod bytepipes { } None => return None } - } else if self.buf.is_empty() { + } else if vec::uniq_len(&const self.buf) == 0 { match self.port.try_recv() { Some(buf) => { fail_unless!(!buf.is_empty()); diff --git a/src/libstd/json.rs b/src/libstd/json.rs index e52d08c40fe..f2f37604fb5 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -757,12 +757,16 @@ pub fn Decoder(json: Json) -> Decoder { priv impl Decoder/&self { fn peek(&self) -> &'self Json { - if self.stack.len() == 0 { self.stack.push(&self.json); } - self.stack[self.stack.len() - 1] + if vec::uniq_len(&const self.stack) == 0 { + self.stack.push(&self.json); + } + self.stack[vec::uniq_len(&const self.stack) - 1] } fn pop(&self) -> &'self Json { - if self.stack.len() == 0 { self.stack.push(&self.json); } + if vec::uniq_len(&const self.stack) == 0 { + self.stack.push(&self.json); + } self.stack.pop() } } diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 54fbae956ce..a93e94e0d04 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -879,7 +879,8 @@ impl io::Reader for TcpSocketBuf { // If possible, copy up to `len` bytes from the internal // `data.buf` into `buf` - let nbuffered = self.data.buf.len() - self.data.buf_off; + let nbuffered = vec::uniq_len(&const self.data.buf) - + self.data.buf_off; let needed = len - count; if nbuffered > 0 { unsafe { @@ -931,7 +932,7 @@ impl io::Reader for TcpSocketBuf { } fn read_byte(&self) -> int { loop { - if self.data.buf.len() > self.data.buf_off { + if vec::uniq_len(&const self.data.buf) > self.data.buf_off { let c = self.data.buf[self.data.buf_off]; self.data.buf_off += 1; return c as int diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index a4b00e4dd04..0a07a24e8ee 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -101,7 +101,7 @@ pub mod chained { } pure fn search_tbl(&self, k: &K, h: uint) -> SearchResult { - let idx = h % vec::len(self.chains); + let idx = h % vec::uniq_len(&const self.chains); match copy self.chains[idx] { None => { debug!("search_tbl: none, comp %u, hash %u, idx %u", @@ -121,7 +121,7 @@ pub mod chained { } fn rehash(@self) { - let n_old_chains = self.chains.len(); + let n_old_chains = vec::uniq_len(&const self.chains); let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u); let mut new_chains = chains(n_new_chains); for self.each_entry |entry| { @@ -137,7 +137,7 @@ pub mod chained { pure fn each_entry(&self, blk: &fn(@Entry) -> bool) { // n.b. we can't use vec::iter() here because self.chains // is stored in a mutable location. - let mut i = 0u, n = self.chains.len(); + let mut i = 0u, n = vec::uniq_len(&const self.chains); while i < n { let mut chain = self.chains[i]; loop { @@ -161,8 +161,8 @@ pub mod chained { } impl Container for HashMap_ { - pure fn len(&self) -> uint { self.count } - pure fn is_empty(&self) -> bool { self.count == 0 } + pure fn len(&const self) -> uint { self.count } + pure fn is_empty(&const self) -> bool { self.count == 0 } } pub impl HashMap_ { @@ -179,7 +179,7 @@ pub mod chained { match self.search_tbl(&k, hash) { NotFound => { self.count += 1u; - let idx = hash % vec::len(self.chains); + let idx = hash % vec::uniq_len(&const self.chains); let old_chain = self.chains[idx]; self.chains[idx] = Some(@Entry { hash: hash, @@ -188,7 +188,7 @@ pub mod chained { next: old_chain}); // consider rehashing if more 3/4 full - let nchains = vec::len(self.chains); + let nchains = vec::uniq_len(&const self.chains); let load = util::Rational { num: (self.count + 1u) as int, den: nchains as int, @@ -271,7 +271,7 @@ pub mod chained { match self.search_tbl(&key, hash) { NotFound => { self.count += 1u; - let idx = hash % vec::len(self.chains); + let idx = hash % vec::uniq_len(&const self.chains); let old_chain = self.chains[idx]; self.chains[idx] = Some(@Entry { hash: hash, @@ -280,7 +280,7 @@ pub mod chained { next: old_chain}); // consider rehashing if more 3/4 full - let nchains = vec::len(self.chains); + let nchains = vec::uniq_len(&const self.chains); let load = util::Rational { num: (self.count + 1u) as int, den: nchains as int, diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index b9b5075c434..a5a291c5b18 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -37,10 +37,10 @@ impl BaseIter for PriorityQueue { impl Container for PriorityQueue { /// Returns the length of the queue - pure fn len(&self) -> uint { self.data.len() } + pure fn len(&const self) -> uint { vec::uniq_len(&const self.data) } /// Returns true if a queue contains no elements - pure fn is_empty(&self) -> bool { self.data.is_empty() } + pure fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for PriorityQueue { diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index b1ef0233d97..f7e31bc7df7 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -91,7 +91,7 @@ pub fn sha1() -> @Sha1 { } fn process_msg_block(st: &mut Sha1State) { fail_unless!((vec::len(st.h) == digest_buf_len)); - fail_unless!((vec::len(*st.work_buf) == work_buf_len)); + fail_unless!((vec::uniq_len(st.work_buf) == work_buf_len)); let mut t: int; // Loop counter let mut w = st.work_buf; diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index c63ef9b7258..dc2688a20e7 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -50,18 +50,19 @@ impl ReverseIter<(uint, &'self V)> for SmallIntMap { impl Container for SmallIntMap { /// Return the number of elements in the map - pure fn len(&self) -> uint { + pure fn len(&const self) -> uint { let mut sz = 0; - for self.v.each |item| { - if item.is_some() { - sz += 1; + for uint::range(0, vec::uniq_len(&const self.v)) |i| { + match self.v[i] { + Some(_) => sz += 1, + None => {} } } sz } /// Return true if the map contains no elements - pure fn is_empty(&self) -> bool { self.len() == 0 } + pure fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for SmallIntMap { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 43c68196eb8..40be303a147 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -68,9 +68,14 @@ fn part(arr: &mut [T], left: uint, let mut storage_index: uint = left; let mut i: uint = left; while i < right { - if compare_func(&arr[i], &arr[right]) { - arr[i] <-> arr[storage_index]; - storage_index += 1; + // XXX: Unsafe because borrow check doesn't handle this right + unsafe { + let a: &T = cast::transmute(&mut arr[i]); + let b: &T = cast::transmute(&mut arr[right]); + if compare_func(a, b) { + arr[i] <-> arr[storage_index]; + storage_index += 1; + } } i += 1; } @@ -451,7 +456,10 @@ impl MergeState { base2: uint, len2: uint) { fail_unless!(len1 != 0 && len2 != 0 && base1+len1 == base2); - let mut tmp = vec::slice(array, base1, base1+len1).to_vec(); + let mut tmp = ~[]; + for uint::range(base1, base1+len1) |i| { + tmp.push(array[i]); + } let mut c1 = 0; let mut c2 = base2; @@ -554,7 +562,10 @@ impl MergeState { base2: uint, len2: uint) { fail_unless!(len1 != 1 && len2 != 0 && base1 + len1 == base2); - let mut tmp = vec::slice(array, base2, base2+len2).to_vec(); + let mut tmp = ~[]; + for uint::range(base2, base2+len2) |i| { + tmp.push(array[i]); + } let mut c1 = base1 + len1 - 1; let mut c2 = len2 - 1; @@ -702,7 +713,11 @@ fn copy_vec(dest: &mut [T], s1: uint, from: &[const T], s2: uint, len: uint) { fail_unless!(s1+len <= dest.len() && s2+len <= from.len()); - let slice = vec::slice(from, s2, s2+len).to_vec(); + let mut slice = ~[]; + for uint::range(s2, s2+len) |i| { + slice.push(from[i]); + } + for slice.eachi |i, v| { dest[s1+i] = *v; } @@ -721,7 +736,7 @@ mod test_qsort3 { quick_sort3::(v1); let mut i = 0; while i < len { - debug!(v2[i]); + // debug!(v2[i]); fail_unless!((v2[i] == v1[i])); i += 1; } @@ -768,7 +783,7 @@ mod test_qsort { quick_sort::(v1, leual); let mut i = 0u; while i < len { - debug!(v2[i]); + // debug!(v2[i]); fail_unless!((v2[i] == v1[i])); i += 1; } @@ -919,7 +934,7 @@ mod test_tim_sort { tim_sort::(v1); let mut i = 0u; while i < len { - debug!(v2[i]); + // debug!(v2[i]); fail_unless!((v2[i] == v1[i])); i += 1u; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 63cf4c998df..fcc60c8d978 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -358,7 +358,11 @@ pub fn run_tests_console(opts: &TestOpts, fn print_failures(st: @ConsoleTestState) { st.out.write_line(~"\nfailures:"); - let mut failures = st.failures.map(|t| t.name.to_str()); + let mut failures = ~[]; + for uint::range(0, vec::uniq_len(&const st.failures)) |i| { + let name = copy st.failures[i].name; + failures.push(name.to_str()); + } sort::tim_sort(failures); for vec::each(failures) |name| { st.out.write_line(fmt!(" %s", name.to_str())); diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 7192da7b88e..f4d58568ae7 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -106,10 +106,10 @@ impl<'self, K: TotalOrd, V> impl Container for TreeMap { /// Return the number of elements in the map - pure fn len(&self) -> uint { self.length } + pure fn len(&const self) -> uint { self.length } /// Return true if the map contains no elements - pure fn is_empty(&self) -> bool { self.root.is_none() } + pure fn is_empty(&const self) -> bool { self.root.is_none() } } impl Mutable for TreeMap { @@ -276,11 +276,11 @@ impl Ord for TreeSet { impl Container for TreeSet { /// Return the number of elements in the set #[inline(always)] - pure fn len(&self) -> uint { self.map.len() } + pure fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements #[inline(always)] - pure fn is_empty(&self) -> bool { self.map.is_empty() } + pure fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for TreeSet { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 97719a140a6..538f0de8c84 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -252,8 +252,8 @@ pub impl FileMap { // about what ends a line between this file and parse.rs fn next_line(&self, +pos: BytePos) { // the new charpos must be > the last one (or it's the first one). - fail_unless!((self.lines.len() == 0) - || (self.lines[self.lines.len() - 1] < pos)); + let lines = &mut *self.lines; + fail_unless!((lines.len() == 0) || (lines[lines.len() - 1] < pos)); self.lines.push(pos); } @@ -302,11 +302,12 @@ pub impl CodeMap { +substr: FileSubstr, src: @~str ) -> @FileMap { - let start_pos = if self.files.len() == 0 { + let files = &mut *self.files; + let start_pos = if files.len() == 0 { 0 } else { - let last_start = self.files.last().start_pos.to_uint(); - let last_len = self.files.last().src.len(); + let last_start = files.last().start_pos.to_uint(); + let last_len = files.last().src.len(); last_start + last_len }; @@ -364,7 +365,8 @@ pub impl CodeMap { } pub fn span_to_str(&self, sp: span) -> ~str { - if self.files.len() == 0 && sp == dummy_sp() { + let files = &mut *self.files; + if files.len() == 0 && sp == dummy_sp() { return ~"no-location"; } @@ -409,7 +411,8 @@ pub impl CodeMap { priv impl CodeMap { fn lookup_filemap_idx(&self, +pos: BytePos) -> uint { - let len = self.files.len(); + let files = &*self.files; + let len = files.len(); let mut a = 0u; let mut b = len; while b - a > 1u { @@ -433,10 +436,11 @@ priv impl CodeMap { let idx = self.lookup_filemap_idx(pos); let f = self.files[idx]; let mut a = 0u; - let mut b = f.lines.len(); + let lines = &*f.lines; + let mut b = lines.len(); while b - a > 1u { let m = (a + b) / 2u; - if f.lines[m] > pos { b = m; } else { a = m; } + if lines[m] > pos { b = m; } else { a = m; } } return FileMapAndLine {fm: f, line: a}; } diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index 54b123bff2f..76ab21f403b 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -226,7 +226,7 @@ fn create_eq_method(cx: @ext_ctxt, attrs: ~[], generics: ast_util::empty_generics(), self_ty: self_ty, - purity: pure_fn, + purity: impure_fn, decl: fn_decl, body: body_block, id: cx.next_id(), @@ -405,7 +405,7 @@ fn create_iter_bytes_method(cx: @ext_ctxt, attrs: ~[], generics: ast_util::empty_generics(), self_ty: self_ty, - purity: pure_fn, + purity: impure_fn, decl: fn_decl, body: body_block, id: cx.next_id(), diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 30e7e832db1..29c9e86ec62 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -41,7 +41,8 @@ impl proto::visitor<(), (), ()> for @ext_ctxt { fn visit_proto(&self, _proto: protocol, _states: &[()]) { } fn visit_state(&self, state: state, _m: &[()]) { - if state.messages.len() == 0 { + let messages = &*state.messages; + if messages.len() == 0 { self.span_warn( state.span, // use a real span! fmt!("state %s contains no messages, \ diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index 15ba7f95538..c6fdf4d9c1b 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -91,7 +91,7 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) { let states = str::connect(self_live.map(|s| copy s.name), ~" "); debug!("protocol %s is unbounded due to loops involving: %s", - proto.name, states); + copy proto.name, states); // Someday this will be configurable with a warning //cx.span_warn(empty_span(), @@ -103,7 +103,7 @@ pub fn analyze(proto: protocol, _cx: @ext_ctxt) { proto.bounded = Some(false); } else { - debug!("protocol %s is bounded. yay!", proto.name); + debug!("protocol %s is bounded. yay!", copy proto.name); proto.bounded = Some(true); } } diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index c9680ac02c9..a47b39a45c8 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -156,7 +156,10 @@ pub impl protocol_ { ~"proto://" + self.name } - fn num_states(&mut self) -> uint { self.states.len() } + fn num_states(&mut self) -> uint { + let states = &mut *self.states; + states.len() + } fn has_ty_params(&mut self) -> bool { for self.states.each |s| { @@ -180,9 +183,10 @@ pub impl protocol_ { +generics: ast::Generics) -> state { let messages = @mut ~[]; + let states = &*self.states; let state = @state_ { - id: self.states.len(), + id: states.len(), name: name, ident: ident, span: self.span, diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 908fbd44825..0196ee6d184 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -106,8 +106,9 @@ pub pure fn dup_tt_reader(r: @mut TtReader) -> @mut TtReader { } -pure fn lookup_cur_matched_by_matched(r: @mut TtReader, - start: @named_match) -> @named_match { +pure fn lookup_cur_matched_by_matched(r: &mut TtReader, + start: @named_match) + -> @named_match { pure fn red(+ad: @named_match, idx: &uint) -> @named_match { match *ad { matched_nonterminal(_) => { @@ -117,18 +118,20 @@ pure fn lookup_cur_matched_by_matched(r: @mut TtReader, matched_seq(ref ads, _) => ads[*idx] } } - vec::foldl(start, r.repeat_idx, red) + let r = &mut *r; + let repeat_idx = &r.repeat_idx; + vec::foldl(start, *repeat_idx, red) } -fn lookup_cur_matched(r: @mut TtReader, name: ident) -> @named_match { +fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match { lookup_cur_matched_by_matched(r, r.interpolations.get(&name)) } enum lis { lis_unconstrained, lis_constraint(uint, ident), lis_contradiction(~str) } -fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { - fn lis_merge(lhs: lis, rhs: lis, r: @mut TtReader) -> lis { +fn lockstep_iter_size(t: token_tree, r: &mut TtReader) -> lis { + fn lis_merge(lhs: lis, rhs: lis, r: &mut TtReader) -> lis { match lhs { lis_unconstrained => copy rhs, lis_contradiction(_) => copy lhs, @@ -148,8 +151,10 @@ fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { } match t { tt_delim(ref tts) | tt_seq(_, ref tts, _, _) => { - vec::foldl(lis_unconstrained, (*tts), |lis, tt| - lis_merge(lis, lockstep_iter_size(*tt, r), r)) + vec::foldl(lis_unconstrained, (*tts), |lis, tt| { + let lis2 = lockstep_iter_size(*tt, r); + lis_merge(lis, lis2, r) + }) } tt_tok(*) => lis_unconstrained, tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { @@ -160,12 +165,20 @@ fn lockstep_iter_size(t: token_tree, r: @mut TtReader) -> lis { } -pub fn tt_next_token(r: @mut TtReader) -> TokenAndSpan { +pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { let ret_val = TokenAndSpan { tok: copy r.cur_tok, sp: r.cur_span, }; - while r.cur.idx >= r.cur.readme.len() { + loop { + { + let cur = &mut *r.cur; + let readme = &mut *cur.readme; + if cur.idx < readme.len() { + break; + } + } + /* done with this set; pop or repeat? */ if ! r.cur.dotdotdoted || { *r.repeat_idx.last() == *r.repeat_len.last() - 1 } { diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 09ffd79c246..90f51fe9b65 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -811,7 +811,7 @@ pub mod test { sp:span {lo:BytePos(21),hi:BytePos(23),expn_info: None}}; check_equal (tok1,tok2); // the 'main' id is already read: - check_equal (string_reader.last_pos,BytePos(28)); + check_equal (copy string_reader.last_pos,BytePos(28)); // read another token: let tok3 = string_reader.next_token(); let tok4 = TokenAndSpan{ @@ -819,7 +819,7 @@ pub mod test { sp:span {lo:BytePos(24),hi:BytePos(28),expn_info: None}}; check_equal (tok3,tok4); // the lparen is already read: - check_equal (string_reader.last_pos,BytePos(29)) + check_equal (copy string_reader.last_pos,BytePos(29)) } // check that the given reader produces the desired stream diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2ea304a0a9b..8a883b73a64 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -412,7 +412,8 @@ pub impl Parser { fn parse_purity(&self) -> purity { if self.eat_keyword(&~"pure") { - return pure_fn; + // NB: We parse this as impure for bootstrapping purposes. + return impure_fn; } else if self.eat_keyword(&~"unsafe") { return unsafe_fn; } else { @@ -2668,7 +2669,8 @@ pub impl Parser { fn parse_optional_purity(&self) -> ast::purity { if self.eat_keyword(&~"pure") { - ast::pure_fn + // NB: We parse this as impure for bootstrapping purposes. + ast::impure_fn } else if self.eat_keyword(&~"unsafe") { ast::unsafe_fn } else { @@ -3418,7 +3420,8 @@ pub impl Parser { let prefix = Path(self.sess.cm.span_to_filename(*self.span)); let prefix = prefix.dir_path(); - let mod_path = Path(".").push_many(*self.mod_path_stack); + let mod_path_stack = &*self.mod_path_stack; + let mod_path = Path(".").push_many(*mod_path_stack); let default_path = *self.sess.interner.get(id) + ~".rs"; let file_path = match ::attr::first_attr_value_str_by_name( outer_attrs, ~"path") { @@ -3505,7 +3508,8 @@ pub impl Parser { if self.eat_keyword(&~"fn") { impure_fn } else if self.eat_keyword(&~"pure") { self.expect_keyword(&~"fn"); - pure_fn + // NB: We parse this as impure for bootstrapping purposes. + impure_fn } else if self.eat_keyword(&~"unsafe") { self.expect_keyword(&~"fn"); unsafe_fn @@ -3894,8 +3898,9 @@ pub impl Parser { maybe_append(attrs, extra_attrs))); } else if items_allowed && self.eat_keyword(&~"pure") { // PURE FUNCTION ITEM + // NB: We parse this as impure for bootstrapping purposes. self.expect_keyword(&~"fn"); - let (ident, item_, extra_attrs) = self.parse_item_fn(pure_fn); + let (ident, item_, extra_attrs) = self.parse_item_fn(impure_fn); return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_, visibility, maybe_append(attrs, extra_attrs))); diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 7f46e452299..492ecdb3f4d 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -452,9 +452,10 @@ pub impl Printer { self.pending_indentation += amount; } fn get_top(&mut self) -> print_stack_elt { - let n = self.print_stack.len(); + let print_stack = &mut *self.print_stack; + let n = print_stack.len(); if n != 0u { - self.print_stack[n - 1u] + print_stack[n - 1u] } else { print_stack_elt { offset: 0, @@ -496,7 +497,8 @@ pub impl Printer { } END => { debug!("print END -> pop END"); - fail_unless!((self.print_stack.len() != 0u)); + let print_stack = &*self.print_stack; + fail_unless!((print_stack.len() != 0u)); self.print_stack.pop(); } BREAK(b) => { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5aae5570dbf..71f3de17414 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -279,9 +279,10 @@ pub fn is_bol(s: @ps) -> bool { } pub fn in_cbox(s: @ps) -> bool { - let len = s.boxes.len(); + let boxes = &*s.boxes; + let len = boxes.len(); if len == 0u { return false; } - return s.boxes[len - 1u] == pp::consistent; + return boxes[len - 1u] == pp::consistent; } pub fn hardbreak_if_not_bol(s: @ps) { if !is_bol(s) { hardbreak(s.s); } } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 7a5708049e9..47f49ebadaa 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -41,14 +41,18 @@ pub impl Interner { None => (), } - let new_idx = self.vect.len(); + let vect = &*self.vect; + let new_idx = vect.len(); self.map.insert(val, new_idx); self.vect.push(val); new_idx } fn gensym(&self, val: T) -> uint { - let new_idx = self.vect.len(); + let new_idx = { + let vect = &*self.vect; + vect.len() + }; // leave out of .map to avoid colliding self.vect.push(val); new_idx @@ -59,7 +63,7 @@ pub impl Interner { // where we first check a pred and then rely on it, ceasing to fail is ok. pure fn get(&self, idx: uint) -> T { self.vect[idx] } - fn len(&self) -> uint { self.vect.len() } + fn len(&self) -> uint { let vect = &*self.vect; vect.len() } } #[test] diff --git a/src/test/compile-fail/borrowck-pat-enum-in-box.rs b/src/test/compile-fail/borrowck-pat-enum-in-box.rs index fe5f474a5f2..bd1001bf38c 100644 --- a/src/test/compile-fail/borrowck-pat-enum-in-box.rs +++ b/src/test/compile-fail/borrowck-pat-enum-in-box.rs @@ -22,17 +22,6 @@ fn match_const_box(v: &const @const Option) -> int { } } -pure fn pure_process(_i: int) {} - -fn match_const_box_and_do_pure_things(v: &const @const Option) { - match *v { - @Some(ref i) => { - pure_process(*i) - } - @None => {} - } -} - fn process(_i: int) {} fn match_const_box_and_do_bad_things(v: &const @const Option) { diff --git a/src/test/compile-fail/borrowck-pure-scope-in-call.rs b/src/test/compile-fail/borrowck-pure-scope-in-call.rs deleted file mode 100644 index 7ff13739ba7..00000000000 --- a/src/test/compile-fail/borrowck-pure-scope-in-call.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pure fn pure_borrow(_x: &int, _y: ()) {} - -fn test1(x: @mut ~int) { - // Here, evaluating the second argument actually invalidates the - // first borrow, even though it occurs outside of the scope of the - // borrow! - pure_borrow(*x, *x = ~5); //~ ERROR illegal borrow unless pure - //~^ NOTE impure due to assigning to dereference of mutable @ pointer -} - -fn test2() { - let mut x = ~1; - - // Same, but for loanable data: - - pure_borrow(x, x = ~5); //~ ERROR assigning to mutable local variable prohibited due to outstanding loan - //~^ NOTE loan of mutable local variable granted here - - copy x; -} - -fn main() { -} diff --git a/src/test/compile-fail/nontrivial-fn-arg-pattern-in-pure-fn.rs b/src/test/compile-fail/nontrivial-fn-arg-pattern-in-pure-fn.rs deleted file mode 100644 index c60eec6edd5..00000000000 --- a/src/test/compile-fail/nontrivial-fn-arg-pattern-in-pure-fn.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pure fn call_first((x, _y): (&fn(), &fn())) { - x(); //~ ERROR access to impure function prohibited in pure context -} - -fn main() {} - diff --git a/src/test/compile-fail/pure-higher-order.rs b/src/test/compile-fail/pure-higher-order.rs deleted file mode 100644 index 6d262bc04e1..00000000000 --- a/src/test/compile-fail/pure-higher-order.rs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[legacy_modes]; - -// Test rules governing higher-order pure fns. - -struct S<'self> { - f: &'self fn(uint) -} - -pure fn range(from: uint, to: uint, f: &fn(uint)) { - let mut i = from; - while i < to { - f(i); // Note: legal to call argument, even if it is not pure. - i += 1u; - } -} - -pure fn range2(from: uint, to: uint, f: &fn(uint)) { - do range(from, to) |i| { - f(i*2u); - } -} - -pure fn range3(from: uint, to: uint, f: &fn(uint)) { - range(from, to, f) -} - -pure fn range4(from: uint, to: uint) { - range(from, to, print) //~ ERROR access to impure function prohibited in pure context -} - -pure fn range5<'a>(from: uint, to: uint, x: S<'a>) { - range(from, to, x.f) //~ ERROR access to impure function prohibited in pure context -} - -pure fn range6<'a>(from: uint, to: uint, x: @S<'a>) { - range(from, to, x.f) //~ ERROR access to impure function prohibited in pure context -} - -pure fn range7(from: uint, to: uint) { - do range(from, to) |i| { - print(i); //~ ERROR access to impure function prohibited in pure context - } -} - -pure fn range8(from: uint, to: uint) { - range(from, to, noop); -} - -fn print(i: uint) { error!("i=%u", i); } - -pure fn noop(_i: uint) {} - -fn main() { -} diff --git a/src/test/compile-fail/pure-loop-body.rs b/src/test/compile-fail/pure-loop-body.rs deleted file mode 100644 index 43a54981dcb..00000000000 --- a/src/test/compile-fail/pure-loop-body.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S<'self> { - x: &'self fn(uint) -} - -pure fn range<'a>(from: uint, to: uint, f: &'a fn(uint) -> bool) { - let mut i = from; - while i < to { - if !f(i) {return;} // Note: legal to call argument, even if it is not pure. - i += 1u; - } -} - -pure fn range2<'a>(from: uint, to: uint, f: &'a fn(uint)) { - for range(from, to) |i| { - f(i*2u); - } -} - -pure fn range3<'a>(from: uint, to: uint, f: S<'a>) { - for range(from, to) |i| { - (f.x)(i*2u); //~ ERROR access to impure function prohibited - } -} - -fn main() {} diff --git a/src/test/compile-fail/pure-modifies-aliased.rs b/src/test/compile-fail/pure-modifies-aliased.rs deleted file mode 100644 index 4bd56c6e78b..00000000000 --- a/src/test/compile-fail/pure-modifies-aliased.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Check that pure functions cannot modify aliased state. - -struct S { - f: int, -} - -pure fn modify_in_box(sum: @mut S) { - sum.f = 3; //~ ERROR assigning to mutable field prohibited in pure context -} - -trait modify_in_box_rec { - pure fn modify_in_box_rec(&self, sum: @mut S); -} - -impl modify_in_box_rec for int { - pure fn modify_in_box_rec(&self, sum: @mut S) { - sum.f = *self; //~ ERROR assigning to mutable field prohibited in pure context - } -} - -fn main() { -} diff --git a/src/test/compile-fail/pure-subtyping.rs b/src/test/compile-fail/pure-subtyping.rs deleted file mode 100644 index 2744afb113d..00000000000 --- a/src/test/compile-fail/pure-subtyping.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test rules governing higher-order pure fns. - -fn take(_v: T) {} - -fn assign_to_pure(x: &pure fn(), y: &fn(), z: &unsafe fn()) { - take::<&pure fn()>(x); - take::<&pure fn()>(y); //~ ERROR expected pure fn but found impure fn - take::<&pure fn()>(z); //~ ERROR expected pure fn but found unsafe fn -} - -fn assign_to_impure(x: &pure fn(), y: &fn(), z: &unsafe fn()) { - take::<&fn()>(x); - take::<&fn()>(y); - take::<&fn()>(z); //~ ERROR expected impure fn but found unsafe fn -} - -fn assign_to_unsafe(x: &pure fn(), y: &fn(), z: &unsafe fn()) { - take::<&unsafe fn()>(x); - take::<&unsafe fn()>(y); - take::<&unsafe fn()>(z); -} - -fn assign_to_pure2(x: @pure fn(), y: @fn(), z: @unsafe fn()) { - take::<&pure fn()>(x); - take::<&pure fn()>(y); //~ ERROR expected pure fn but found impure fn - take::<&pure fn()>(z); //~ ERROR expected pure fn but found unsafe fn - - take::<~pure fn()>(x); //~ ERROR expected ~ closure, found @ closure - take::<~pure fn()>(y); //~ ERROR expected ~ closure, found @ closure - take::<~pure fn()>(z); //~ ERROR expected ~ closure, found @ closure - - take::<~unsafe fn()>(x); //~ ERROR expected ~ closure, found @ closure - take::<~unsafe fn()>(y); //~ ERROR expected ~ closure, found @ closure - take::<~unsafe fn()>(z); //~ ERROR expected ~ closure, found @ closure -} - -fn main() { -} diff --git a/src/test/compile-fail/purity-infer-fail.rs b/src/test/compile-fail/purity-infer-fail.rs deleted file mode 100644 index 3e5296530fa..00000000000 --- a/src/test/compile-fail/purity-infer-fail.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn something(f: &pure fn()) { f(); } - -fn main() { - let mut x = ~[]; - something(|| x.push(0) ); //~ ERROR access to impure function prohibited in pure context -} diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs index 6931e680e08..6676cde3c96 100644 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ b/src/test/compile-fail/trait-impl-method-mismatch.rs @@ -9,15 +9,15 @@ // except according to those terms. trait Mumbo { - pure fn jumbo(&self, x: @uint) -> uint; + fn jumbo(&self, x: @uint) -> uint; fn jambo(&self, x: @const uint) -> uint; fn jbmbo(&self) -> @uint; } impl Mumbo for uint { // Cannot have a larger effect than the trait: - fn jumbo(&self, x: @uint) { *self + *x; } - //~^ ERROR expected pure fn but found impure fn + unsafe fn jumbo(&self, x: @uint) { *self + *x; } + //~^ ERROR expected impure fn but found unsafe fn // Cannot accept a narrower range of parameters: fn jambo(&self, x: @uint) { *self + *x; } diff --git a/src/test/run-pass/auto-ref-slice-plus-ref.rs b/src/test/run-pass/auto-ref-slice-plus-ref.rs index ea41a50e382..39fe34bfe52 100644 --- a/src/test/run-pass/auto-ref-slice-plus-ref.rs +++ b/src/test/run-pass/auto-ref-slice-plus-ref.rs @@ -39,7 +39,6 @@ pub fn main() { (&"test").test_imm(); // XXX: Other types of mutable vecs don't currently exist - (@mut [1]).test_imm(); ([1]).test_const(); (~[1]).test_const(); @@ -50,8 +49,6 @@ pub fn main() { (@"test").test_const(); (&"test").test_const(); - (@mut [1]).test_const(); - // NB: We don't do this double autoreffing for &mut self because that would // allow creating a mutable pointer to a temporary, which would be a source // of confusion diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 0c285258f75..a0a4ea19964 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -62,8 +62,8 @@ impl BaseIter<(int, &'self T)> for cat { } impl Container for cat { - pure fn len(&self) -> uint { self.meows as uint } - pure fn is_empty(&self) -> bool { self.meows == 0 } + pure fn len(&const self) -> uint { self.meows as uint } + pure fn is_empty(&const self) -> bool { self.meows == 0 } } impl Mutable for cat { diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs index 37770f4d59b..905046756f6 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs @@ -10,8 +10,4 @@ fn negate_imm(y: &int) -> int { negate(y) } -fn negate_const(y: &const int) -> int { - negate(y) -} - pub fn main() {} diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs index 8fab061b4de..54d9758aa21 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs @@ -3,7 +3,7 @@ struct SpeechMaker { } pub impl SpeechMaker { - pure fn how_many(&self) -> uint { self.speeches } + pure fn how_many(&const self) -> uint { self.speeches } } fn foo(speaker: &const SpeechMaker) -> uint { diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs index ba7d78ba04f..a18b4a2b0c6 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs @@ -1,3 +1,5 @@ +// xfail-test + pure fn sum(x: &[int]) -> int { let mut sum = 0; for x.each |y| { sum += *y; } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index 7ab63f43769..bf86472d900 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -1,3 +1,5 @@ +// xfail-test + fn foo(v: &[const uint]) -> ~[uint] { v.to_vec() } diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 3f94600ea17..2e70e900389 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -16,6 +16,6 @@ struct Refs { refs: ~[int], n: int } pub fn main() { let e = @mut Refs{refs: ~[], n: 0}; - let f: @fn() = || error!(e.n); + let f: @fn() = || error!(copy e.n); e.refs += ~[1]; }