librustc: Convert all uses of old lifetime notation to new lifetime notation. rs=delifetiming
This commit is contained in:
parent
7352d919f6
commit
352c070365
147 changed files with 523 additions and 501 deletions
|
@ -174,9 +174,9 @@ pub mod traits {
|
|||
use kinds::Copy;
|
||||
use ops::Add;
|
||||
|
||||
impl<T:Copy> Add<&self/[const T],@[T]> for @[T] {
|
||||
impl<T:Copy> 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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,17 +59,17 @@ pub unsafe fn transmute<L, G>(thing: L) -> G {
|
|||
|
||||
/// Coerce an immutable reference to be mutable.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_mut<T>(ptr: &a/T) -> &a/mut T { transmute(ptr) }
|
||||
pub unsafe fn transmute_mut<T>(ptr: &'a T) -> &'a mut T { transmute(ptr) }
|
||||
|
||||
/// Coerce a mutable reference to be immutable.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_immut<T>(ptr: &a/mut T) -> &a/T {
|
||||
pub unsafe fn transmute_immut<T>(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<T>(ptr: &a/T) -> &b/T { transmute(ptr) }
|
||||
pub unsafe fn transmute_region<T>(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<T>(ptr: *const T) -> *T {
|
|||
|
||||
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
|
||||
#[inline(always)]
|
||||
pub unsafe fn transmute_mut_region<T>(ptr: &a/mut T) -> &b/mut T {
|
||||
pub unsafe fn transmute_mut_region<T>(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<S,T>(_ptr: &a/S, ptr: &T) -> &a/T {
|
||||
pub unsafe fn copy_lifetime<S,T>(_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<S,T>(_ptr: &a/[S], ptr: &T) -> &a/T {
|
||||
pub unsafe fn copy_lifetime_vec<S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
|
||||
transmute_region(ptr)
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ pub struct Handler<T, U> {
|
|||
}
|
||||
|
||||
pub struct Condition<T, U> {
|
||||
name: &static/str,
|
||||
name: &'static str,
|
||||
key: task::local_data::LocalDataKey/&self<Handler<T, U>>
|
||||
}
|
||||
|
||||
pub impl<T, U> Condition/&self<T, U> {
|
||||
fn trap(&self, h: &self/fn(T) -> U) -> Trap/&self<T, U> {
|
||||
fn trap(&self, h: &'self fn(T) -> U) -> Trap/&self<T, U> {
|
||||
unsafe {
|
||||
let p : *RustClosure = ::cast::transmute(&h);
|
||||
let prev = task::local_data::local_data_get(self.key);
|
||||
|
@ -65,12 +65,12 @@ pub impl<T, U> Condition/&self<T, U> {
|
|||
}
|
||||
|
||||
struct Trap<T, U> {
|
||||
cond: &self/Condition/&self<T, U>,
|
||||
cond: &'self Condition/&self<T, U>,
|
||||
handler: @Handler<T, U>
|
||||
}
|
||||
|
||||
pub impl<T, U> Trap/&self<T, U> {
|
||||
fn in<V>(&self, inner: &self/fn() -> V) -> V {
|
||||
fn in<V>(&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<T, U> Trap/&self<T, U> {
|
|||
}
|
||||
|
||||
struct Guard<T, U> {
|
||||
cond: &self/Condition/&self<T, U>
|
||||
cond: &'self Condition/&self<T, U>
|
||||
}
|
||||
|
||||
impl<T, U> Drop for Guard/&self<T, U> {
|
||||
|
|
|
@ -39,7 +39,7 @@ pub trait Map<K, V>: 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
|
||||
|
|
|
@ -122,7 +122,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
|
|||
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.
|
||||
|
|
|
@ -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<K:Hash + IterBytes + Eq,V>
|
||||
BaseIter<(&self/K, &self/V)> for LinearMap<K, V>
|
||||
BaseIter<(&'self K, &'self V)> for LinearMap<K, V>
|
||||
{
|
||||
/// 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<Q:Hash + IterBytes + Equiv<K>>(&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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use option::{None, Option, Some};
|
|||
use vec;
|
||||
|
||||
/// A function used to initialize the elements of a sequence
|
||||
pub type InitOp<T> = &self/fn(uint) -> T;
|
||||
pub type InitOp<T> = &'self fn(uint) -> T;
|
||||
|
||||
pub trait BaseIter<A> {
|
||||
pure fn each(&self, blk: &fn(v: &A) -> bool);
|
||||
|
|
|
@ -122,7 +122,7 @@ pub pure fn get<T:Copy>(opt: Option<T>) -> T {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
|
||||
pub pure fn get_ref<T>(opt: &'r Option<T>) -> &'r T {
|
||||
/*!
|
||||
Gets an immutable reference to the value inside an option.
|
||||
|
||||
|
@ -143,7 +143,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
|
|||
}
|
||||
}
|
||||
|
||||
pub pure fn get_mut_ref<T>(opt: &r/mut Option<T>) -> &r/mut T {
|
||||
pub pure fn get_mut_ref<T>(opt: &'r mut Option<T>) -> &'r mut T {
|
||||
/*!
|
||||
Gets a mutable reference to the value inside an option.
|
||||
|
||||
|
@ -165,7 +165,7 @@ pub pure fn get_mut_ref<T>(opt: &r/mut Option<T>) -> &r/mut T {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn map<T, U>(opt: &r/Option<T>, f: &fn(x: &r/T) -> U) -> Option<U> {
|
||||
pub pure fn map<T, U>(opt: &'r Option<T>, f: &fn(x: &'r T) -> U) -> Option<U> {
|
||||
//! 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<T:Copy>(opt: Option<T>, def: T) -> T {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub pure fn map_default<T, U>(opt: &r/Option<T>, def: U,
|
||||
f: &fn(&r/T) -> U) -> U {
|
||||
pub pure fn map_default<T, U>(opt: &'r Option<T>, 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<T>(opt: Option<T>, reason: &str) -> T {
|
|||
impl<T> BaseIter<T> for Option<T> {
|
||||
/// 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<T> Option<T> {
|
|||
|
||||
/// Maps a `some` value from one type to another by reference
|
||||
#[inline(always)]
|
||||
pure fn map<U>(&self, f: &fn(&self/T) -> U) -> Option<U> { map(self, f) }
|
||||
pure fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> { map(self, f) }
|
||||
|
||||
/// As `map`, but consumes the option and gives `f` ownership to avoid
|
||||
/// copying.
|
||||
|
@ -361,7 +361,7 @@ pub impl<T> Option<T> {
|
|||
|
||||
/// Applies a function to the contained value or returns a default
|
||||
#[inline(always)]
|
||||
pure fn map_default<U>(&self, def: U, f: &fn(&self/T) -> U) -> U {
|
||||
pure fn map_default<U>(&self, def: U, f: &fn(&'self T) -> U) -> U {
|
||||
map_default(self, def, f)
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ pub impl<T> Option<T> {
|
|||
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<T> Option<T> {
|
|||
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.
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
|
|||
let p = unsafe { &*p_ };
|
||||
|
||||
struct DropState {
|
||||
p: &self/PacketHeader,
|
||||
p: &'self PacketHeader,
|
||||
|
||||
drop {
|
||||
if task::failing() {
|
||||
|
|
|
@ -178,7 +178,7 @@ pub pure fn to_uint<T>(thing: &T) -> uint {
|
|||
|
||||
/// Determine if two borrowed pointers point to the same thing.
|
||||
#[inline(always)]
|
||||
pub pure fn ref_eq<T>(thing: &a/T, other: &b/T) -> bool {
|
||||
pub pure fn ref_eq<T>(thing: &'a T, other: &'b T) -> bool {
|
||||
to_uint(thing) == to_uint(other)
|
||||
}
|
||||
|
||||
|
@ -312,34 +312,34 @@ impl<T> Ord for *const T {
|
|||
|
||||
// Equality for region pointers
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> Eq for &self/const T {
|
||||
impl<T:Eq> 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<T:Ord> Ord for &self/const T {
|
||||
impl<T:Ord> 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,9 +214,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
|||
}
|
||||
|
||||
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<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
|||
}
|
||||
|
||||
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<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
|||
}
|
||||
|
||||
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<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ pub pure fn get<T:Copy,U>(res: &Result<T, U>) -> T {
|
|||
* If the result is an error
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub pure fn get_ref<T, U>(res: &a/Result<T, U>) -> &a/T {
|
||||
pub pure fn get_ref<T, U>(res: &'a Result<T, U>) -> &'a T {
|
||||
match *res {
|
||||
Ok(ref t) => t,
|
||||
Err(ref the_err) => unsafe {
|
||||
|
@ -229,7 +229,7 @@ pub pure fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F)
|
|||
|
||||
pub impl<T, E> Result<T, E> {
|
||||
#[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) }
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -659,7 +659,7 @@ fn install_watcher_data<H, W: Watcher + NativeHandle<*H>>(watcher: &mut W) {
|
|||
}
|
||||
|
||||
fn get_watcher_data<H, W: Watcher + NativeHandle<*H>>(
|
||||
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());
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<uint> {
|
||||
pub pure fn find_str(haystack: &'a str, needle: &'b str) -> Option<uint> {
|
||||
find_str_between(haystack, needle, 0u, len(haystack))
|
||||
}
|
||||
|
||||
|
@ -1390,7 +1390,7 @@ pub pure fn find_str(haystack: &a/str, needle: &b/str) -> Option<uint> {
|
|||
*
|
||||
* `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<uint> {
|
||||
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<uint> {
|
||||
// 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<T>(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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -44,7 +44,7 @@ use task::rt;
|
|||
*
|
||||
* These two cases aside, the interface is safe.
|
||||
*/
|
||||
pub type LocalDataKey<T> = &self/fn(v: @T);
|
||||
pub type LocalDataKey<T> = &'self fn(v: @T);
|
||||
|
||||
/**
|
||||
* Remove a task-local data value from the table, returning the
|
||||
|
|
|
@ -123,7 +123,7 @@ struct TaskGroupData {
|
|||
}
|
||||
type TaskGroupArc = unstable::Exclusive<Option<TaskGroupData>>;
|
||||
|
||||
type TaskGroupInner = &self/mut Option<TaskGroupData>;
|
||||
type TaskGroupInner = &'self mut Option<TaskGroupData>;
|
||||
|
||||
// A taskgroup is 'dead' when nothing can cause it to fail; only members can.
|
||||
pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
|
||||
|
|
|
@ -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<A:IterBytes> IterBytes for &self/[A] {
|
||||
impl<A:IterBytes> IterBytes for &'self [A] {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
for (*self).each |elt| {
|
||||
|
@ -231,7 +231,7 @@ impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) {
|
|||
}
|
||||
|
||||
// Move this to vec, probably.
|
||||
pure fn borrow<A>(a: &x/[A]) -> &x/[A] {
|
||||
pure fn borrow<A>(a: &'x [A]) -> &'x [A] {
|
||||
a
|
||||
}
|
||||
|
||||
|
@ -352,7 +352,7 @@ pub pure fn iter_bytes_7<A: IterBytes,
|
|||
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||
}
|
||||
|
||||
impl IterBytes for &self/str {
|
||||
impl IterBytes for &'self str {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||
do str::byte_slice(*self) |bytes| {
|
||||
|
@ -389,7 +389,7 @@ impl<A:IterBytes> IterBytes for Option<A> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<A:IterBytes> IterBytes for &self/A {
|
||||
impl<A:IterBytes> IterBytes for &'self A {
|
||||
#[inline(always)]
|
||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||
(**self).iter_bytes(lsb0, f);
|
||||
|
|
|
@ -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<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
|
|||
}
|
||||
}
|
||||
|
||||
impl<A:ToStr> ToStr for &self/[A] {
|
||||
impl<A:ToStr> ToStr for &'self [A] {
|
||||
#[inline(always)]
|
||||
pure fn to_str(&self) -> ~str {
|
||||
unsafe {
|
||||
|
|
|
@ -32,7 +32,7 @@ pub struct TrieMap<T> {
|
|||
impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
/// 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<T> BaseIter<(uint, &'self T)> for TrieMap<T> {
|
|||
impl<T> ReverseIter<(uint, &'self T)> for TrieMap<T> {
|
||||
/// 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<T> Map<uint, T> for TrieMap<T> {
|
|||
|
||||
/// 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<T> = &self.root;
|
||||
pure fn find(&self, key: &uint) -> Option<&'self T> {
|
||||
let mut node: &'self TrieNode<T> = &self.root;
|
||||
let mut idx = 0;
|
||||
loop {
|
||||
match node.children[chunk(*key, idx)] {
|
||||
|
@ -233,7 +233,7 @@ impl<T> TrieNode<T> {
|
|||
}
|
||||
|
||||
impl<T> TrieNode<T> {
|
||||
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<T> TrieNode<T> {
|
|||
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 },
|
||||
|
|
|
@ -47,19 +47,19 @@ impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
|
|||
}
|
||||
|
||||
pub trait ImmutableTuple<T, U> {
|
||||
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<T, U> ImmutableTuple<T, U> 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<A,B> {
|
|||
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C];
|
||||
}
|
||||
|
||||
impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&self/[A], &self/[B]) {
|
||||
impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
|
||||
#[inline(always)]
|
||||
fn zip(&self) -> ~[(A, B)] {
|
||||
match *self {
|
||||
|
|
|
@ -173,7 +173,7 @@ pub unsafe fn get_shared_mutable_state<T:Owned>(
|
|||
}
|
||||
#[inline(always)]
|
||||
pub unsafe fn get_shared_immutable_state<T:Owned>(
|
||||
rc: &a/SharedMutableState<T>) -> &a/T {
|
||||
rc: &'a SharedMutableState<T>) -> &'a T {
|
||||
unsafe {
|
||||
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
|
||||
fail_unless!(ptr.count > 0);
|
||||
|
|
|
@ -31,7 +31,7 @@ pub trait Finally<T> {
|
|||
fn finally(&self, dtor: &fn()) -> T;
|
||||
}
|
||||
|
||||
impl<T> Finally<T> for &self/fn() -> T {
|
||||
impl<T> Finally<T> for &'self fn() -> T {
|
||||
fn finally(&self, dtor: &fn()) -> T {
|
||||
let _d = Finallyalizer {
|
||||
dtor: dtor
|
||||
|
@ -42,7 +42,7 @@ impl<T> Finally<T> for &self/fn() -> T {
|
|||
}
|
||||
|
||||
struct Finallyalizer {
|
||||
dtor: &self/fn()
|
||||
dtor: &'self fn()
|
||||
}
|
||||
|
||||
impl Drop for Finallyalizer/&self {
|
||||
|
|
|
@ -42,7 +42,7 @@ use sys::Closure;
|
|||
#[cfg(test)] use task::spawn;
|
||||
#[cfg(test)] use uint;
|
||||
|
||||
pub type GlobalDataKey<T> = &self/fn(v: T);
|
||||
pub type GlobalDataKey<T> = &'self fn(v: T);
|
||||
|
||||
pub unsafe fn global_data_clone_create<T:Owned + Clone>(
|
||||
key: GlobalDataKey<T>, create: &fn() -> ~T) -> T {
|
||||
|
|
|
@ -217,46 +217,46 @@ pub pure fn build_sized_opt<A>(size: Option<uint>,
|
|||
// Accessors
|
||||
|
||||
/// Returns the first element of a vector
|
||||
pub pure fn head<T>(v: &r/[T]) -> &r/T {
|
||||
pub pure fn head<T>(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<T>(v: &r/[T]) -> Option<&r/T> {
|
||||
pub pure fn head_opt<T>(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<T>(v: &r/[T]) -> &r/[T] { slice(v, 1, v.len()) }
|
||||
pub pure fn tail<T>(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<T>(v: &r/[T], n: uint) -> &r/[T] { slice(v, n, v.len()) }
|
||||
pub pure fn tailn<T>(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<T>(v: &r/[T]) -> &r/[T] { slice(v, 0, v.len() - 1) }
|
||||
pub pure fn init<T>(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<T>(v: &r/[T], n: uint) -> &r/[T] {
|
||||
pub pure fn initn<T>(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<T>(v: &r/[T]) -> &r/T {
|
||||
pub pure fn last<T>(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<T>(v: &r/[T]) -> Option<&r/T> {
|
||||
pub pure fn last_opt<T>(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<T>(v: &r/[T], start: uint, end: uint) -> &r/[T] {
|
||||
pub pure fn slice<T>(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<T>(v: &r/[T], start: uint, end: uint) -> &r/[T] {
|
|||
|
||||
/// Return a slice that points into another slice.
|
||||
#[inline(always)]
|
||||
pub pure fn mut_slice<T>(v: &r/mut [T],
|
||||
pub pure fn mut_slice<T>(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<T>(v: &r/mut [T],
|
|||
|
||||
/// Return a slice that points into another slice.
|
||||
#[inline(always)]
|
||||
pub pure fn const_slice<T>(v: &r/[const T],
|
||||
pub pure fn const_slice<T>(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<T:Copy>(v: &[const T]) -> ~[T] {
|
|||
* ~~~
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub pure fn each<T>(v: &r/[T], f: &fn(&r/T) -> bool) {
|
||||
pub pure fn each<T>(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<T>(v: &[const T], f: &fn(elem: &const T) -> bool) {
|
|||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub pure fn eachi<T>(v: &r/[T], f: &fn(uint, v: &r/T) -> bool) {
|
||||
pub pure fn eachi<T>(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<T>(v: &r/[T], f: &fn(uint, v: &r/T) -> bool) {
|
|||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub pure fn rev_each<T>(v: &r/[T], blk: &fn(v: &r/T) -> bool) {
|
||||
pub pure fn rev_each<T>(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<T>(v: &r/[T], blk: &fn(v: &r/T) -> bool) {
|
|||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pub pure fn rev_eachi<T>(v: &r/[T], blk: &fn(i: uint, v: &r/T) -> bool) {
|
||||
pub pure fn rev_eachi<T>(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<T:Eq>(a: &[T], b: &[T]) -> bool {
|
|||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> Eq for &self/[T] {
|
||||
impl<T:Eq> 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<T: TotalOrd>(a: &[T], b: &[T]) -> Ordering {
|
|||
#[cfg(notest)]
|
||||
impl<T: TotalOrd> 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<T:Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) }
|
|||
pure fn gt<T:Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Ord> Ord for &self/[T] {
|
||||
impl<T:Ord> 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<T:Copy> Add<&self/[const T],~[T]> for ~[T] {
|
||||
impl<T:Copy> 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<T> Container for &self/[const T] {
|
||||
impl<T> 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<T: Copy> CopyableVector<T> for &'self [const T] {
|
|||
}
|
||||
|
||||
pub trait ImmutableVector<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 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<U: Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U;
|
||||
pure fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U];
|
||||
pure fn mapi<U>(&self, f: &fn(uint, t: &T) -> U) -> ~[U];
|
||||
|
@ -1731,44 +1731,44 @@ pub trait ImmutableVector<T> {
|
|||
}
|
||||
|
||||
/// Extension methods for vectors
|
||||
impl<T> ImmutableVector<T> for &self/[T] {
|
||||
impl<T> ImmutableVector<T> 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<T:Eq> {
|
|||
pure fn rposition_elem(&self, t: &T) -> Option<uint>;
|
||||
}
|
||||
|
||||
impl<T:Eq> ImmutableEqVector<T> for &self/[T] {
|
||||
impl<T:Eq> ImmutableEqVector<T> for &'self [T] {
|
||||
/**
|
||||
* Find the first index matching some predicate
|
||||
*
|
||||
|
@ -1879,7 +1879,7 @@ pub trait ImmutableCopyableVector<T> {
|
|||
}
|
||||
|
||||
/// Extension methods for vectors
|
||||
impl<T:Copy> ImmutableCopyableVector<T> for &self/[T] {
|
||||
impl<T:Copy> ImmutableCopyableVector<T> 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::<T>());
|
||||
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::<T>());
|
||||
let v : *(&blk/mut [T]) =
|
||||
let v : *(&'blk mut [T]) =
|
||||
::cast::reinterpret_cast(&addr_of(&pair));
|
||||
f(*v)
|
||||
}
|
||||
|
@ -2327,7 +2327,7 @@ impl<A> iter::MutableIter<A> for @mut [A] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<A> iter::ExtendedIter<A> for &self/[A] {
|
||||
impl<A> iter::ExtendedIter<A> for &'self [A] {
|
||||
pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
|
||||
iter::eachi(self, blk)
|
||||
}
|
||||
|
@ -2404,7 +2404,7 @@ impl<A> iter::ExtendedIter<A> for @[A] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<A:Eq> iter::EqIter<A> for &self/[A] {
|
||||
impl<A:Eq> iter::EqIter<A> 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<A:Eq> iter::EqIter<A> for @[A] {
|
|||
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
||||
}
|
||||
|
||||
impl<A:Copy> iter::CopyableIter<A> for &self/[A] {
|
||||
impl<A:Copy> iter::CopyableIter<A> 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<A:Copy> iter::CopyableIter<A> for @[A] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for &self/[A] {
|
||||
impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for &'self [A] {
|
||||
pure fn min(&self) -> A { iter::min(self) }
|
||||
pure fn max(&self) -> A { iter::max(self) }
|
||||
}
|
||||
|
@ -2470,7 +2470,7 @@ impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for @[A] {
|
|||
pure fn max(&self) -> A { iter::max(self) }
|
||||
}
|
||||
|
||||
impl<A:Copy> iter::CopyableNonstrictIter<A> for &self/[A] {
|
||||
impl<A:Copy> iter::CopyableNonstrictIter<A> for &'self [A] {
|
||||
pure fn each_val(&const self, f: &fn(A) -> bool) {
|
||||
let mut i = 0;
|
||||
while i < self.len() {
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<ebml::Doc> {
|
||||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -21,7 +21,7 @@ use core::result::Result;
|
|||
use core::result;
|
||||
use core::str;
|
||||
|
||||
pub type pick<T> = &self/fn(path: &Path) -> Option<T>;
|
||||
pub type pick<T> = &'self fn(path: &Path) -> Option<T>;
|
||||
|
||||
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
|
||||
if path.file_path() == file { option::Some(copy *path) }
|
||||
|
|
|
@ -49,7 +49,7 @@ pub enum DefIdSource {
|
|||
// Identifies a type parameter (`fn foo<X>() { ... }`).
|
||||
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],
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<node_id, ()>;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -212,7 +212,7 @@ pub impl<T> ResolveResult<T> {
|
|||
|
||||
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.
|
||||
|
|
|
@ -327,7 +327,7 @@ pub type BindingsMap = HashMap<ident, BindingInfo>;
|
|||
|
||||
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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<def_id, ()>,
|
||||
inherent_candidates: @mut ~[Candidate],
|
||||
extension_candidates: @mut ~[Candidate],
|
||||
|
|
|
@ -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
|
||||
* }
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -58,7 +58,7 @@ pub trait LatticeValue {
|
|||
-> cres<Self>;
|
||||
}
|
||||
|
||||
pub type LatticeOp<T> = &self/fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
|
||||
pub type LatticeOp<T> = &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
|
||||
|
||||
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<L:LatticeDir + TyLatticeDir + Combine>(
|
|||
}
|
||||
}
|
||||
|
||||
pub type LatticeDirOp<T> = &self/fn(a: &T, b: &T) -> cres<T>;
|
||||
pub type LatticeDirOp<T> = &'self fn(a: &T, b: &T) -> cres<T>;
|
||||
|
||||
pub enum LatticeVarResult<V,T> {
|
||||
VarResult(V),
|
||||
|
|
|
@ -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>(&a/int)` to indicate that `a` is a lifetime
|
||||
notation like `fn<a>(&'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>(&a/int) <: &fn(&self/int)? (Yes, a => self)
|
||||
fn<a>(&'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>(&a/int)? (No)
|
||||
fn(&'self int) <: &fn<a>(&'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,b>(&a/int, &b/int) <: &fn<a>(&a/int, &a/int)? (Yes)
|
||||
fn<a>(&a/int, &a/int) <: &fn<a,b>(&a/int, &b/int)? (No)
|
||||
fn<a,b>(&'a int, &'b int) <: &fn<a>(&'a int, &'a int)? (Yes)
|
||||
fn<a>(&'a int, &'a int) <: &fn<a,b>(&'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>(&a/T) <: &fn<b>(&b/T)? Yes: a -> b
|
||||
1. fn<a>(&'a T) <: &fn<b>(&'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>(&b/T)? No!
|
||||
3. fn(&'self T) <: &fn<b>(&'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<a>() -> fn(&a/T) <: &fn() -> fn<b>(&b/T)? No.
|
||||
fn<a>() -> fn(&'a T) <: &fn() -> fn<b>(&'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>(&b/T)` when it really has type
|
||||
`fn(&a/T)` (this is case #3, above). Bad.
|
||||
the return value has type `fn<b>(&'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>(&b/T)?
|
||||
fn() -> fn(&'A T) <: &fn() -> fn<b>(&'b T)?
|
||||
|
||||
Now we compare the return types, which are covariant, and hence we have:
|
||||
|
||||
fn(&A/T) <: &fn<b>(&b/T)?
|
||||
fn(&'A T) <: &fn<b>(&'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>(&a/T) <: &fn<b>(&b/T)
|
||||
fn<a>(&'a T) <: &fn<b>(&'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
|
||||
|
|
|
@ -35,8 +35,8 @@ pub struct Node<V, T> {
|
|||
}
|
||||
|
||||
pub trait UnifyVid<T> {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt)
|
||||
-> &v/mut ValsAndBindings<Self, T>;
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<Self, T>;
|
||||
}
|
||||
|
||||
pub impl InferCtxt {
|
||||
|
@ -235,15 +235,15 @@ pub impl InferCtxt {
|
|||
// ______________________________________________________________________
|
||||
|
||||
impl UnifyVid<Bounds<ty::t>> for ty::TyVid {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt)
|
||||
-> &v/mut ValsAndBindings<ty::TyVid, Bounds<ty::t>> {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<ty::TyVid, Bounds<ty::t>> {
|
||||
return &mut infcx.ty_var_bindings;
|
||||
}
|
||||
}
|
||||
|
||||
impl UnifyVid<Option<IntVarValue>> for ty::IntVid {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt)
|
||||
-> &v/mut ValsAndBindings<ty::IntVid, Option<IntVarValue>> {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<ty::IntVid, Option<IntVarValue>> {
|
||||
return &mut infcx.int_var_bindings;
|
||||
}
|
||||
}
|
||||
|
@ -256,8 +256,8 @@ impl SimplyUnifiable for IntVarValue {
|
|||
}
|
||||
|
||||
impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &v/mut InferCtxt)
|
||||
-> &v/mut ValsAndBindings<ty::FloatVid, Option<ast::float_ty>> {
|
||||
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
|
||||
-> &'v mut ValsAndBindings<ty::FloatVid, Option<ast::float_ty>> {
|
||||
return &mut infcx.float_var_bindings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<T:Const + Owned>(data: T) -> ARC<T> {
|
|||
* Access the underlying data in an atomically reference counted
|
||||
* wrapper.
|
||||
*/
|
||||
pub fn get<T:Const + Owned>(rc: &a/ARC<T>) -> &a/T {
|
||||
pub fn get<T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
|
||||
unsafe { get_shared_immutable_state(&rc.x) }
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ pub impl<T:Owned> MutexARC<T> {
|
|||
#[inline(always)]
|
||||
unsafe fn access_cond<U>(
|
||||
&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<T:Const + Owned> RWARC<T> {
|
|||
}
|
||||
/// As write(), but with a condvar, as sync::rwlock.write_cond().
|
||||
#[inline(always)]
|
||||
fn write_cond<U>(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U {
|
||||
fn write_cond<U>(&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<T:Const + Owned> RWWriteMode/&self<T> {
|
|||
}
|
||||
}
|
||||
/// Access the pre-downgrade RWARC in write mode with a condvar.
|
||||
fn write_cond<U>(&self, blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U {
|
||||
fn write_cond<U>(&self, blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U {
|
||||
match *self {
|
||||
RWWriteMode {
|
||||
data: ref data,
|
||||
|
|
|
@ -201,7 +201,7 @@ pub impl Arena {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn alloc_pod<T>(&self, op: &fn() -> T) -> &self/T {
|
||||
fn alloc_pod<T>(&self, op: &fn() -> T) -> &'self T {
|
||||
unsafe {
|
||||
let tydesc = sys::get_type_desc::<T>();
|
||||
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
|
||||
|
@ -246,7 +246,7 @@ pub impl Arena {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn alloc_nonpod<T>(&self, op: &fn() -> T) -> &self/T {
|
||||
fn alloc_nonpod<T>(&self, op: &fn() -> T) -> &'self T {
|
||||
unsafe {
|
||||
let tydesc = sys::get_type_desc::<T>();
|
||||
let (ty_ptr, ptr) =
|
||||
|
@ -268,7 +268,7 @@ pub impl Arena {
|
|||
|
||||
// The external interface
|
||||
#[inline(always)]
|
||||
fn alloc<T>(&self, op: &fn() -> T) -> &self/T {
|
||||
fn alloc<T>(&self, op: &fn() -> T) -> &'self T {
|
||||
unsafe {
|
||||
if !rusti::needs_drop::<T>() {
|
||||
self.alloc_pod(op)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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]),
|
||||
|
|
|
@ -49,17 +49,17 @@ pub impl<T> Deque<T> {
|
|||
/// 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<T>(nelts: uint, lo: uint, elts: &mut [Option<T>]) -> ~[Option<T>] {
|
|||
rv
|
||||
}
|
||||
|
||||
fn get<T>(elts: &r/[Option<T>], i: uint) -> &r/T {
|
||||
fn get<T>(elts: &'r [Option<T>], i: uint) -> &'r T {
|
||||
match elts[i] { Some(ref t) => t, _ => fail!() }
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ pub impl<A:Copy> Future<A> {
|
|||
|
||||
pub impl<A> Future<A> {
|
||||
|
||||
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
|
||||
|
|
|
@ -748,7 +748,7 @@ pub fn from_str(s: &str) -> Result<Json, Error> {
|
|||
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -50,10 +50,10 @@ impl<T:Ord> Mutable for PriorityQueue<T> {
|
|||
|
||||
pub impl <T:Ord> PriorityQueue<T> {
|
||||
/// 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()) }
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ impl<D:Decoder> Decodable<D> for i64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S:Encoder> Encodable<S> for &self/str {
|
||||
impl<S:Encoder> Encodable<S> for &'self str {
|
||||
fn encode(&self, s: &S) { s.emit_borrowed_str(*self) }
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ impl<D:Decoder> Decodable<D> for () {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &self/T {
|
||||
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &'self T {
|
||||
fn encode(&self, s: &S) {
|
||||
s.emit_borrowed(|| (**self).encode(s))
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &self/[T] {
|
||||
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &'self [T] {
|
||||
fn encode(&self, s: &S) {
|
||||
do s.emit_borrowed_vec(self.len()) {
|
||||
for self.eachi |i, e| {
|
||||
|
|
|
@ -22,9 +22,9 @@ pub struct SmallIntMap<T> {
|
|||
priv v: ~[Option<T>],
|
||||
}
|
||||
|
||||
impl<V> BaseIter<(uint, &self/V)> for SmallIntMap<V> {
|
||||
impl<V> BaseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
/// 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<V> BaseIter<(uint, &self/V)> for SmallIntMap<V> {
|
|||
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||
}
|
||||
|
||||
impl<V> ReverseIter<(uint, &self/V)> for SmallIntMap<V> {
|
||||
impl<V> ReverseIter<(uint, &'self V)> for SmallIntMap<V> {
|
||||
/// 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<V> Map<uint, V> for SmallIntMap<V> {
|
|||
}
|
||||
|
||||
/// 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<V> SmallIntMap<V> {
|
|||
/// Create an empty SmallIntMap
|
||||
static pure fn new() -> SmallIntMap<V> { 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")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use core::util;
|
|||
use core::vec::{len, push};
|
||||
use core::vec;
|
||||
|
||||
type Le<T> = &self/pure fn(v1: &T, v2: &T) -> bool;
|
||||
type Le<T> = &'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<T:Copy + Ord + Eq> Sort for &self/mut [T] {
|
||||
impl<T:Copy + Ord + Eq> 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ pub impl Sem<~[Waitqueue]> {
|
|||
#[doc(hidden)]
|
||||
type SemRelease = SemReleaseGeneric/&self<()>;
|
||||
type SemAndSignalRelease = SemReleaseGeneric/&self<~[Waitqueue]>;
|
||||
struct SemReleaseGeneric<Q> { sem: &self/Sem<Q> }
|
||||
struct SemReleaseGeneric<Q> { sem: &'self Sem<Q> }
|
||||
|
||||
impl<Q:Owned> Drop for SemReleaseGeneric/&self<Q> {
|
||||
fn finalize(&self) {
|
||||
|
@ -173,13 +173,13 @@ impl<Q:Owned> Drop for SemReleaseGeneric/&self<Q> {
|
|||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -88,7 +88,7 @@ impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
|
|||
|
||||
impl<'self, K: TotalOrd, V> BaseIter<(&'self K, &'self V)> for TreeMap<K, V> {
|
||||
/// 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<uint> { Some(self.len()) }
|
||||
|
@ -99,7 +99,7 @@ impl<'self, K: TotalOrd, V>
|
|||
for TreeMap<K, V>
|
||||
{
|
||||
/// 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<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
|
|||
}
|
||||
|
||||
/// 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<K, V>> = &self.root;
|
||||
pure fn find(&self, key: &K) -> Option<&'self V> {
|
||||
let mut current: &'self Option<~TreeNode<K, V>> = &self.root;
|
||||
loop {
|
||||
match *current {
|
||||
Some(ref r) => {
|
||||
|
@ -197,15 +197,15 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> {
|
|||
|
||||
/// Lazy forward iterator over a map
|
||||
pub struct TreeMapIterator<K, V> {
|
||||
priv stack: ~[&self/~TreeNode<K, V>],
|
||||
priv node: &self/Option<~TreeNode<K, V>>
|
||||
priv stack: ~[&'self ~TreeNode<K, V>],
|
||||
priv node: &'self Option<~TreeNode<K, V>>
|
||||
}
|
||||
|
||||
/// 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<K, V>(iter: &mut TreeMapIterator/&r<K, V>)
|
||||
-> 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<K, V>(iter: &mut TreeMapIterator/&r<K, V>)
|
|||
|
||||
/// Advance the iterator through the map
|
||||
pub fn map_advance<K, V>(iter: &mut TreeMapIterator/&r<K, V>,
|
||||
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<T> {
|
|||
/// Advance the iterator to the next node (in order). If this iterator is
|
||||
/// finished, does nothing.
|
||||
#[inline(always)]
|
||||
pub fn set_next<T>(iter: &mut TreeSetIterator/&r<T>) -> Option<&r/T> {
|
||||
pub fn set_next<T>(iter: &mut TreeSetIterator/&r<T>) -> Option<&'r T> {
|
||||
do map_next(&mut iter.iter).map |&(value, _)| { value }
|
||||
}
|
||||
|
||||
/// Advance the iterator through the set
|
||||
#[inline(always)]
|
||||
pub fn set_advance<T>(iter: &mut TreeSetIterator/&r<T>,
|
||||
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<K: TotalOrd, V> TreeNode<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
pure fn each<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
|
||||
f: &fn(&(&r/K, &r/V)) -> bool) {
|
||||
pure fn each<K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
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<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
|
||||
f: &fn(&(&r/K, &r/V)) -> bool) {
|
||||
pure fn each_reverse<K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>,
|
||||
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) }
|
||||
|
|
|
@ -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 <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
|
|||
|
||||
// ugh: can't get this to compile with mut because of the
|
||||
// lack of flow sensitivity.
|
||||
fn get_map(&self) -> &self/LinearMap<K,@V> {
|
||||
fn get_map(&self) -> &'self LinearMap<K,@V> {
|
||||
match *self {
|
||||
BaseMapChain (~ref map) => map,
|
||||
ConsMapChain (~ref map,_) => map
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"]),
|
||||
|
|
|
@ -61,7 +61,7 @@ impl<T> OptVec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
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]
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -22,6 +22,6 @@ impl<A> vec_monad<A> 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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ struct Foo {
|
|||
}
|
||||
|
||||
pub impl Foo<'self> {
|
||||
fn get_s(&self) -> &self/str {
|
||||
fn get_s(&self) -> &'self str {
|
||||
self.s
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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<T>(v: &r/[T]) -> Option< (&r/T, &r/[T]) > {
|
||||
fn vec_peek<T>(v: &'r [T]) -> Option< (&'r T, &'r [T]) > {
|
||||
if v.len() == 0 {
|
||||
None
|
||||
} else {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// xfail-test
|
||||
fn id<T>(t: T) -> T { t }
|
||||
|
||||
fn f<T>(v: &r/T) -> &r/fn()->T { id::<&r/fn()->T>(|| *v) } //~ ERROR ???
|
||||
fn f<T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR ???
|
||||
|
||||
fn main() {
|
||||
let v = &5;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -21,10 +21,10 @@ fn repeater<A:Copy>(v: @A) -> @repeat<A> {
|
|||
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
fn of<T>() -> @fn(T) { fail!(); }
|
||||
fn subtype<T>(x: @fn(T)) { fail!(); }
|
||||
|
||||
fn test_fn<T>(_x: &x/T, _y: &y/T, _z: &z/T) {
|
||||
fn test_fn<T>(_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::<T1>(of::<T2>()) will typecheck
|
||||
|
|
|
@ -11,47 +11,47 @@
|
|||
fn of<T>() -> @fn(T) { fail!(); }
|
||||
fn subtype<T>(x: @fn(T)) { fail!(); }
|
||||
|
||||
fn test_fn<T>(_x: &x/T, _y: &y/T, _z: &z/T) {
|
||||
fn test_fn<T>(_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::<T1>(of::<T2>()) 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() {}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn borrow<T>(x: &r/T) -> &r/T {x}
|
||||
fn borrow<T>(x: &'r T) -> &'r T {x}
|
||||
|
||||
fn foo(cond: &fn() -> bool, box: &fn() -> @int) {
|
||||
let mut y: ∫
|
||||
|
|
|
@ -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<T>(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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue