Add manual &self/ and &static/ and /&self declarations that
are currently inferred. New rules are coming that will require them to be explicit. All add some explicit self declarations.
This commit is contained in:
parent
876b6ba792
commit
3168fe06ff
122 changed files with 509 additions and 477 deletions
19
doc/rust.md
19
doc/rust.md
|
@ -1144,22 +1144,23 @@ Constants are declared with the `const` keyword.
|
||||||
A constant item must have an expression giving its definition.
|
A constant item must have an expression giving its definition.
|
||||||
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
|
The definition expression of a constant is limited to expression forms that can be evaluated at compile time.
|
||||||
|
|
||||||
Constants must be explicitly typed. The type may be ```bool```, ```char```, a number, or a type derived from
|
Constants must be explicitly typed. The type may be ```bool```, ```char```, a number, or a type derived from those primitive types.
|
||||||
those primitive types. The derived types are borrowed pointers, static arrays, tuples, and structs.
|
The derived types are borrowed pointers, static arrays, tuples, and structs.
|
||||||
|
Borrowed pointers must be have the `'static` lifetime.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
const bit1: uint = 1 << 0;
|
const bit1: uint = 1 << 0;
|
||||||
const bit2: uint = 1 << 1;
|
const bit2: uint = 1 << 1;
|
||||||
|
|
||||||
const bits: [uint * 2] = [bit1, bit2];
|
const bits: [uint * 2] = [bit1, bit2];
|
||||||
const string: &str = "bitstring";
|
const string: &'static str = "bitstring";
|
||||||
|
|
||||||
struct BitsNStrings {
|
struct BitsNStrings {
|
||||||
mybits: [uint *2],
|
mybits: [uint *2],
|
||||||
mystring: &str
|
mystring: &'self str
|
||||||
}
|
}
|
||||||
|
|
||||||
const bits_n_strings: BitsNStrings = BitsNStrings {
|
const bits_n_strings: BitsNStrings<'static> = BitsNStrings {
|
||||||
mybits: bits,
|
mybits: bits,
|
||||||
mystring: string
|
mystring: string
|
||||||
};
|
};
|
||||||
|
@ -1630,7 +1631,7 @@ The following are examples of structure expressions:
|
||||||
~~~~
|
~~~~
|
||||||
# struct Point { x: float, y: float }
|
# struct Point { x: float, y: float }
|
||||||
# struct TuplePoint(float, float);
|
# struct TuplePoint(float, float);
|
||||||
# mod game { pub struct User { name: &str, age: uint, score: uint } }
|
# mod game { pub struct User<'self> { name: &'self str, age: uint, score: uint } }
|
||||||
# struct Cookie; fn some_fn<T>(t: T) {}
|
# struct Cookie; fn some_fn<T>(t: T) {}
|
||||||
Point {x: 10f, y: 20f};
|
Point {x: 10f, y: 20f};
|
||||||
TuplePoint(10f, 20f);
|
TuplePoint(10f, 20f);
|
||||||
|
@ -2556,8 +2557,8 @@ order specified by the tuple type.
|
||||||
An example of a tuple type and its use:
|
An example of a tuple type and its use:
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
type Pair = (int,&str);
|
type Pair<'self> = (int,&'self str);
|
||||||
let p: Pair = (10,"hello");
|
let p: Pair<'static> = (10,"hello");
|
||||||
let (a, b) = p;
|
let (a, b) = p;
|
||||||
assert b != "world";
|
assert b != "world";
|
||||||
~~~~
|
~~~~
|
||||||
|
@ -2718,7 +2719,7 @@ fn add(x: int, y: int) -> int {
|
||||||
|
|
||||||
let mut x = add(5,7);
|
let mut x = add(5,7);
|
||||||
|
|
||||||
type Binop = fn(int,int) -> int;
|
type Binop<'self> = &'self fn(int,int) -> int;
|
||||||
let bo: Binop = add;
|
let bo: Binop = add;
|
||||||
x = bo(5,7);
|
x = bo(5,7);
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
|
@ -1951,7 +1951,7 @@ trait Printable {
|
||||||
Traits may be implemented for specific types with [impls]. An impl
|
Traits may be implemented for specific types with [impls]. An impl
|
||||||
that implements a trait includes the name of the trait at the start of
|
that implements a trait includes the name of the trait at the start of
|
||||||
the definition, as in the following impls of `Printable` for `int`
|
the definition, as in the following impls of `Printable` for `int`
|
||||||
and `&str`.
|
and `~str`.
|
||||||
|
|
||||||
[impls]: #functions-and-methods
|
[impls]: #functions-and-methods
|
||||||
|
|
||||||
|
@ -1961,12 +1961,12 @@ impl Printable for int {
|
||||||
fn print(&self) { io::println(fmt!("%d", *self)) }
|
fn print(&self) { io::println(fmt!("%d", *self)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Printable for &str {
|
impl Printable for ~str {
|
||||||
fn print(&self) { io::println(*self) }
|
fn print(&self) { io::println(*self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
# 1.print();
|
# 1.print();
|
||||||
# ("foo").print();
|
# (~"foo").print();
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
Methods defined in an implementation of a trait may be called just like
|
Methods defined in an implementation of a trait may be called just like
|
||||||
|
|
|
@ -168,7 +168,7 @@ pub mod traits {
|
||||||
use kinds::Copy;
|
use kinds::Copy;
|
||||||
use ops::Add;
|
use ops::Add;
|
||||||
|
|
||||||
impl<T:Copy> Add<&[const T],@[T]> for @[T] {
|
impl<T:Copy> Add<&self/[const T],@[T]> for @[T] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
|
pure fn add(&self, rhs: & &self/[const T]) -> @[T] {
|
||||||
append(*self, (*rhs))
|
append(*self, (*rhs))
|
||||||
|
|
|
@ -22,8 +22,8 @@ use cast::transmute;
|
||||||
* NB: These must match the representation in the C++ runtime.
|
* NB: These must match the representation in the C++ runtime.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type DropGlue = fn(**TypeDesc, *c_void);
|
type DropGlue = &self/fn(**TypeDesc, *c_void);
|
||||||
type FreeGlue = fn(**TypeDesc, *c_void);
|
type FreeGlue = &self/fn(**TypeDesc, *c_void);
|
||||||
|
|
||||||
type TaskID = uintptr_t;
|
type TaskID = uintptr_t;
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,10 @@ pub struct Handler<T, U> {
|
||||||
|
|
||||||
pub struct Condition<T, U> {
|
pub struct Condition<T, U> {
|
||||||
name: &static/str,
|
name: &static/str,
|
||||||
key: task::local_data::LocalDataKey<Handler<T, U>>
|
key: task::local_data::LocalDataKey/&self<Handler<T, U>>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T, U> Condition<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 {
|
unsafe {
|
||||||
let p : *RustClosure = ::cast::transmute(&h);
|
let p : *RustClosure = ::cast::transmute(&h);
|
||||||
|
@ -65,11 +65,11 @@ pub impl<T, U> Condition<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Trap<T, U> {
|
struct Trap<T, U> {
|
||||||
cond: &Condition<T, U>,
|
cond: &self/Condition/&self<T, U>,
|
||||||
handler: @Handler<T, U>
|
handler: @Handler<T, U>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T, U> Trap<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 {
|
unsafe {
|
||||||
let _g = Guard { cond: self.cond };
|
let _g = Guard { cond: self.cond };
|
||||||
|
@ -81,10 +81,10 @@ pub impl<T, U> Trap<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Guard<T, U> {
|
struct Guard<T, U> {
|
||||||
cond: &Condition<T, U>
|
cond: &self/Condition/&self<T, U>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, U> Drop for Guard<T, U> {
|
impl<T, U> Drop for Guard/&self<T, U> {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("Guard: popping handler from TLS");
|
debug!("Guard: popping handler from TLS");
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
//! Container traits
|
//! Container traits
|
||||||
|
|
||||||
use cmp::Equiv;
|
|
||||||
use option::Option;
|
use option::Option;
|
||||||
|
|
||||||
pub trait Container {
|
pub trait Container {
|
||||||
|
|
|
@ -115,7 +115,7 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Visitor = 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
|
// Walks the list of roots for the given safe point, and calls visitor
|
||||||
// on each root.
|
// on each root.
|
||||||
|
|
|
@ -298,7 +298,7 @@ impl io::Writer for SipState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Streaming for &SipState {
|
impl Streaming for SipState {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn input(&self, buf: &[const u8]) {
|
fn input(&self, buf: &[const u8]) {
|
||||||
|
|
|
@ -268,7 +268,9 @@ pub mod linear {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K:Hash + IterBytes + Eq,V> BaseIter<(&K, &V)> for LinearMap<K, V> {
|
impl<K:Hash + IterBytes + Eq,V>
|
||||||
|
BaseIter<(&self/K, &self/V)> for LinearMap<K, V>
|
||||||
|
{
|
||||||
/// Visit all key-value pairs
|
/// 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| {
|
for uint::range(0, self.buckets.len()) |i| {
|
||||||
|
|
|
@ -585,11 +585,11 @@ pub fn file_reader(path: &Path) -> Result<@Reader, ~str> {
|
||||||
|
|
||||||
// Byte readers
|
// Byte readers
|
||||||
pub struct BytesReader {
|
pub struct BytesReader {
|
||||||
bytes: &[u8],
|
bytes: &self/[u8],
|
||||||
mut pos: uint
|
mut pos: uint
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reader for BytesReader {
|
impl Reader for BytesReader/&self {
|
||||||
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
|
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
|
||||||
let count = uint::min(len, self.bytes.len() - self.pos);
|
let count = uint::min(len, self.bytes.len() - self.pos);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use option::{None, Option, Some};
|
||||||
use vec;
|
use vec;
|
||||||
|
|
||||||
/// A function used to initialize the elements of a sequence
|
/// A function used to initialize the elements of a sequence
|
||||||
pub type InitOp<T> = &fn(uint) -> T;
|
pub type InitOp<T> = &self/fn(uint) -> T;
|
||||||
|
|
||||||
pub trait BaseIter<A> {
|
pub trait BaseIter<A> {
|
||||||
pure fn each(&self, blk: fn(v: &A) -> bool);
|
pure fn each(&self, blk: fn(v: &A) -> bool);
|
||||||
|
|
|
@ -1028,11 +1028,11 @@ pub mod consts {
|
||||||
pub use os::consts::windows::*;
|
pub use os::consts::windows::*;
|
||||||
|
|
||||||
pub mod unix {
|
pub mod unix {
|
||||||
pub const FAMILY: &str = "unix";
|
pub const FAMILY: &static/str = "unix";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod windows {
|
pub mod windows {
|
||||||
pub const FAMILY: &str = "windows";
|
pub const FAMILY: &static/str = "windows";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -1051,38 +1051,38 @@ pub mod consts {
|
||||||
pub use os::consts::win32::*;
|
pub use os::consts::win32::*;
|
||||||
|
|
||||||
pub mod macos {
|
pub mod macos {
|
||||||
pub const SYSNAME: &str = "macos";
|
pub const SYSNAME: &static/str = "macos";
|
||||||
pub const DLL_PREFIX: &str = "lib";
|
pub const DLL_PREFIX: &static/str = "lib";
|
||||||
pub const DLL_SUFFIX: &str = ".dylib";
|
pub const DLL_SUFFIX: &static/str = ".dylib";
|
||||||
pub const EXE_SUFFIX: &str = "";
|
pub const EXE_SUFFIX: &static/str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod freebsd {
|
pub mod freebsd {
|
||||||
pub const SYSNAME: &str = "freebsd";
|
pub const SYSNAME: &static/str = "freebsd";
|
||||||
pub const DLL_PREFIX: &str = "lib";
|
pub const DLL_PREFIX: &static/str = "lib";
|
||||||
pub const DLL_SUFFIX: &str = ".so";
|
pub const DLL_SUFFIX: &static/str = ".so";
|
||||||
pub const EXE_SUFFIX: &str = "";
|
pub const EXE_SUFFIX: &static/str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod linux {
|
pub mod linux {
|
||||||
pub const SYSNAME: &str = "linux";
|
pub const SYSNAME: &static/str = "linux";
|
||||||
pub const DLL_PREFIX: &str = "lib";
|
pub const DLL_PREFIX: &static/str = "lib";
|
||||||
pub const DLL_SUFFIX: &str = ".so";
|
pub const DLL_SUFFIX: &static/str = ".so";
|
||||||
pub const EXE_SUFFIX: &str = "";
|
pub const EXE_SUFFIX: &static/str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod android {
|
pub mod android {
|
||||||
pub const SYSNAME: &str = "android";
|
pub const SYSNAME: &static/str = "android";
|
||||||
pub const DLL_PREFIX: &str = "lib";
|
pub const DLL_PREFIX: &static/str = "lib";
|
||||||
pub const DLL_SUFFIX: &str = ".so";
|
pub const DLL_SUFFIX: &static/str = ".so";
|
||||||
pub const EXE_SUFFIX: &str = "";
|
pub const EXE_SUFFIX: &static/str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod win32 {
|
pub mod win32 {
|
||||||
pub const SYSNAME: &str = "win32";
|
pub const SYSNAME: &static/str = "win32";
|
||||||
pub const DLL_PREFIX: &str = "";
|
pub const DLL_PREFIX: &static/str = "";
|
||||||
pub const DLL_SUFFIX: &str = ".dll";
|
pub const DLL_SUFFIX: &static/str = ".dll";
|
||||||
pub const EXE_SUFFIX: &str = ".exe";
|
pub const EXE_SUFFIX: &static/str = ".exe";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1099,16 +1099,16 @@ pub mod consts {
|
||||||
use os::consts::mips::*;
|
use os::consts::mips::*;
|
||||||
|
|
||||||
pub mod x86 {
|
pub mod x86 {
|
||||||
pub const ARCH: &str = "x86";
|
pub const ARCH: &'static str = "x86";
|
||||||
}
|
}
|
||||||
pub mod x86_64 {
|
pub mod x86_64 {
|
||||||
pub const ARCH: &str = "x86_64";
|
pub const ARCH: &'static str = "x86_64";
|
||||||
}
|
}
|
||||||
pub mod arm {
|
pub mod arm {
|
||||||
pub const ARCH: &str = "arm";
|
pub const ARCH: &'static str = "arm";
|
||||||
}
|
}
|
||||||
pub mod mips {
|
pub mod mips {
|
||||||
pub const ARCH: &str = "mips";
|
pub const ARCH: &'static str = "mips";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -440,7 +440,7 @@ pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
|
||||||
let p = unsafe { &*p_ };
|
let p = unsafe { &*p_ };
|
||||||
|
|
||||||
struct DropState {
|
struct DropState {
|
||||||
p: &PacketHeader,
|
p: &self/PacketHeader,
|
||||||
|
|
||||||
drop {
|
drop {
|
||||||
if task::failing() {
|
if task::failing() {
|
||||||
|
|
|
@ -264,7 +264,7 @@ impl<T> Ord for *const T {
|
||||||
|
|
||||||
// Equality for region pointers
|
// Equality for region pointers
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T:Eq> Eq for &const T {
|
impl<T:Eq> Eq for &self/const T {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn eq(&self, other: & &self/const T) -> bool {
|
pure fn eq(&self, other: & &self/const T) -> bool {
|
||||||
return *(*self) == *(*other);
|
return *(*self) == *(*other);
|
||||||
|
@ -277,7 +277,7 @@ impl<T:Eq> Eq for &const T {
|
||||||
|
|
||||||
// Comparison for region pointers
|
// Comparison for region pointers
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T:Ord> Ord for &const T {
|
impl<T:Ord> Ord for &self/const T {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn lt(&self, other: & &self/const T) -> bool {
|
pure fn lt(&self, other: & &self/const T) -> bool {
|
||||||
*(*self) < *(*other)
|
*(*self) < *(*other)
|
||||||
|
|
|
@ -787,7 +787,7 @@ pure fn cmp(a: &str, b: &str) -> Ordering {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl TotalOrd for &str {
|
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) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ pure fn gt(a: &str, b: &str) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl Eq for &str {
|
impl Eq for &self/str {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn eq(&self, other: & &self/str) -> bool {
|
pure fn eq(&self, other: & &self/str) -> bool {
|
||||||
eq_slice((*self), (*other))
|
eq_slice((*self), (*other))
|
||||||
|
@ -875,7 +875,7 @@ impl Ord for ~str {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl Ord for &str {
|
impl Ord for &self/str {
|
||||||
#[inline(always)]
|
#[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)]
|
#[inline(always)]
|
||||||
|
@ -899,7 +899,7 @@ impl Ord for @str {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl Equiv<~str> for &str {
|
impl Equiv<~str> for &'self str {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) }
|
pure fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) }
|
||||||
}
|
}
|
||||||
|
@ -2226,7 +2226,7 @@ pub mod traits {
|
||||||
use ops::Add;
|
use ops::Add;
|
||||||
use str::append;
|
use str::append;
|
||||||
|
|
||||||
impl Add<&str,~str> for ~str {
|
impl Add<&self/str,~str> for ~str {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(&self, rhs: & &self/str) -> ~str {
|
pure fn add(&self, rhs: & &self/str) -> ~str {
|
||||||
append(copy *self, (*rhs))
|
append(copy *self, (*rhs))
|
||||||
|
@ -2270,7 +2270,7 @@ pub trait StrSlice {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension methods for strings
|
/// Extension methods for strings
|
||||||
impl StrSlice for &str {
|
impl StrSlice for &self/str {
|
||||||
/**
|
/**
|
||||||
* Return true if a predicate matches all characters or if the string
|
* Return true if a predicate matches all characters or if the string
|
||||||
* contains no characters
|
* contains no characters
|
||||||
|
|
|
@ -19,7 +19,7 @@ use libc::{c_void, c_char, size_t};
|
||||||
use repr;
|
use repr;
|
||||||
use str;
|
use str;
|
||||||
|
|
||||||
pub type FreeGlue = fn(*TypeDesc, *c_void);
|
pub type FreeGlue = &self/fn(*TypeDesc, *c_void);
|
||||||
|
|
||||||
// Corresponds to runtime type_desc type
|
// Corresponds to runtime type_desc type
|
||||||
pub enum TypeDesc = {
|
pub enum TypeDesc = {
|
||||||
|
|
|
@ -44,7 +44,7 @@ use task::rt;
|
||||||
*
|
*
|
||||||
* These two cases aside, the interface is safe.
|
* These two cases aside, the interface is safe.
|
||||||
*/
|
*/
|
||||||
pub type LocalDataKey<T> = &fn(v: @T);
|
pub type LocalDataKey<T> = &self/fn(v: @T);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a task-local data value from the table, returning the
|
* Remove a task-local data value from the table, returning the
|
||||||
|
|
|
@ -123,7 +123,7 @@ struct TaskGroupData {
|
||||||
}
|
}
|
||||||
type TaskGroupArc = unstable::Exclusive<Option<TaskGroupData>>;
|
type TaskGroupArc = unstable::Exclusive<Option<TaskGroupData>>;
|
||||||
|
|
||||||
type TaskGroupInner = &mut Option<TaskGroupData>;
|
type TaskGroupInner = &self/mut Option<TaskGroupData>;
|
||||||
|
|
||||||
// A taskgroup is 'dead' when nothing can cause it to fail; only members can.
|
// A taskgroup is 'dead' when nothing can cause it to fail; only members can.
|
||||||
pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
|
pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
|
||||||
|
|
|
@ -19,7 +19,7 @@ use io::Writer;
|
||||||
use option::{None, Option, Some};
|
use option::{None, Option, Some};
|
||||||
use str;
|
use str;
|
||||||
|
|
||||||
pub type Cb = &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;
|
* A trait to implement in order to make a type hashable;
|
||||||
|
@ -197,7 +197,7 @@ impl IterBytes for int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:IterBytes> IterBytes for &[A] {
|
impl<A:IterBytes> IterBytes for &self/[A] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||||
for (*self).each |elt| {
|
for (*self).each |elt| {
|
||||||
|
@ -352,7 +352,7 @@ pub pure fn iter_bytes_7<A: IterBytes,
|
||||||
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IterBytes for &str {
|
impl IterBytes for &self/str {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
|
||||||
do str::byte_slice(*self) |bytes| {
|
do str::byte_slice(*self) |bytes| {
|
||||||
|
@ -389,7 +389,7 @@ impl<A:IterBytes> IterBytes for Option<A> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:IterBytes> IterBytes for &A {
|
impl<A:IterBytes> IterBytes for &self/A {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
|
||||||
(**self).iter_bytes(lsb0, f);
|
(**self).iter_bytes(lsb0, f);
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl ToStr for ~str {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn to_str(&self) -> ~str { copy *self }
|
pure fn to_str(&self) -> ~str { copy *self }
|
||||||
}
|
}
|
||||||
impl ToStr for &str {
|
impl ToStr for &self/str {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
|
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 &[A] {
|
impl<A:ToStr> ToStr for &self/[A] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn to_str(&self) -> ~str {
|
pure fn to_str(&self) -> ~str {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub struct TrieMap<T> {
|
||||||
priv length: uint
|
priv length: uint
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> BaseIter<(uint, &T)> for TrieMap<T> {
|
impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> {
|
||||||
/// Visit all key-value pairs in order
|
/// Visit all key-value pairs in order
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn each(&self, f: fn(&(uint, &self/T)) -> bool) {
|
pure fn each(&self, f: fn(&(uint, &self/T)) -> bool) {
|
||||||
|
@ -39,7 +39,7 @@ impl<T> BaseIter<(uint, &T)> for TrieMap<T> {
|
||||||
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ReverseIter<(uint, &T)> for TrieMap<T> {
|
impl<T> ReverseIter<(uint, &'self T)> for TrieMap<T> {
|
||||||
/// Visit all key-value pairs in reverse order
|
/// Visit all key-value pairs in reverse order
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn each_reverse(&self, f: fn(&(uint, &self/T)) -> bool) {
|
pure fn each_reverse(&self, f: fn(&(uint, &self/T)) -> bool) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ pub trait ExtendedTupleOps<A,B> {
|
||||||
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C];
|
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C];
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&[A], &[B]) {
|
impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&self/[A], &self/[B]) {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn zip(&self) -> ~[(A, B)] {
|
fn zip(&self) -> ~[(A, B)] {
|
||||||
match *self {
|
match *self {
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub trait Finally<T> {
|
||||||
fn finally(&self, dtor: &fn()) -> T;
|
fn finally(&self, dtor: &fn()) -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Finally<T> for &fn() -> T {
|
impl<T> Finally<T> for &self/fn() -> T {
|
||||||
fn finally(&self, dtor: &fn()) -> T {
|
fn finally(&self, dtor: &fn()) -> T {
|
||||||
let _d = Finallyalizer {
|
let _d = Finallyalizer {
|
||||||
dtor: dtor
|
dtor: dtor
|
||||||
|
@ -42,10 +42,10 @@ impl<T> Finally<T> for &fn() -> T {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Finallyalizer {
|
struct Finallyalizer {
|
||||||
dtor: &fn()
|
dtor: &self/fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Finallyalizer {
|
impl Drop for Finallyalizer/&self {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
(self.dtor)();
|
(self.dtor)();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ use sys::Closure;
|
||||||
#[cfg(test)] use task::spawn;
|
#[cfg(test)] use task::spawn;
|
||||||
#[cfg(test)] use uint;
|
#[cfg(test)] use uint;
|
||||||
|
|
||||||
pub type GlobalDataKey<T> = &fn(v: T);
|
pub type GlobalDataKey<T> = &self/fn(v: T);
|
||||||
|
|
||||||
pub unsafe fn global_data_clone_create<T:Owned + Clone>(
|
pub unsafe fn global_data_clone_create<T:Owned + Clone>(
|
||||||
key: GlobalDataKey<T>, create: &fn() -> ~T) -> T {
|
key: GlobalDataKey<T>, create: &fn() -> ~T) -> T {
|
||||||
|
|
|
@ -1549,7 +1549,7 @@ pure fn eq<T:Eq>(a: &[T], b: &[T]) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T:Eq> Eq for &[T] {
|
impl<T:Eq> Eq for &self/[T] {
|
||||||
#[inline(always)]
|
#[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)]
|
#[inline(always)]
|
||||||
|
@ -1574,7 +1574,7 @@ impl<T:Eq> Eq for @[T] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T:Eq> Equiv<~[T]> for &[T] {
|
impl<T:Eq> Equiv<~[T]> for &'self [T] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) }
|
pure fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) }
|
||||||
}
|
}
|
||||||
|
@ -1596,7 +1596,7 @@ pure fn cmp<T: TotalOrd>(a: &[T], b: &[T]) -> Ordering {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T: TotalOrd> TotalOrd for &[T] {
|
impl<T: TotalOrd> TotalOrd for &'self [T] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn cmp(&self, other: & &self/[T]) -> Ordering { cmp(*self, *other) }
|
pure fn cmp(&self, other: & &self/[T]) -> Ordering { cmp(*self, *other) }
|
||||||
}
|
}
|
||||||
|
@ -1633,7 +1633,7 @@ 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) }
|
pure fn gt<T:Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
|
||||||
|
|
||||||
#[cfg(notest)]
|
#[cfg(notest)]
|
||||||
impl<T:Ord> Ord for &[T] {
|
impl<T:Ord> Ord for &self/[T] {
|
||||||
#[inline(always)]
|
#[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)]
|
#[inline(always)]
|
||||||
|
@ -1674,7 +1674,7 @@ pub mod traits {
|
||||||
use ops::Add;
|
use ops::Add;
|
||||||
use vec::append;
|
use vec::append;
|
||||||
|
|
||||||
impl<T:Copy> Add<&[const T],~[T]> for ~[T] {
|
impl<T:Copy> Add<&self/[const T],~[T]> for ~[T] {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn add(&self, rhs: & &self/[const T]) -> ~[T] {
|
pure fn add(&self, rhs: & &self/[const T]) -> ~[T] {
|
||||||
append(copy *self, (*rhs))
|
append(copy *self, (*rhs))
|
||||||
|
@ -1682,7 +1682,7 @@ pub mod traits {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Container for &[const T] {
|
impl<T> Container for &self/[const T] {
|
||||||
/// Returns true if a vector contains no elements
|
/// Returns true if a vector contains no elements
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn is_empty(&self) -> bool { is_empty(*self) }
|
pure fn is_empty(&self) -> bool { is_empty(*self) }
|
||||||
|
@ -1697,7 +1697,7 @@ pub trait CopyableVector<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension methods for vectors
|
/// Extension methods for vectors
|
||||||
impl<T: Copy> CopyableVector<T> for &[const T] {
|
impl<T: Copy> CopyableVector<T> for &'self [const T] {
|
||||||
/// Returns a copy of the elements from [`start`..`end`) from `v`.
|
/// Returns a copy of the elements from [`start`..`end`) from `v`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn slice(&self, start: uint, end: uint) -> ~[T] {
|
pure fn slice(&self, start: uint, end: uint) -> ~[T] {
|
||||||
|
@ -1725,7 +1725,7 @@ pub trait ImmutableVector<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension methods for vectors
|
/// Extension methods for vectors
|
||||||
impl<T> ImmutableVector<T> for &[T] {
|
impl<T> ImmutableVector<T> for &self/[T] {
|
||||||
/// Return a slice that points into another slice.
|
/// Return a slice that points into another slice.
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn view(&self, start: uint, end: uint) -> &self/[T] {
|
pure fn view(&self, start: uint, end: uint) -> &self/[T] {
|
||||||
|
@ -1828,7 +1828,7 @@ pub trait ImmutableEqVector<T:Eq> {
|
||||||
pure fn rposition_elem(&self, t: &T) -> Option<uint>;
|
pure fn rposition_elem(&self, t: &T) -> Option<uint>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Eq> ImmutableEqVector<T> for &[T] {
|
impl<T:Eq> ImmutableEqVector<T> for &self/[T] {
|
||||||
/**
|
/**
|
||||||
* Find the first index matching some predicate
|
* Find the first index matching some predicate
|
||||||
*
|
*
|
||||||
|
@ -1873,7 +1873,7 @@ pub trait ImmutableCopyableVector<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension methods for vectors
|
/// Extension methods for vectors
|
||||||
impl<T:Copy> ImmutableCopyableVector<T> for &[T] {
|
impl<T:Copy> ImmutableCopyableVector<T> for &self/[T] {
|
||||||
/**
|
/**
|
||||||
* Construct a new vector from the elements of a vector for which some
|
* Construct a new vector from the elements of a vector for which some
|
||||||
* predicate holds.
|
* predicate holds.
|
||||||
|
@ -2266,7 +2266,7 @@ pub mod bytes {
|
||||||
// This cannot be used with iter-trait.rs because of the region pointer
|
// This cannot be used with iter-trait.rs because of the region pointer
|
||||||
// required in the slice.
|
// required in the slice.
|
||||||
|
|
||||||
impl<A> iter::BaseIter<A> for &[A] {
|
impl<A> iter::BaseIter<A> for &self/[A] {
|
||||||
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
|
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
|
||||||
// FIXME(#2263)---should be able to call each(self, blk)
|
// FIXME(#2263)---should be able to call each(self, blk)
|
||||||
for each(*self) |e| {
|
for each(*self) |e| {
|
||||||
|
@ -2304,7 +2304,7 @@ impl<A> iter::BaseIter<A> for @[A] {
|
||||||
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
|
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> iter::ExtendedIter<A> for &[A] {
|
impl<A> iter::ExtendedIter<A> for &self/[A] {
|
||||||
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
|
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
|
||||||
iter::eachi(self, blk)
|
iter::eachi(self, blk)
|
||||||
}
|
}
|
||||||
|
@ -2381,7 +2381,7 @@ impl<A> iter::ExtendedIter<A> for @[A] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:Eq> iter::EqIter<A> for &[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 contains(&self, x: &A) -> bool { iter::contains(self, x) }
|
||||||
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
||||||
}
|
}
|
||||||
|
@ -2398,7 +2398,7 @@ impl<A:Eq> iter::EqIter<A> for @[A] {
|
||||||
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:Copy> iter::CopyableIter<A> for &[A] {
|
impl<A:Copy> iter::CopyableIter<A> for &self/[A] {
|
||||||
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
|
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
|
||||||
iter::filter_to_vec(self, pred)
|
iter::filter_to_vec(self, pred)
|
||||||
}
|
}
|
||||||
|
@ -2430,7 +2430,7 @@ impl<A:Copy> iter::CopyableIter<A> for @[A] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for &[A] {
|
impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for &self/[A] {
|
||||||
pure fn min(&self) -> A { iter::min(self) }
|
pure fn min(&self) -> A { iter::min(self) }
|
||||||
pure fn max(&self) -> A { iter::max(self) }
|
pure fn max(&self) -> A { iter::max(self) }
|
||||||
}
|
}
|
||||||
|
@ -2447,7 +2447,7 @@ impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for @[A] {
|
||||||
pure fn max(&self) -> A { iter::max(self) }
|
pure fn max(&self) -> A { iter::max(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A:Copy> iter::CopyableNonstrictIter<A> for &[A] {
|
impl<A:Copy> iter::CopyableNonstrictIter<A> for &self/[A] {
|
||||||
pure fn each_val(&const self, f: fn(A) -> bool) {
|
pure fn each_val(&const self, f: fn(A) -> bool) {
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
while i < self.len() {
|
while i < self.len() {
|
||||||
|
|
|
@ -36,23 +36,23 @@ impl ValidUsage {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
Exec(&str),
|
Exec(&self/str),
|
||||||
Call(&fn(args: &[~str]) -> ValidUsage)
|
Call(&self/fn(args: &[~str]) -> ValidUsage)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UsageSource {
|
enum UsageSource {
|
||||||
UsgExec(&str),
|
UsgExec(&self/str),
|
||||||
UsgStr(&str)
|
UsgStr(&self/str)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Command {
|
struct Command {
|
||||||
cmd: &str,
|
cmd: &self/str,
|
||||||
action: Action,
|
action: Action/&self,
|
||||||
usage_line: &str,
|
usage_line: &self/str,
|
||||||
usage_full: UsageSource
|
usage_full: UsageSource/&self
|
||||||
}
|
}
|
||||||
|
|
||||||
const commands: &[Command] = &[
|
const commands: &static/[Command/&static] = &[
|
||||||
Command{
|
Command{
|
||||||
cmd: "build",
|
cmd: "build",
|
||||||
action: Exec("rustc"),
|
action: Exec("rustc"),
|
||||||
|
|
|
@ -68,7 +68,7 @@ fn lookup_hash(d: ebml::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type GetCrateDataCb = &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> {
|
pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||||
|
@ -546,7 +546,7 @@ pub fn get_item_path(intr: @ident_interner, cdata: cmd, id: ast::node_id)
|
||||||
item_path(intr, lookup_item(id, cdata.data))
|
item_path(intr, lookup_item(id, cdata.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type decode_inlined_item = fn(
|
pub type decode_inlined_item = &self/fn(
|
||||||
cdata: @cstore::crate_metadata,
|
cdata: @cstore::crate_metadata,
|
||||||
tcx: ty::ctxt,
|
tcx: ty::ctxt,
|
||||||
path: ast_map::path,
|
path: ast_map::path,
|
||||||
|
|
|
@ -1276,7 +1276,8 @@ fn encode_hash(ebml_w: writer::Encoder, hash: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: Increment this as you change the metadata encoding version.
|
// NB: Increment this as you change the metadata encoding version.
|
||||||
pub const metadata_encoding_version : &[u8] = &[0x72, //'r' as u8,
|
pub const metadata_encoding_version : &static/[u8] =
|
||||||
|
&[0x72, //'r' as u8,
|
||||||
0x75, //'u' as u8,
|
0x75, //'u' as u8,
|
||||||
0x73, //'s' as u8,
|
0x73, //'s' as u8,
|
||||||
0x74, //'t' as u8,
|
0x74, //'t' as u8,
|
||||||
|
|
|
@ -21,7 +21,7 @@ use core::result::Result;
|
||||||
use core::result;
|
use core::result;
|
||||||
use core::str;
|
use core::str;
|
||||||
|
|
||||||
pub type pick<T> = 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> {
|
pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
|
||||||
if path.file_path() == file { option::Some(copy *path) }
|
if path.file_path() == file { option::Some(copy *path) }
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub enum DefIdSource {
|
||||||
// Identifies a type parameter (`fn foo<X>() { ... }`).
|
// Identifies a type parameter (`fn foo<X>() { ... }`).
|
||||||
TypeParameter
|
TypeParameter
|
||||||
}
|
}
|
||||||
type conv_did = 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 {
|
pub struct PState {
|
||||||
data: @~[u8],
|
data: @~[u8],
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub impl BorrowckCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PreserveCtxt {
|
struct PreserveCtxt {
|
||||||
bccx: &BorrowckCtxt,
|
bccx: &self/BorrowckCtxt,
|
||||||
|
|
||||||
// the region scope for which we must preserve the memory
|
// the region scope for which we must preserve the memory
|
||||||
scope_region: ty::Region,
|
scope_region: ty::Region,
|
||||||
|
@ -79,7 +79,7 @@ struct PreserveCtxt {
|
||||||
root_managed_data: bool
|
root_managed_data: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl PreserveCtxt {
|
pub impl PreserveCtxt/&self {
|
||||||
fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
|
||||||
|
|
||||||
fn preserve(&self, cmt: cmt) -> bckres<PreserveCondition> {
|
fn preserve(&self, cmt: cmt) -> bckres<PreserveCondition> {
|
||||||
|
|
|
@ -55,7 +55,7 @@ use syntax::{visit, ast_util};
|
||||||
// primitives in the stdlib are explicitly annotated to only take sendable
|
// primitives in the stdlib are explicitly annotated to only take sendable
|
||||||
// types.
|
// types.
|
||||||
|
|
||||||
pub const try_adding: &str = "Try adding a move";
|
pub const try_adding: &static/str = "Try adding a move";
|
||||||
|
|
||||||
pub type rval_map = HashMap<node_id, ()>;
|
pub type rval_map = HashMap<node_id, ()>;
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,7 @@ fn LanguageItemCollector(crate: @crate,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LanguageItemCollector {
|
struct LanguageItemCollector {
|
||||||
items: &mut LanguageItems,
|
items: &self/mut LanguageItems,
|
||||||
|
|
||||||
crate: @crate,
|
crate: @crate,
|
||||||
session: Session,
|
session: Session,
|
||||||
|
@ -320,7 +320,7 @@ struct LanguageItemCollector {
|
||||||
item_refs: HashMap<@~str, uint>,
|
item_refs: HashMap<@~str, uint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl LanguageItemCollector {
|
pub impl LanguageItemCollector/&self {
|
||||||
fn match_and_collect_meta_item(&self, item_def_id: def_id,
|
fn match_and_collect_meta_item(&self, item_def_id: def_id,
|
||||||
meta_item: @meta_item) {
|
meta_item: @meta_item) {
|
||||||
match meta_item.node {
|
match meta_item.node {
|
||||||
|
|
|
@ -213,7 +213,7 @@ pub impl<T> ResolveResult<T> {
|
||||||
|
|
||||||
pub enum TypeParameters/& {
|
pub enum TypeParameters/& {
|
||||||
NoTypeParameters, //< No type parameters.
|
NoTypeParameters, //< No type parameters.
|
||||||
HasTypeParameters(&Generics, //< Type parameters.
|
HasTypeParameters(&self/Generics, //< Type parameters.
|
||||||
node_id, //< ID of the enclosing item
|
node_id, //< ID of the enclosing item
|
||||||
|
|
||||||
// The index to start numbering the type parameters at.
|
// The index to start numbering the type parameters at.
|
||||||
|
|
|
@ -328,13 +328,13 @@ pub type BindingsMap = HashMap<ident, BindingInfo>;
|
||||||
|
|
||||||
pub struct ArmData {
|
pub struct ArmData {
|
||||||
bodycx: block,
|
bodycx: block,
|
||||||
arm: &ast::arm,
|
arm: &self/ast::arm,
|
||||||
bindings_map: BindingsMap
|
bindings_map: BindingsMap
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Match {
|
pub struct Match {
|
||||||
pats: ~[@ast::pat],
|
pats: ~[@ast::pat],
|
||||||
data: @ArmData
|
data: @ArmData/&self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn match_to_str(bcx: block, m: &Match) -> ~str {
|
pub fn match_to_str(bcx: block, m: &Match) -> ~str {
|
||||||
|
@ -392,7 +392,7 @@ pub fn expand_nested_bindings(bcx: block, m: &[@Match/&r],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type enter_pat = 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) {
|
pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
|
||||||
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
|
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
|
||||||
|
|
|
@ -550,8 +550,8 @@ pub fn trans_call_inner(
|
||||||
|
|
||||||
|
|
||||||
pub enum CallArgs {
|
pub enum CallArgs {
|
||||||
ArgExprs(&[@ast::expr]),
|
ArgExprs(&self/[@ast::expr]),
|
||||||
ArgVals(&[ValueRef])
|
ArgVals(&self/[ValueRef])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
|
|
|
@ -97,10 +97,10 @@ fn c_stack_tys(ccx: @CrateContext,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type shim_arg_builder = fn(bcx: block, tys: @c_stack_tys,
|
type shim_arg_builder = &self/fn(bcx: block, tys: @c_stack_tys,
|
||||||
llargbundle: ValueRef) -> ~[ValueRef];
|
llargbundle: ValueRef) -> ~[ValueRef];
|
||||||
|
|
||||||
type shim_ret_builder = fn(bcx: block, tys: @c_stack_tys,
|
type shim_ret_builder = &self/fn(bcx: block, tys: @c_stack_tys,
|
||||||
llargbundle: ValueRef, llretval: ValueRef);
|
llargbundle: ValueRef, llretval: ValueRef);
|
||||||
|
|
||||||
fn build_shim_fn_(ccx: @CrateContext,
|
fn build_shim_fn_(ccx: @CrateContext,
|
||||||
|
@ -133,11 +133,11 @@ fn build_shim_fn_(ccx: @CrateContext,
|
||||||
return llshimfn;
|
return llshimfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrap_arg_builder = fn(bcx: block, tys: @c_stack_tys,
|
type wrap_arg_builder = &self/fn(bcx: block, tys: @c_stack_tys,
|
||||||
llwrapfn: ValueRef,
|
llwrapfn: ValueRef,
|
||||||
llargbundle: ValueRef);
|
llargbundle: ValueRef);
|
||||||
|
|
||||||
type wrap_ret_builder = fn(bcx: block, tys: @c_stack_tys,
|
type wrap_ret_builder = &self/fn(bcx: block, tys: @c_stack_tys,
|
||||||
llargbundle: ValueRef);
|
llargbundle: ValueRef);
|
||||||
|
|
||||||
fn build_wrap_fn_(ccx: @CrateContext,
|
fn build_wrap_fn_(ccx: @CrateContext,
|
||||||
|
|
|
@ -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 val_and_ty_fn = @fn(block, ValueRef, ty::t) -> Result;
|
||||||
|
|
||||||
pub type iter_vec_block = &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,
|
pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
|
||||||
fill: ValueRef, f: iter_vec_block) -> block {
|
fill: ValueRef, f: iter_vec_block) -> block {
|
||||||
|
|
|
@ -143,7 +143,7 @@ pub struct LookupContext {
|
||||||
self_expr: @ast::expr,
|
self_expr: @ast::expr,
|
||||||
callee_id: node_id,
|
callee_id: node_id,
|
||||||
m_name: ast::ident,
|
m_name: ast::ident,
|
||||||
supplied_tps: &[ty::t],
|
supplied_tps: &self/[ty::t],
|
||||||
impl_dups: HashMap<def_id, ()>,
|
impl_dups: HashMap<def_id, ()>,
|
||||||
inherent_candidates: DVec<Candidate>,
|
inherent_candidates: DVec<Candidate>,
|
||||||
extension_candidates: DVec<Candidate>,
|
extension_candidates: DVec<Candidate>,
|
||||||
|
@ -176,7 +176,7 @@ pub enum TransformTypeFlag {
|
||||||
TransformTypeForObject,
|
TransformTypeForObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl LookupContext {
|
pub impl LookupContext/&self {
|
||||||
fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
|
fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
|
||||||
debug!("do_lookup(self_ty=%s, expr=%s, self_expr=%s)",
|
debug!("do_lookup(self_ty=%s, expr=%s, self_expr=%s)",
|
||||||
self.ty_to_str(self_ty),
|
self.ty_to_str(self_ty),
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub trait LatticeValue {
|
||||||
-> cres<Self>;
|
-> cres<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type LatticeOp<T> = &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 {
|
impl LatticeValue for ty::t {
|
||||||
static fn sub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
|
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> = &fn(a: &T, b: &T) -> cres<T>;
|
pub type LatticeDirOp<T> = &self/fn(a: &T, b: &T) -> cres<T>;
|
||||||
|
|
||||||
pub enum LatticeVarResult<V,T> {
|
pub enum LatticeVarResult<V,T> {
|
||||||
VarResult(V),
|
VarResult(V),
|
||||||
|
|
|
@ -36,7 +36,7 @@ pub struct Ctxt {
|
||||||
ast_map: ast_map::map
|
ast_map: ast_map::map
|
||||||
}
|
}
|
||||||
|
|
||||||
type SrvOwner<T> = &fn(srv: Srv) -> T;
|
type SrvOwner<T> = &'self fn(srv: Srv) -> T;
|
||||||
pub type CtxtHandler<T> = ~fn(ctxt: Ctxt) -> T;
|
pub type CtxtHandler<T> = ~fn(ctxt: Ctxt) -> T;
|
||||||
type Parser = ~fn(Session, s: ~str) -> @ast::crate;
|
type Parser = ~fn(Session, s: ~str) -> @ast::crate;
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,17 @@ use core::ptr;
|
||||||
use core::task;
|
use core::task;
|
||||||
|
|
||||||
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
|
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
|
||||||
pub struct Condvar { is_mutex: bool, failed: &mut bool, cond: &sync::Condvar }
|
pub struct Condvar {
|
||||||
|
is_mutex: bool,
|
||||||
|
failed: &self/mut bool,
|
||||||
|
cond: &self/sync::Condvar/&self
|
||||||
|
}
|
||||||
|
|
||||||
pub impl &Condvar {
|
pub impl Condvar/&self {
|
||||||
/// Atomically exit the associated ARC and block until a signal is sent.
|
/// Atomically exit the associated ARC and block until a signal is sent.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn wait() { self.wait_on(0) }
|
fn wait(&self) { self.wait_on(0) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Atomically exit the associated ARC and block on a specified condvar
|
* Atomically exit the associated ARC and block on a specified condvar
|
||||||
* until a signal is sent on that same condvar (as sync::cond.wait_on).
|
* until a signal is sent on that same condvar (as sync::cond.wait_on).
|
||||||
|
@ -38,33 +43,37 @@ pub impl &Condvar {
|
||||||
* wait() is equivalent to wait_on(0).
|
* wait() is equivalent to wait_on(0).
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn wait_on(condvar_id: uint) {
|
fn wait_on(&self, condvar_id: uint) {
|
||||||
assert !*self.failed;
|
assert !*self.failed;
|
||||||
self.cond.wait_on(condvar_id);
|
self.cond.wait_on(condvar_id);
|
||||||
// This is why we need to wrap sync::condvar.
|
// This is why we need to wrap sync::condvar.
|
||||||
check_poison(self.is_mutex, *self.failed);
|
check_poison(self.is_mutex, *self.failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wake up a blocked task. Returns false if there was no blocked task.
|
/// Wake up a blocked task. Returns false if there was no blocked task.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn signal() -> bool { self.signal_on(0) }
|
fn signal(&self) -> bool { self.signal_on(0) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wake up a blocked task on a specified condvar (as
|
* Wake up a blocked task on a specified condvar (as
|
||||||
* sync::cond.signal_on). Returns false if there was no blocked task.
|
* sync::cond.signal_on). Returns false if there was no blocked task.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn signal_on(condvar_id: uint) -> bool {
|
fn signal_on(&self, condvar_id: uint) -> bool {
|
||||||
assert !*self.failed;
|
assert !*self.failed;
|
||||||
self.cond.signal_on(condvar_id)
|
self.cond.signal_on(condvar_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wake up all blocked tasks. Returns the number of tasks woken.
|
/// Wake up all blocked tasks. Returns the number of tasks woken.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn broadcast() -> uint { self.broadcast_on(0) }
|
fn broadcast(&self) -> uint { self.broadcast_on(0) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wake up all blocked tasks on a specified condvar (as
|
* Wake up all blocked tasks on a specified condvar (as
|
||||||
* sync::cond.broadcast_on). Returns Returns the number of tasks woken.
|
* sync::cond.broadcast_on). Returns Returns the number of tasks woken.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn broadcast_on(condvar_id: uint) -> uint {
|
fn broadcast_on(&self, condvar_id: uint) -> uint {
|
||||||
assert !*self.failed;
|
assert !*self.failed;
|
||||||
self.cond.broadcast_on(condvar_id)
|
self.cond.broadcast_on(condvar_id)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +150,7 @@ impl<T:Owned> Clone for MutexARC<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T:Owned> &MutexARC<T> {
|
pub impl<T:Owned> MutexARC<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access the underlying mutable data with mutual exclusion from other
|
* Access the underlying mutable data with mutual exclusion from other
|
||||||
|
@ -167,7 +176,7 @@ pub impl<T:Owned> &MutexARC<T> {
|
||||||
* blocked on the mutex) will also fail immediately.
|
* blocked on the mutex) will also fail immediately.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn access<U>(blk: fn(x: &mut T) -> U) -> U {
|
unsafe fn access<U>(&self, blk: fn(x: &mut T) -> U) -> U {
|
||||||
unsafe {
|
unsafe {
|
||||||
let state = get_shared_mutable_state(&self.x);
|
let state = get_shared_mutable_state(&self.x);
|
||||||
// Borrowck would complain about this if the function were
|
// Borrowck would complain about this if the function were
|
||||||
|
@ -179,9 +188,13 @@ pub impl<T:Owned> &MutexARC<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// As access(), but with a condvar, as sync::mutex.lock_cond().
|
/// As access(), but with a condvar, as sync::mutex.lock_cond().
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn access_cond<U>(blk: fn(x: &x/mut T, c: &c/Condvar) -> U) -> U {
|
unsafe fn access_cond<U>(
|
||||||
|
&self,
|
||||||
|
blk: &fn(x: &x/mut T, c: &c/Condvar) -> U) -> U
|
||||||
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
let state = get_shared_mutable_state(&self.x);
|
let state = get_shared_mutable_state(&self.x);
|
||||||
do (&(*state).lock).lock_cond |cond| {
|
do (&(*state).lock).lock_cond |cond| {
|
||||||
|
@ -276,7 +289,7 @@ pub impl<T:Const + Owned> RWARC<T> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T:Const + Owned> &RWARC<T> {
|
pub impl<T:Const + Owned> RWARC<T> {
|
||||||
/**
|
/**
|
||||||
* Access the underlying data mutably. Locks the rwlock in write mode;
|
* Access the underlying data mutably. Locks the rwlock in write mode;
|
||||||
* other readers and writers will block.
|
* other readers and writers will block.
|
||||||
|
@ -288,7 +301,7 @@ pub impl<T:Const + Owned> &RWARC<T> {
|
||||||
* poison the ARC, so subsequent readers and writers will both also fail.
|
* poison the ARC, so subsequent readers and writers will both also fail.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn write<U>(blk: fn(x: &mut T) -> U) -> U {
|
fn write<U>(&self, blk: fn(x: &mut T) -> U) -> U {
|
||||||
unsafe {
|
unsafe {
|
||||||
let state = get_shared_mutable_state(&self.x);
|
let state = get_shared_mutable_state(&self.x);
|
||||||
do (*borrow_rwlock(state)).write {
|
do (*borrow_rwlock(state)).write {
|
||||||
|
@ -300,7 +313,7 @@ pub impl<T:Const + Owned> &RWARC<T> {
|
||||||
}
|
}
|
||||||
/// As write(), but with a condvar, as sync::rwlock.write_cond().
|
/// As write(), but with a condvar, as sync::rwlock.write_cond().
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn write_cond<U>(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 {
|
unsafe {
|
||||||
let state = get_shared_mutable_state(&self.x);
|
let state = get_shared_mutable_state(&self.x);
|
||||||
do (*borrow_rwlock(state)).write_cond |cond| {
|
do (*borrow_rwlock(state)).write_cond |cond| {
|
||||||
|
@ -389,13 +402,13 @@ fn borrow_rwlock<T:Const + Owned>(state: *const RWARCInner<T>) -> *RWlock {
|
||||||
|
|
||||||
/// The "write permission" token used for RWARC.write_downgrade().
|
/// The "write permission" token used for RWARC.write_downgrade().
|
||||||
pub enum RWWriteMode<T> =
|
pub enum RWWriteMode<T> =
|
||||||
(&mut T, sync::RWlockWriteMode, PoisonOnFail);
|
(&self/mut T, sync::RWlockWriteMode/&self, PoisonOnFail);
|
||||||
/// The "read permission" token used for RWARC.write_downgrade().
|
/// The "read permission" token used for RWARC.write_downgrade().
|
||||||
pub enum RWReadMode<T> = (&T, sync::RWlockReadMode);
|
pub enum RWReadMode<T> = (&self/T, sync::RWlockReadMode/&self);
|
||||||
|
|
||||||
pub impl<T:Const + Owned> &RWWriteMode<T> {
|
pub impl<T:Const + Owned> RWWriteMode/&self<T> {
|
||||||
/// Access the pre-downgrade RWARC in write mode.
|
/// Access the pre-downgrade RWARC in write mode.
|
||||||
fn write<U>(blk: fn(x: &mut T) -> U) -> U {
|
fn write<U>(&self, blk: fn(x: &mut T) -> U) -> U {
|
||||||
match *self {
|
match *self {
|
||||||
RWWriteMode((ref data, ref token, _)) => {
|
RWWriteMode((ref data, ref token, _)) => {
|
||||||
do token.write {
|
do token.write {
|
||||||
|
@ -405,7 +418,7 @@ pub impl<T:Const + Owned> &RWWriteMode<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Access the pre-downgrade RWARC in write mode with a condvar.
|
/// Access the pre-downgrade RWARC in write mode with a condvar.
|
||||||
fn write_cond<U>(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 {
|
match *self {
|
||||||
RWWriteMode((ref data, ref token, ref poison)) => {
|
RWWriteMode((ref data, ref token, ref poison)) => {
|
||||||
do token.write_cond |cond| {
|
do token.write_cond |cond| {
|
||||||
|
@ -423,9 +436,9 @@ pub impl<T:Const + Owned> &RWWriteMode<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T:Const + Owned> &RWReadMode<T> {
|
pub impl<T:Const + Owned> RWReadMode/&self<T> {
|
||||||
/// Access the post-downgrade rwlock in read mode.
|
/// Access the post-downgrade rwlock in read mode.
|
||||||
fn read<U>(blk: fn(x: &T) -> U) -> U {
|
fn read<U>(&self, blk: fn(x: &T) -> U) -> U {
|
||||||
match *self {
|
match *self {
|
||||||
RWReadMode((data, ref token)) => {
|
RWReadMode((data, ref token)) => {
|
||||||
do token.read { blk(data) }
|
do token.read { blk(data) }
|
||||||
|
|
|
@ -160,9 +160,9 @@ unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
|
||||||
(reinterpret_cast(&(p & !1)), p & 1 == 1)
|
(reinterpret_cast(&(p & !1)), p & 1 == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl &Arena {
|
pub impl Arena {
|
||||||
// Functions for the POD part of the arena
|
// Functions for the POD part of the arena
|
||||||
fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {
|
fn alloc_pod_grow(&self, n_bytes: uint, align: uint) -> *u8 {
|
||||||
// Allocate a new chunk.
|
// Allocate a new chunk.
|
||||||
let chunk_size = at_vec::capacity(self.pod_head.data);
|
let chunk_size = at_vec::capacity(self.pod_head.data);
|
||||||
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
|
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
|
||||||
|
@ -174,7 +174,7 @@ pub impl &Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn alloc_pod_inner(n_bytes: uint, align: uint) -> *u8 {
|
fn alloc_pod_inner(&self, n_bytes: uint, align: uint) -> *u8 {
|
||||||
let head = &mut self.pod_head;
|
let head = &mut self.pod_head;
|
||||||
|
|
||||||
let start = round_up_to(head.fill, align);
|
let start = round_up_to(head.fill, align);
|
||||||
|
@ -193,7 +193,7 @@ pub impl &Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn alloc_pod<T>(op: fn() -> T) -> &self/T {
|
fn alloc_pod<T>(&self, op: fn() -> T) -> &self/T {
|
||||||
unsafe {
|
unsafe {
|
||||||
let tydesc = sys::get_type_desc::<T>();
|
let tydesc = sys::get_type_desc::<T>();
|
||||||
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
|
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
|
||||||
|
@ -204,7 +204,7 @@ pub impl &Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions for the non-POD part of the arena
|
// Functions for the non-POD part of the arena
|
||||||
fn alloc_nonpod_grow(n_bytes: uint, align: uint) -> (*u8, *u8) {
|
fn alloc_nonpod_grow(&self, n_bytes: uint, align: uint) -> (*u8, *u8) {
|
||||||
// Allocate a new chunk.
|
// Allocate a new chunk.
|
||||||
let chunk_size = at_vec::capacity(self.head.data);
|
let chunk_size = at_vec::capacity(self.head.data);
|
||||||
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
|
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
|
||||||
|
@ -216,7 +216,7 @@ pub impl &Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn alloc_nonpod_inner(n_bytes: uint, align: uint) -> (*u8, *u8) {
|
fn alloc_nonpod_inner(&self, n_bytes: uint, align: uint) -> (*u8, *u8) {
|
||||||
let head = &mut self.head;
|
let head = &mut self.head;
|
||||||
|
|
||||||
let tydesc_start = head.fill;
|
let tydesc_start = head.fill;
|
||||||
|
@ -238,7 +238,7 @@ pub impl &Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn alloc_nonpod<T>(op: fn() -> T) -> &self/T {
|
fn alloc_nonpod<T>(&self, op: fn() -> T) -> &self/T {
|
||||||
unsafe {
|
unsafe {
|
||||||
let tydesc = sys::get_type_desc::<T>();
|
let tydesc = sys::get_type_desc::<T>();
|
||||||
let (ty_ptr, ptr) =
|
let (ty_ptr, ptr) =
|
||||||
|
@ -260,7 +260,7 @@ pub impl &Arena {
|
||||||
|
|
||||||
// The external interface
|
// The external interface
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn alloc<T>(op: fn() -> T) -> &self/T {
|
fn alloc<T>(&self, op: fn() -> T) -> &self/T {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !rusti::needs_drop::<T>() {
|
if !rusti::needs_drop::<T>() {
|
||||||
self.alloc_pod(op)
|
self.alloc_pod(op)
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub trait ToBase64 {
|
||||||
pure fn to_base64() -> ~str;
|
pure fn to_base64() -> ~str;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToBase64 for &[u8] {
|
impl ToBase64 for &self/[u8] {
|
||||||
pure fn to_base64() -> ~str {
|
pure fn to_base64() -> ~str {
|
||||||
let chars = str::chars(
|
let chars = str::chars(
|
||||||
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
||||||
|
@ -69,7 +69,7 @@ impl ToBase64 for &[u8] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToBase64 for &str {
|
impl ToBase64 for &self/str {
|
||||||
pure fn to_base64() -> ~str {
|
pure fn to_base64() -> ~str {
|
||||||
str::to_bytes(self).to_base64()
|
str::to_bytes(self).to_base64()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1045,7 +1045,9 @@ mod biguint_tests {
|
||||||
assert BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value;
|
assert BigUint::new(~[0, 0, -1]).to_uint() == uint::max_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sum_triples: &[(&[BigDigit], &[BigDigit], &[BigDigit])] = &[
|
const sum_triples: &static/[(&static/[BigDigit],
|
||||||
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit])] = &[
|
||||||
(&[], &[], &[]),
|
(&[], &[], &[]),
|
||||||
(&[], &[ 1], &[ 1]),
|
(&[], &[ 1], &[ 1]),
|
||||||
(&[ 1], &[ 1], &[ 2]),
|
(&[ 1], &[ 1], &[ 2]),
|
||||||
|
@ -1083,7 +1085,9 @@ mod biguint_tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mul_triples: &[(&[BigDigit], &[BigDigit], &[BigDigit])] = &[
|
const mul_triples: &static/[(&static/[BigDigit],
|
||||||
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit])] = &[
|
||||||
(&[], &[], &[]),
|
(&[], &[], &[]),
|
||||||
(&[], &[ 1], &[]),
|
(&[], &[ 1], &[]),
|
||||||
(&[ 2], &[], &[]),
|
(&[ 2], &[], &[]),
|
||||||
|
@ -1107,8 +1111,10 @@ mod biguint_tests {
|
||||||
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
|
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
|
||||||
];
|
];
|
||||||
|
|
||||||
const divmod_quadruples: &[(&[BigDigit], &[BigDigit],
|
const divmod_quadruples: &static/[(&static/[BigDigit],
|
||||||
&[BigDigit], &[BigDigit])]
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit])]
|
||||||
= &[
|
= &[
|
||||||
(&[ 1], &[ 2], &[], &[1]),
|
(&[ 1], &[ 2], &[], &[1]),
|
||||||
(&[ 1, 1], &[ 2], &[-1/2+1], &[1]),
|
(&[ 1, 1], &[ 2], &[-1/2+1], &[1]),
|
||||||
|
@ -1393,7 +1399,9 @@ mod bigint_tests {
|
||||||
).to_uint() == 0;
|
).to_uint() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sum_triples: &[(&[BigDigit], &[BigDigit], &[BigDigit])] = &[
|
const sum_triples: &static/[(&static/[BigDigit],
|
||||||
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit])] = &[
|
||||||
(&[], &[], &[]),
|
(&[], &[], &[]),
|
||||||
(&[], &[ 1], &[ 1]),
|
(&[], &[ 1], &[ 1]),
|
||||||
(&[ 1], &[ 1], &[ 2]),
|
(&[ 1], &[ 1], &[ 2]),
|
||||||
|
@ -1443,7 +1451,9 @@ mod bigint_tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mul_triples: &[(&[BigDigit], &[BigDigit], &[BigDigit])] = &[
|
const mul_triples: &static/[(&static/[BigDigit],
|
||||||
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit])] = &[
|
||||||
(&[], &[], &[]),
|
(&[], &[], &[]),
|
||||||
(&[], &[ 1], &[]),
|
(&[], &[ 1], &[]),
|
||||||
(&[ 2], &[], &[]),
|
(&[ 2], &[], &[]),
|
||||||
|
@ -1467,8 +1477,10 @@ mod bigint_tests {
|
||||||
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
|
(&[ 0, 0, 1], &[ 0, 0, 0, 1], &[0, 0, 0, 0, 0, 1])
|
||||||
];
|
];
|
||||||
|
|
||||||
const divmod_quadruples: &[(&[BigDigit], &[BigDigit],
|
const divmod_quadruples: &static/[(&static/[BigDigit],
|
||||||
&[BigDigit], &[BigDigit])]
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit],
|
||||||
|
&static/[BigDigit])]
|
||||||
= &[
|
= &[
|
||||||
(&[ 1], &[ 2], &[], &[1]),
|
(&[ 1], &[ 2], &[], &[1]),
|
||||||
(&[ 1, 1], &[ 2], &[-1/2+1], &[1]),
|
(&[ 1, 1], &[ 2], &[-1/2+1], &[1]),
|
||||||
|
|
|
@ -468,8 +468,8 @@ pub mod flatteners {
|
||||||
static fn from_writer(w: Writer) -> Self;
|
static fn from_writer(w: Writer) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromReader for json::Decoder {
|
impl FromReader for json::Decoder/&self {
|
||||||
static fn from_reader(r: Reader) -> json::Decoder {
|
static fn from_reader(r: Reader) -> json::Decoder/&self {
|
||||||
match json::from_reader(r) {
|
match json::from_reader(r) {
|
||||||
Ok(json) => {
|
Ok(json) => {
|
||||||
json::Decoder(json)
|
json::Decoder(json)
|
||||||
|
|
|
@ -749,14 +749,14 @@ pub fn from_str(s: &str) -> Result<Json, Error> {
|
||||||
|
|
||||||
pub struct Decoder {
|
pub struct Decoder {
|
||||||
priv json: Json,
|
priv json: Json,
|
||||||
priv mut stack: ~[&Json],
|
priv mut stack: ~[&self/Json],
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Decoder(json: Json) -> Decoder {
|
pub fn Decoder(json: Json) -> Decoder {
|
||||||
Decoder { json: json, stack: ~[] }
|
Decoder { json: json, stack: ~[] }
|
||||||
}
|
}
|
||||||
|
|
||||||
priv impl 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); }
|
if self.stack.len() == 0 { self.stack.push(&self.json); }
|
||||||
self.stack[self.stack.len() - 1]
|
self.stack[self.stack.len() - 1]
|
||||||
|
@ -768,7 +768,7 @@ priv impl Decoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl serialize::Decoder for Decoder {
|
impl serialize::Decoder for Decoder/&self {
|
||||||
fn read_nil(&self) -> () {
|
fn read_nil(&self) -> () {
|
||||||
debug!("read_nil");
|
debug!("read_nil");
|
||||||
match *self.pop() {
|
match *self.pop() {
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl<D:Decoder> Decodable<D> for i64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S:Encoder> Encodable<S> for &str {
|
impl<S:Encoder> Encodable<S> for &self/str {
|
||||||
fn encode(&self, s: &S) { s.emit_borrowed_str(*self) }
|
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 &T {
|
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &self/T {
|
||||||
fn encode(&self, s: &S) {
|
fn encode(&self, s: &S) {
|
||||||
s.emit_borrowed(|| (**self).encode(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 &[T] {
|
impl<S:Encoder,T:Encodable<S>> Encodable<S> for &self/[T] {
|
||||||
fn encode(&self, s: &S) {
|
fn encode(&self, s: &S) {
|
||||||
do s.emit_borrowed_vec(self.len()) {
|
do s.emit_borrowed_vec(self.len()) {
|
||||||
for self.eachi |i, e| {
|
for self.eachi |i, e| {
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub struct SmallIntMap<T> {
|
||||||
priv v: ~[Option<T>],
|
priv v: ~[Option<T>],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V> BaseIter<(uint, &V)> for SmallIntMap<V> {
|
impl<V> BaseIter<(uint, &self/V)> for SmallIntMap<V> {
|
||||||
/// Visit all key-value pairs in order
|
/// 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| {
|
for uint::range(0, self.v.len()) |i| {
|
||||||
|
@ -36,7 +36,7 @@ impl<V> BaseIter<(uint, &V)> for SmallIntMap<V> {
|
||||||
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V> ReverseIter<(uint, &V)> for SmallIntMap<V> {
|
impl<V> ReverseIter<(uint, &self/V)> for SmallIntMap<V> {
|
||||||
/// Visit all key-value pairs in reverse order
|
/// 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| {
|
for uint::range_rev(self.v.len(), 0) |i| {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use core::util;
|
||||||
use core::vec::{len, push};
|
use core::vec::{len, push};
|
||||||
use core::vec;
|
use core::vec;
|
||||||
|
|
||||||
type Le<T> = 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.
|
* Merge sort. Returns a new vector containing the sorted list.
|
||||||
|
@ -169,7 +169,7 @@ pub trait Sort {
|
||||||
fn qsort(self);
|
fn qsort(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Copy + Ord + Eq> Sort for &mut [T] {
|
impl<T:Copy + Ord + Eq> Sort for &self/mut [T] {
|
||||||
fn qsort(self) { quick_sort3(self); }
|
fn qsort(self) { quick_sort3(self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,11 +1178,10 @@ mod big_tests {
|
||||||
|
|
||||||
struct LVal {
|
struct LVal {
|
||||||
val: uint,
|
val: uint,
|
||||||
key: fn(@uint),
|
key: &self/fn(@uint),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for LVal {
|
impl Drop for LVal/&self {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
let x = unsafe { task::local_data::local_data_get(self.key) };
|
let x = unsafe { task::local_data::local_data_get(self.key) };
|
||||||
match x {
|
match x {
|
||||||
|
@ -1196,7 +1195,7 @@ mod big_tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for LVal {
|
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
|
(*self).val < other.val
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub trait Stats {
|
||||||
fn median_abs_dev_pct(self) -> f64;
|
fn median_abs_dev_pct(self) -> f64;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stats for &[f64] {
|
impl Stats for &self/[f64] {
|
||||||
fn sum(self) -> f64 {
|
fn sum(self) -> f64 {
|
||||||
vec::foldl(0.0, self, |p,q| p + *q)
|
vec::foldl(0.0, self, |p,q| p + *q)
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub impl<Q:Owned> &Sem<Q> {
|
pub impl<Q:Owned> &self/Sem<Q> {
|
||||||
fn acquire() {
|
fn acquire() {
|
||||||
let mut waiter_nobe = None;
|
let mut waiter_nobe = None;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -134,7 +134,7 @@ pub impl<Q:Owned> &Sem<Q> {
|
||||||
}
|
}
|
||||||
// FIXME(#3154) move both copies of this into Sem<Q>, and unify the 2 structs
|
// FIXME(#3154) move both copies of this into Sem<Q>, and unify the 2 structs
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub impl &Sem<()> {
|
pub impl &self/Sem<()> {
|
||||||
fn access<U>(blk: fn() -> U) -> U {
|
fn access<U>(blk: fn() -> U) -> U {
|
||||||
let mut release = None;
|
let mut release = None;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -147,7 +147,7 @@ pub impl &Sem<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub impl &Sem<~[Waitqueue]> {
|
pub impl &self/Sem<~[Waitqueue]> {
|
||||||
fn access<U>(blk: fn() -> U) -> U {
|
fn access<U>(blk: fn() -> U) -> U {
|
||||||
let mut release = None;
|
let mut release = None;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -162,11 +162,11 @@ pub impl &Sem<~[Waitqueue]> {
|
||||||
|
|
||||||
// FIXME(#3588) should go inside of access()
|
// FIXME(#3588) should go inside of access()
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
type SemRelease = SemReleaseGeneric<()>;
|
type SemRelease = SemReleaseGeneric/&self<()>;
|
||||||
type SemAndSignalRelease = SemReleaseGeneric<~[Waitqueue]>;
|
type SemAndSignalRelease = SemReleaseGeneric/&self<~[Waitqueue]>;
|
||||||
struct SemReleaseGeneric<Q> { sem: &Sem<Q> }
|
struct SemReleaseGeneric<Q> { sem: &self/Sem<Q> }
|
||||||
|
|
||||||
impl<Q:Owned> Drop for SemReleaseGeneric<Q> {
|
impl<Q:Owned> Drop for SemReleaseGeneric/&self<Q> {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
self.sem.release();
|
self.sem.release();
|
||||||
}
|
}
|
||||||
|
@ -186,11 +186,11 @@ fn SemAndSignalRelease(sem: &r/Sem<~[Waitqueue]>)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
||||||
pub struct Condvar { priv sem: &Sem<~[Waitqueue]> }
|
pub struct Condvar { priv sem: &self/Sem<~[Waitqueue]> }
|
||||||
|
|
||||||
impl Drop for Condvar { fn finalize(&self) {} }
|
impl Drop for Condvar/&self { fn finalize(&self) {} }
|
||||||
|
|
||||||
pub impl &Condvar {
|
pub impl Condvar/&self {
|
||||||
/**
|
/**
|
||||||
* Atomically drop the associated lock, and block until a signal is sent.
|
* Atomically drop the associated lock, and block until a signal is sent.
|
||||||
*
|
*
|
||||||
|
@ -199,7 +199,8 @@ pub impl &Condvar {
|
||||||
* while waiting on a condition variable will wake up, fail, and unlock
|
* while waiting on a condition variable will wake up, fail, and unlock
|
||||||
* the associated lock as it unwinds.
|
* the associated lock as it unwinds.
|
||||||
*/
|
*/
|
||||||
fn wait() { self.wait_on(0) }
|
fn wait(&self) { self.wait_on(0) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As wait(), but can specify which of multiple condition variables to
|
* As wait(), but can specify which of multiple condition variables to
|
||||||
* wait on. Only a signal_on() or broadcast_on() with the same condvar_id
|
* wait on. Only a signal_on() or broadcast_on() with the same condvar_id
|
||||||
|
@ -211,7 +212,7 @@ pub impl &Condvar {
|
||||||
*
|
*
|
||||||
* wait() is equivalent to wait_on(0).
|
* wait() is equivalent to wait_on(0).
|
||||||
*/
|
*/
|
||||||
fn wait_on(condvar_id: uint) {
|
fn wait_on(&self, condvar_id: uint) {
|
||||||
// Create waiter nobe.
|
// Create waiter nobe.
|
||||||
let (WaitEnd, SignalEnd) = comm::oneshot();
|
let (WaitEnd, SignalEnd) = comm::oneshot();
|
||||||
let mut WaitEnd = Some(WaitEnd);
|
let mut WaitEnd = Some(WaitEnd);
|
||||||
|
@ -256,10 +257,10 @@ pub impl &Condvar {
|
||||||
// mutex during unwinding. As long as the wrapper (mutex, etc) is
|
// mutex during unwinding. As long as the wrapper (mutex, etc) is
|
||||||
// bounded in when it gets released, this shouldn't hang forever.
|
// bounded in when it gets released, this shouldn't hang forever.
|
||||||
struct SemAndSignalReacquire {
|
struct SemAndSignalReacquire {
|
||||||
sem: &Sem<~[Waitqueue]>,
|
sem: &self/Sem<~[Waitqueue]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for SemAndSignalReacquire {
|
impl Drop for SemAndSignalReacquire/&self {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Needs to succeed, instead of itself dying.
|
// Needs to succeed, instead of itself dying.
|
||||||
|
@ -279,9 +280,10 @@ pub impl &Condvar {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wake up a blocked task. Returns false if there was no blocked task.
|
/// Wake up a blocked task. Returns false if there was no blocked task.
|
||||||
fn signal() -> bool { self.signal_on(0) }
|
fn signal(&self) -> bool { self.signal_on(0) }
|
||||||
|
|
||||||
/// As signal, but with a specified condvar_id. See wait_on.
|
/// As signal, but with a specified condvar_id. See wait_on.
|
||||||
fn signal_on(condvar_id: uint) -> bool {
|
fn signal_on(&self, condvar_id: uint) -> bool {
|
||||||
let mut out_of_bounds = None;
|
let mut out_of_bounds = None;
|
||||||
let mut result = false;
|
let mut result = false;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -299,9 +301,10 @@ pub impl &Condvar {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wake up all blocked tasks. Returns the number of tasks woken.
|
/// Wake up all blocked tasks. Returns the number of tasks woken.
|
||||||
fn broadcast() -> uint { self.broadcast_on(0) }
|
fn broadcast(&self) -> uint { self.broadcast_on(0) }
|
||||||
|
|
||||||
/// As broadcast, but with a specified condvar_id. See wait_on.
|
/// As broadcast, but with a specified condvar_id. See wait_on.
|
||||||
fn broadcast_on(condvar_id: uint) -> uint {
|
fn broadcast_on(&self, condvar_id: uint) -> uint {
|
||||||
let mut out_of_bounds = None;
|
let mut out_of_bounds = None;
|
||||||
let mut queue = None;
|
let mut queue = None;
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -342,9 +345,9 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub impl &Sem<~[Waitqueue]> {
|
pub impl Sem<~[Waitqueue]> {
|
||||||
// The only other place that condvars get built is rwlock_write_mode.
|
// The only other place that condvars get built is rwlock_write_mode.
|
||||||
fn access_cond<U>(blk: fn(c: &Condvar) -> U) -> U {
|
fn access_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U {
|
||||||
do self.access { blk(&Condvar { sem: self }) }
|
do self.access { blk(&Condvar { sem: self }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,18 +371,18 @@ impl Clone for Semaphore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl &Semaphore {
|
pub impl Semaphore {
|
||||||
/**
|
/**
|
||||||
* Acquire a resource represented by the semaphore. Blocks if necessary
|
* Acquire a resource represented by the semaphore. Blocks if necessary
|
||||||
* until resource(s) become available.
|
* until resource(s) become available.
|
||||||
*/
|
*/
|
||||||
fn acquire() { (&self.sem).acquire() }
|
fn acquire(&self) { (&self.sem).acquire() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release a held resource represented by the semaphore. Wakes a blocked
|
* Release a held resource represented by the semaphore. Wakes a blocked
|
||||||
* contending task, if any exist. Won't block the caller.
|
* contending task, if any exist. Won't block the caller.
|
||||||
*/
|
*/
|
||||||
fn release() { (&self.sem).release() }
|
fn release(&self) { (&self.sem).release() }
|
||||||
|
|
||||||
/// Run a function with ownership of one of the semaphore's resources.
|
/// Run a function with ownership of one of the semaphore's resources.
|
||||||
fn access<U>(blk: fn() -> U) -> U { (&self.sem).access(blk) }
|
fn access<U>(blk: fn() -> U) -> U { (&self.sem).access(blk) }
|
||||||
|
@ -416,12 +419,12 @@ impl Clone for Mutex {
|
||||||
fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } }
|
fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl &Mutex {
|
pub impl Mutex {
|
||||||
/// Run a function with ownership of the mutex.
|
/// Run a function with ownership of the mutex.
|
||||||
fn lock<U>(blk: fn() -> U) -> U { (&self.sem).access(blk) }
|
fn lock<U>(&self, blk: fn() -> U) -> U { (&self.sem).access(blk) }
|
||||||
|
|
||||||
/// Run a function with ownership of the mutex and a handle to a condvar.
|
/// Run a function with ownership of the mutex and a handle to a condvar.
|
||||||
fn lock_cond<U>(blk: fn(c: &Condvar) -> U) -> U {
|
fn lock_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U {
|
||||||
(&self.sem).access_cond(blk)
|
(&self.sem).access_cond(blk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,9 +468,9 @@ pub fn rwlock_with_condvars(num_condvars: uint) -> RWlock {
|
||||||
read_count: 0 }) }
|
read_count: 0 }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl &RWlock {
|
pub impl RWlock {
|
||||||
/// Create a new handle to the rwlock.
|
/// Create a new handle to the rwlock.
|
||||||
fn clone() -> RWlock {
|
fn clone(&self) -> RWlock {
|
||||||
RWlock { order_lock: (&(self.order_lock)).clone(),
|
RWlock { order_lock: (&(self.order_lock)).clone(),
|
||||||
access_lock: Sem((*self.access_lock).clone()),
|
access_lock: Sem((*self.access_lock).clone()),
|
||||||
state: self.state.clone() }
|
state: self.state.clone() }
|
||||||
|
@ -477,7 +480,7 @@ pub impl &RWlock {
|
||||||
* Run a function with the rwlock in read mode. Calls to 'read' from other
|
* Run a function with the rwlock in read mode. Calls to 'read' from other
|
||||||
* tasks may run concurrently with this one.
|
* tasks may run concurrently with this one.
|
||||||
*/
|
*/
|
||||||
fn read<U>(blk: fn() -> U) -> U {
|
fn read<U>(&self, blk: fn() -> U) -> U {
|
||||||
let mut release = None;
|
let mut release = None;
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
|
@ -508,7 +511,7 @@ pub impl &RWlock {
|
||||||
* Run a function with the rwlock in write mode. No calls to 'read' or
|
* Run a function with the rwlock in write mode. No calls to 'read' or
|
||||||
* 'write' from other tasks will run concurrently with this one.
|
* 'write' from other tasks will run concurrently with this one.
|
||||||
*/
|
*/
|
||||||
fn write<U>(blk: fn() -> U) -> U {
|
fn write<U>(&self, blk: fn() -> U) -> U {
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
(&self.order_lock).acquire();
|
(&self.order_lock).acquire();
|
||||||
|
@ -526,7 +529,7 @@ pub impl &RWlock {
|
||||||
* the waiting task is signalled. (Note: a writer that waited and then
|
* the waiting task is signalled. (Note: a writer that waited and then
|
||||||
* was signalled might reacquire the lock before other waiting writers.)
|
* was signalled might reacquire the lock before other waiting writers.)
|
||||||
*/
|
*/
|
||||||
fn write_cond<U>(blk: fn(c: &Condvar) -> U) -> U {
|
fn write_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U {
|
||||||
// NB: You might think I should thread the order_lock into the cond
|
// NB: You might think I should thread the order_lock into the cond
|
||||||
// wait call, so that it gets waited on before access_lock gets
|
// wait call, so that it gets waited on before access_lock gets
|
||||||
// reacquired upon being woken up. However, (a) this would be not
|
// reacquired upon being woken up. However, (a) this would be not
|
||||||
|
@ -561,7 +564,7 @@ pub impl &RWlock {
|
||||||
* }
|
* }
|
||||||
* ~~~
|
* ~~~
|
||||||
*/
|
*/
|
||||||
fn write_downgrade<U>(blk: fn(v: RWlockWriteMode) -> U) -> U {
|
fn write_downgrade<U>(&self, blk: fn(v: RWlockWriteMode) -> U) -> U {
|
||||||
// Implementation slightly different from the slicker 'write's above.
|
// Implementation slightly different from the slicker 'write's above.
|
||||||
// The exit path is conditional on whether the caller downgrades.
|
// The exit path is conditional on whether the caller downgrades.
|
||||||
let mut _release = None;
|
let mut _release = None;
|
||||||
|
@ -577,7 +580,7 @@ pub impl &RWlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// To be called inside of the write_downgrade block.
|
/// To be called inside of the write_downgrade block.
|
||||||
fn downgrade(token: RWlockWriteMode/&a) -> RWlockReadMode/&a {
|
fn downgrade(&self, token: RWlockWriteMode/&a) -> RWlockReadMode/&a {
|
||||||
if !ptr::ref_eq(self, token.lock) {
|
if !ptr::ref_eq(self, token.lock) {
|
||||||
fail!(~"Can't downgrade() with a different rwlock's write_mode!");
|
fail!(~"Can't downgrade() with a different rwlock's write_mode!");
|
||||||
}
|
}
|
||||||
|
@ -606,10 +609,10 @@ pub impl &RWlock {
|
||||||
// FIXME(#3588) should go inside of read()
|
// FIXME(#3588) should go inside of read()
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
struct RWlockReleaseRead {
|
struct RWlockReleaseRead {
|
||||||
lock: &RWlock,
|
lock: &self/RWlock,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for RWlockReleaseRead {
|
impl Drop for RWlockReleaseRead/&self {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
|
@ -640,10 +643,10 @@ fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r {
|
||||||
// FIXME(#3588) should go inside of downgrade()
|
// FIXME(#3588) should go inside of downgrade()
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
struct RWlockReleaseDowngrade {
|
struct RWlockReleaseDowngrade {
|
||||||
lock: &RWlock,
|
lock: &self/RWlock,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for RWlockReleaseDowngrade {
|
impl Drop for RWlockReleaseDowngrade/&self {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
|
@ -680,23 +683,25 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The "write permission" token used for rwlock.write_downgrade().
|
/// The "write permission" token used for rwlock.write_downgrade().
|
||||||
pub struct RWlockWriteMode { priv lock: &RWlock }
|
pub struct RWlockWriteMode { priv lock: &self/RWlock }
|
||||||
impl Drop for RWlockWriteMode { fn finalize(&self) {} }
|
impl Drop for RWlockWriteMode/&self { fn finalize(&self) {} }
|
||||||
/// The "read permission" token used for rwlock.write_downgrade().
|
|
||||||
pub struct RWlockReadMode { priv lock: &RWlock }
|
|
||||||
impl Drop for RWlockReadMode { fn finalize(&self) {} }
|
|
||||||
|
|
||||||
pub impl &RWlockWriteMode {
|
/// The "read permission" token used for rwlock.write_downgrade().
|
||||||
|
pub struct RWlockReadMode { priv lock: &self/RWlock }
|
||||||
|
impl Drop for RWlockReadMode/&self { fn finalize(&self) {} }
|
||||||
|
|
||||||
|
pub impl RWlockWriteMode/&self {
|
||||||
/// Access the pre-downgrade rwlock in write mode.
|
/// Access the pre-downgrade rwlock in write mode.
|
||||||
fn write<U>(blk: fn() -> U) -> U { blk() }
|
fn write<U>(&self, blk: fn() -> U) -> U { blk() }
|
||||||
/// Access the pre-downgrade rwlock in write mode with a condvar.
|
/// Access the pre-downgrade rwlock in write mode with a condvar.
|
||||||
fn write_cond<U>(blk: fn(c: &Condvar) -> U) -> U {
|
fn write_cond<U>(&self, blk: fn(c: &Condvar) -> U) -> U {
|
||||||
blk(&Condvar { sem: &self.lock.access_lock })
|
blk(&Condvar { sem: &self.lock.access_lock })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub impl &RWlockReadMode {
|
|
||||||
|
pub impl RWlockReadMode/&self {
|
||||||
/// Access the post-downgrade rwlock in read mode.
|
/// Access the post-downgrade rwlock in read mode.
|
||||||
fn read<U>(blk: fn() -> U) -> U { blk() }
|
fn read<U>(&self, blk: fn() -> U) -> U { blk() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: TotalOrd, V> BaseIter<(&K, &V)> 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
|
/// 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)
|
each(&self.root, f)
|
||||||
|
@ -102,7 +102,10 @@ impl<K: TotalOrd, V> BaseIter<(&K, &V)> for TreeMap<K, V> {
|
||||||
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: TotalOrd, V> ReverseIter<(&K, &V)> for TreeMap<K, V> {
|
impl<'self, K: TotalOrd, V>
|
||||||
|
ReverseIter<(&'self K, &'self V)>
|
||||||
|
for TreeMap<K, V>
|
||||||
|
{
|
||||||
/// Visit all key-value pairs in reverse order
|
/// 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);
|
each_reverse(&self.root, f);
|
||||||
|
@ -195,8 +198,8 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> {
|
||||||
|
|
||||||
/// Lazy forward iterator over a map
|
/// Lazy forward iterator over a map
|
||||||
pub struct TreeMapIterator<K, V> {
|
pub struct TreeMapIterator<K, V> {
|
||||||
priv stack: ~[&~TreeNode<K, V>],
|
priv stack: ~[&self/~TreeNode<K, V>],
|
||||||
priv node: &Option<~TreeNode<K, V>>
|
priv node: &self/Option<~TreeNode<K, V>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Advance the iterator to the next node (in order) and return a
|
/// Advance the iterator to the next node (in order) and return a
|
||||||
|
@ -494,7 +497,7 @@ pub impl <T: TotalOrd> TreeSet<T> {
|
||||||
|
|
||||||
/// Lazy forward iterator over a set
|
/// Lazy forward iterator over a set
|
||||||
pub struct TreeSetIterator<T> {
|
pub struct TreeSetIterator<T> {
|
||||||
priv iter: TreeMapIterator<T, ()>
|
priv iter: TreeMapIterator/&self<T, ()>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Advance the iterator to the next node (in order). If this iterator is
|
/// Advance the iterator to the next node (in order). If this iterator is
|
||||||
|
|
|
@ -168,7 +168,8 @@ struct Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl Database {
|
pub impl Database {
|
||||||
fn prepare(&mut self, fn_name: &str,
|
fn prepare(&mut self,
|
||||||
|
fn_name: &str,
|
||||||
declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)>
|
declared_inputs: &WorkMap) -> Option<(WorkMap, WorkMap, ~str)>
|
||||||
{
|
{
|
||||||
let k = json_encode(&(fn_name, declared_inputs));
|
let k = json_encode(&(fn_name, declared_inputs));
|
||||||
|
@ -233,7 +234,9 @@ fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
|
fn json_decode<T:Decodable<json::Decoder/&static>>( // FIXME(#5121)
|
||||||
|
s: &str) -> T
|
||||||
|
{
|
||||||
do io::with_str_reader(s) |rdr| {
|
do io::with_str_reader(s) |rdr| {
|
||||||
let j = result::unwrap(json::from_reader(rdr));
|
let j = result::unwrap(json::from_reader(rdr));
|
||||||
Decodable::decode(&json::Decoder(j))
|
Decodable::decode(&json::Decoder(j))
|
||||||
|
@ -261,7 +264,9 @@ pub impl Context {
|
||||||
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
|
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prep<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
|
fn prep<T:Owned +
|
||||||
|
Encodable<json::Encoder> +
|
||||||
|
Decodable<json::Decoder/&static>>( // FIXME(#5121)
|
||||||
@self,
|
@self,
|
||||||
fn_name:&str,
|
fn_name:&str,
|
||||||
blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> {
|
blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> {
|
||||||
|
@ -277,7 +282,9 @@ trait TPrep {
|
||||||
fn declare_input(&self, kind:&str, name:&str, val:&str);
|
fn declare_input(&self, kind:&str, name:&str, val:&str);
|
||||||
fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool;
|
fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool;
|
||||||
fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool;
|
fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool;
|
||||||
fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
|
fn exec<T:Owned +
|
||||||
|
Encodable<json::Encoder> +
|
||||||
|
Decodable<json::Decoder/&static>>( // FIXME(#5121)
|
||||||
&self, blk: ~fn(&Exec) -> T) -> Work<T>;
|
&self, blk: ~fn(&Exec) -> T) -> Work<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +323,9 @@ impl TPrep for @Mut<Prep> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
|
fn exec<T:Owned +
|
||||||
|
Encodable<json::Encoder> +
|
||||||
|
Decodable<json::Decoder/&static>>( // FIXME(#5121)
|
||||||
&self, blk: ~fn(&Exec) -> T) -> Work<T> {
|
&self, blk: ~fn(&Exec) -> T) -> Work<T> {
|
||||||
let mut bo = Some(blk);
|
let mut bo = Some(blk);
|
||||||
|
|
||||||
|
@ -355,14 +364,18 @@ impl TPrep for @Mut<Prep> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T:Owned+Encodable<json::Encoder>+Decodable<json::Decoder>> Work<T> {
|
pub impl<T:Owned +
|
||||||
|
Encodable<json::Encoder> +
|
||||||
|
Decodable<json::Decoder/&static>> Work<T> { // FIXME(#5121)
|
||||||
static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
|
static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
|
||||||
Work { prep: p, res: Some(e) }
|
Work { prep: p, res: Some(e) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME (#3724): movable self. This should be in impl Work.
|
// FIXME (#3724): movable self. This should be in impl Work.
|
||||||
fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
|
fn unwrap<T:Owned +
|
||||||
|
Encodable<json::Encoder> +
|
||||||
|
Decodable<json::Decoder/&static>>( // FIXME(#5121)
|
||||||
w: Work<T>) -> T {
|
w: Work<T>) -> T {
|
||||||
let mut ww = w;
|
let mut ww = w;
|
||||||
let mut s = None;
|
let mut s = None;
|
||||||
|
|
|
@ -46,18 +46,16 @@ pub impl Junction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExpandDerivingStructDefFn = &fn(ext_ctxt,
|
type ExpandDerivingStructDefFn = &self/fn(ext_ctxt,
|
||||||
span,
|
span,
|
||||||
x: &struct_def,
|
x: &struct_def,
|
||||||
ident,
|
ident,
|
||||||
y: &Generics)
|
y: &Generics) -> @item;
|
||||||
-> @item;
|
type ExpandDerivingEnumDefFn = &self/fn(ext_ctxt,
|
||||||
type ExpandDerivingEnumDefFn = &fn(ext_ctxt,
|
|
||||||
span,
|
span,
|
||||||
x: &enum_def,
|
x: &enum_def,
|
||||||
ident,
|
ident,
|
||||||
y: &Generics)
|
y: &Generics) -> @item;
|
||||||
-> @item;
|
|
||||||
|
|
||||||
pub fn expand_deriving_eq(cx: ext_ctxt,
|
pub fn expand_deriving_eq(cx: ext_ctxt,
|
||||||
span: span,
|
span: span,
|
||||||
|
|
|
@ -442,7 +442,8 @@ pub fn core_macros() -> ~str {
|
||||||
mod $c {
|
mod $c {
|
||||||
fn key(_x: @::core::condition::Handler<$in,$out>) { }
|
fn key(_x: @::core::condition::Handler<$in,$out>) { }
|
||||||
|
|
||||||
pub const cond : ::core::condition::Condition<$in,$out> =
|
pub const cond :
|
||||||
|
::core::condition::Condition/&static<$in,$out> =
|
||||||
::core::condition::Condition {
|
::core::condition::Condition {
|
||||||
name: stringify!($c),
|
name: stringify!($c),
|
||||||
key: key
|
key: key
|
||||||
|
|
|
@ -35,8 +35,8 @@ use core::u64;
|
||||||
use core::vec;
|
use core::vec;
|
||||||
|
|
||||||
// The @ps is stored here to prevent recursive type.
|
// The @ps is stored here to prevent recursive type.
|
||||||
pub enum ann_node/& {
|
pub enum ann_node<'self> {
|
||||||
node_block(@ps, &ast::blk),
|
node_block(@ps, &'self ast::blk),
|
||||||
node_item(@ps, @ast::item),
|
node_item(@ps, @ast::item),
|
||||||
node_expr(@ps, @ast::expr),
|
node_expr(@ps, @ast::expr),
|
||||||
node_pat(@ps, @ast::pat),
|
node_pat(@ps, @ast::pat),
|
||||||
|
|
|
@ -28,14 +28,14 @@ use opt_vec::OptVec;
|
||||||
// hold functions that take visitors. A vt enum is used to break the cycle.
|
// hold functions that take visitors. A vt enum is used to break the cycle.
|
||||||
pub enum vt<E> { mk_vt(visitor<E>), }
|
pub enum vt<E> { mk_vt(visitor<E>), }
|
||||||
|
|
||||||
pub enum fn_kind {
|
pub enum fn_kind<'self> {
|
||||||
fk_item_fn(ident, &Generics, purity), // fn foo()
|
fk_item_fn(ident, &'self Generics, purity), // fn foo()
|
||||||
fk_method(ident, &Generics, &method), // fn foo(&self)
|
fk_method(ident, &'self Generics, &'self method), // fn foo(&self)
|
||||||
fk_anon(ast::Sigil), // fn@(x, y) { ... }
|
fk_anon(ast::Sigil), // fn@(x, y) { ... }
|
||||||
fk_fn_block, // |x, y| ...
|
fk_fn_block, // |x, y| ...
|
||||||
fk_dtor( // class destructor
|
fk_dtor( // class destructor
|
||||||
&Generics,
|
&'self Generics,
|
||||||
&[attribute],
|
&'self [attribute],
|
||||||
node_id /* self id */,
|
node_id /* self id */,
|
||||||
def_id /* parent class id */
|
def_id /* parent class id */
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,10 @@ extern mod std;
|
||||||
use std::arena;
|
use std::arena;
|
||||||
use methods = std::arena::Arena;
|
use methods = std::arena::Arena;
|
||||||
|
|
||||||
enum tree/& { nil, node(&tree, &tree, int), }
|
enum tree {
|
||||||
|
nil,
|
||||||
|
node(&'self tree<'self>, &'self tree<'self>, int),
|
||||||
|
}
|
||||||
|
|
||||||
fn item_check(t: &tree) -> int {
|
fn item_check(t: &tree) -> int {
|
||||||
match *t {
|
match *t {
|
||||||
|
@ -23,9 +26,9 @@ fn item_check(t: &tree) -> int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bottom_up_tree(arena: &r/arena::Arena,
|
fn bottom_up_tree(arena: &'r arena::Arena,
|
||||||
item: int,
|
item: int,
|
||||||
depth: int) -> &r/tree {
|
depth: int) -> &'r tree<'r> {
|
||||||
if depth > 0 {
|
if depth > 0 {
|
||||||
return arena.alloc(
|
return arena.alloc(
|
||||||
|| node(bottom_up_tree(arena, 2 * item - 1, depth - 1),
|
|| node(bottom_up_tree(arena, 2 * item - 1, depth - 1),
|
||||||
|
|
|
@ -18,7 +18,7 @@ trait Stuff {
|
||||||
fn printme();
|
fn printme();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stuff for &mut Foo {
|
impl Stuff for &'self mut Foo {
|
||||||
fn printme() {
|
fn printme() {
|
||||||
io::println(fmt!("%d", self.x));
|
io::println(fmt!("%d", self.x));
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,6 @@ trait MyIter {
|
||||||
pure fn test_mut(&mut self);
|
pure fn test_mut(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyIter for &[int] {
|
impl MyIter for &'self [int] {
|
||||||
pure fn test_mut(&mut self) { }
|
pure fn test_mut(&mut self) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
enum X = Either<(uint,uint),extern fn()>;
|
enum X = Either<(uint,uint),extern fn()>;
|
||||||
pub impl &X {
|
pub impl &'self X {
|
||||||
fn with(blk: fn(x: &Either<(uint,uint),extern fn()>)) {
|
fn with(blk: fn(x: &Either<(uint,uint),extern fn()>)) {
|
||||||
blk(&**self)
|
blk(&**self)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct defer {
|
struct defer {
|
||||||
x: &[&str],
|
x: &'self [&'self str],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for defer {
|
impl Drop for defer<'self> {
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
error!("%?", self.x);
|
error!("%?", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn defer(x: &r/[&r/str]) -> defer/&r {
|
fn defer(x: &'r [&'r str]) -> defer<'r> {
|
||||||
defer {
|
defer {
|
||||||
x: x
|
x: x
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct boxedFn { theFn: ~fn() -> uint }
|
struct boxedFn { theFn: &'self fn() -> uint }
|
||||||
|
|
||||||
fn createClosure (closedUint: uint) -> boxedFn {
|
fn createClosure (closedUint: uint) -> boxedFn {
|
||||||
let result: @fn() -> uint = || closedUint;
|
boxedFn {theFn: @fn () -> uint { closedUint }} //~ ERROR illegal borrow
|
||||||
boxedFn { theFn: result } //~ ERROR mismatched types
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main () {
|
fn main () {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct thing<Q> {
|
struct thing<Q> {
|
||||||
x: &Q
|
x: &'self Q
|
||||||
}
|
}
|
||||||
|
|
||||||
fn thing<Q>(x: &Q) -> thing<Q> {
|
fn thing<Q>(x: &Q) -> thing<Q> {
|
||||||
|
|
|
@ -10,17 +10,17 @@
|
||||||
|
|
||||||
#[legacy_mode]
|
#[legacy_mode]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
s: &str,
|
s: &'self str,
|
||||||
u: ~()
|
u: ~()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl Foo {
|
pub impl Foo<'self> {
|
||||||
fn get_s(&self) -> &self/str {
|
fn get_s(&self) -> &self/str {
|
||||||
self.s
|
self.s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bar(s: &str, f: fn(Option<Foo>)) {
|
fn bar(s: &str, f: &fn(Option<Foo>)) {
|
||||||
f(Some(Foo {s: s, u: ~()}));
|
f(Some(Foo {s: s, u: ~()}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
fn foopy() {}
|
fn foopy() {}
|
||||||
|
|
||||||
const f: fn() = foopy; //~ ERROR mismatched types: expected `&static/fn()`
|
const f: &'static fn() = foopy; //~ ERROR mismatched types: expected `&static/fn()`
|
||||||
|
|
||||||
fn main () {
|
fn main () {
|
||||||
f();
|
f();
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
// be parameterized by a region due to the &self/int constraint.
|
// be parameterized by a region due to the &self/int constraint.
|
||||||
|
|
||||||
trait foo {
|
trait foo {
|
||||||
fn foo(i: &self/int) -> int;
|
fn foo(i: &'self int) -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Copy> foo for T {
|
impl<T:Copy> foo<'self> for T {
|
||||||
fn foo(i: &self/int) -> int {*i}
|
fn foo(i: &'self int) -> int {*i}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_foo<T:Copy>(t: T) {
|
fn to_foo<T:Copy>(t: T) {
|
||||||
|
|
|
@ -12,25 +12,25 @@
|
||||||
// nominal types (but not on other types) and that they are type
|
// nominal types (but not on other types) and that they are type
|
||||||
// checked.
|
// checked.
|
||||||
|
|
||||||
enum an_enum = ∫
|
enum an_enum = &'self int;
|
||||||
trait a_trait {
|
trait a_trait {
|
||||||
fn foo() -> &'self int;
|
fn foo() -> &'self int;
|
||||||
}
|
}
|
||||||
struct a_class { x:&'self int }
|
struct a_class { x:&'self int }
|
||||||
|
|
||||||
fn a_fn1(e: an_enum/&a) -> an_enum/&b {
|
fn a_fn1(e: an_enum<'a>) -> an_enum<'b> {
|
||||||
return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
|
return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn a_fn2(e: a_trait/&a) -> a_trait/&b {
|
fn a_fn2(e: a_trait<'a>) -> a_trait<'b> {
|
||||||
return e; //~ ERROR mismatched types: expected `@a_trait/&b` but found `@a_trait/&a`
|
return e; //~ ERROR mismatched types: expected `@a_trait/&b` but found `@a_trait/&a`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn a_fn3(e: a_class/&a) -> a_class/&b {
|
fn a_fn3(e: a_class<'a>) -> a_class<'b> {
|
||||||
return e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
|
return e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn a_fn4(e: int/&a) -> int/&b {
|
fn a_fn4(e: int<'a>) -> int<'b> {
|
||||||
//~^ ERROR region parameters are not allowed on this type
|
//~^ ERROR region parameters are not allowed on this type
|
||||||
//~^^ ERROR region parameters are not allowed on this type
|
//~^^ ERROR region parameters are not allowed on this type
|
||||||
return e;
|
return e;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
enum ast {
|
enum ast {
|
||||||
num(uint),
|
num(uint),
|
||||||
add(&ast, &ast)
|
add(&'self ast<'self>, &'self ast<'self>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build() {
|
fn build() {
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
enum ast {
|
enum ast {
|
||||||
num(uint),
|
num(uint),
|
||||||
add(&ast, &ast)
|
add(&'self ast<'self>, &'self ast<'self>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_add_bad1(x: &a/ast, y: &b/ast) -> ast/&a {
|
fn mk_add_bad1(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
|
||||||
add(x, y) //~ ERROR cannot infer an appropriate lifetime
|
add(x, y) //~ ERROR cannot infer an appropriate lifetime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
enum ast {
|
enum ast<'self> {
|
||||||
num(uint),
|
num(uint),
|
||||||
add(&ast, &ast)
|
add(&'self ast<'self>, &'self ast<'self>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_add_bad2(x: &a/ast, y: &a/ast, z: &ast) -> ast {
|
fn mk_add_bad2(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast {
|
||||||
add(x, y)
|
add(x, y)
|
||||||
//~^ ERROR cannot infer an appropriate lifetime
|
//~^ ERROR cannot infer an appropriate lifetime
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ trait deref {
|
||||||
fn get() -> int;
|
fn get() -> int;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl deref for &int {
|
impl deref for &'self int {
|
||||||
fn get() -> int {
|
fn get() -> int {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,19 +11,19 @@
|
||||||
mod argparse {
|
mod argparse {
|
||||||
extern mod std;
|
extern mod std;
|
||||||
|
|
||||||
pub struct Flag {
|
pub struct Flag<'self> {
|
||||||
name: &str,
|
name: &'self str,
|
||||||
desc: &str,
|
desc: &'self str,
|
||||||
max_count: uint,
|
max_count: uint,
|
||||||
value: uint
|
value: uint
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flag(name: &r/str, desc: &r/str) -> Flag/&r {
|
pub fn flag(name: &'r str, desc: &'r str) -> Flag<'r> {
|
||||||
Flag { name: name, desc: desc, max_count: 1, value: 0 }
|
Flag { name: name, desc: desc, max_count: 1, value: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl Flag {
|
pub impl Flag<'self> {
|
||||||
fn set_desc(self, s: &str) -> Flag {
|
fn set_desc(self, s: &str) -> Flag<'self> {
|
||||||
Flag { //~ ERROR cannot infer an appropriate lifetime
|
Flag { //~ ERROR cannot infer an appropriate lifetime
|
||||||
name: self.name,
|
name: self.name,
|
||||||
desc: s,
|
desc: s,
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
const c_x: &blk/int = &22; //~ ERROR only the static region is allowed here
|
const c_x: &'blk int = &22; //~ ERROR only the static region is allowed here
|
||||||
const c_y: &static/int = &22;
|
const c_y: &int = &22; //~ ERROR only the static region is allowed here
|
||||||
|
const c_z: &'static int = &22;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,28 +8,16 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct yes0 {
|
struct yes0<'self> {
|
||||||
x: &uint,
|
x: &uint, //~ ERROR anonymous region types are not permitted here
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for yes0 {
|
struct yes1<'self> {
|
||||||
fn finalize(&self) {}
|
x: &'self uint,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct yes1 {
|
struct yes2<'self> {
|
||||||
x: &self/uint,
|
x: &'foo uint, //~ ERROR named regions other than `self` are not allowed as part of a type declaration
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for yes1 {
|
|
||||||
fn finalize(&self) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct yes2 {
|
|
||||||
x: &foo/uint, //~ ERROR named regions other than `self` are not allowed as part of a type declaration
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for yes2 {
|
|
||||||
fn finalize(&self) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
|
@ -9,15 +9,15 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
type item_ty_yes0 = {
|
type item_ty_yes0 = {
|
||||||
x: &uint
|
x: &uint //~ ERROR anonymous region types are not permitted here
|
||||||
};
|
};
|
||||||
|
|
||||||
type item_ty_yes1 = {
|
type item_ty_yes1 = {
|
||||||
x: &self/uint
|
x: &'self uint
|
||||||
};
|
};
|
||||||
|
|
||||||
type item_ty_yes2 = {
|
type item_ty_yes2 = {
|
||||||
x: &foo/uint //~ ERROR named regions other than `self` are not allowed as part of a type declaration
|
x: &'foo uint //~ ERROR named regions other than `self` are not allowed as part of a type declaration
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -8,25 +8,20 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct param1 {
|
struct parameterized1 {
|
||||||
g: &fn()
|
g: &'self fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct param2 {
|
struct not_parameterized1 {
|
||||||
g: fn()
|
|
||||||
}
|
|
||||||
|
|
||||||
struct not_param1 {
|
|
||||||
g: @fn()
|
g: @fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct not_param2 {
|
struct not_parameterized2 {
|
||||||
g: @fn()
|
g: @fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take1(p: param1) -> param1 { p } //~ ERROR mismatched types
|
fn take1(p: parameterized1) -> parameterized1 { p } //~ ERROR mismatched types
|
||||||
fn take2(p: param2) -> param2 { p } //~ ERROR mismatched types
|
fn take3(p: not_parameterized1) -> not_parameterized1 { p }
|
||||||
fn take3(p: not_param1) -> not_param1 { p }
|
fn take4(p: not_parameterized2) -> not_parameterized2 { p }
|
||||||
fn take4(p: not_param2) -> not_param2 { p }
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -9,18 +9,18 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct contravariant {
|
struct contravariant {
|
||||||
f: &int
|
f: &'self int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_same_lifetime(bi: contravariant/&r) {
|
fn to_same_lifetime(bi: contravariant<'r>) {
|
||||||
let bj: contravariant/&r = bi;
|
let bj: contravariant<'r> = bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_shorter_lifetime(bi: contravariant/&r) {
|
fn to_shorter_lifetime(bi: contravariant<'r>) {
|
||||||
let bj: contravariant/&blk = bi;
|
let bj: contravariant<'blk> = bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_longer_lifetime(bi: contravariant/&r) -> contravariant/&static {
|
fn to_longer_lifetime(bi: contravariant<'r>) -> contravariant/&static {
|
||||||
bi //~ ERROR mismatched types
|
bi //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,18 +13,18 @@
|
||||||
// You cannot convert between regions.
|
// You cannot convert between regions.
|
||||||
|
|
||||||
struct invariant {
|
struct invariant {
|
||||||
f: fn(x: &self/int) -> &self/int
|
f: &'self fn(x: &'self int) -> &'self int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_same_lifetime(bi: invariant/&r) {
|
fn to_same_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&r = bi;
|
let bj: invariant<'r> = bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&blk = bi; //~ ERROR mismatched types
|
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
fn to_longer_lifetime(bi: invariant<'r>) -> invariant/&static {
|
||||||
bi //~ ERROR mismatched types
|
bi //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,18 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct invariant {
|
struct invariant {
|
||||||
f: @mut &int
|
f: @mut &'self int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_same_lifetime(bi: invariant/&r) {
|
fn to_same_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&r = bi;
|
let bj: invariant<'r> = bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&blk = bi; //~ ERROR mismatched types
|
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
|
||||||
bi //~ ERROR mismatched types
|
bi //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct invariant {
|
struct invariant<'self> {
|
||||||
f: @mut [&int]
|
f: @mut [&'self int]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_same_lifetime(bi: invariant/&r) {
|
fn to_same_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&r = bi;
|
let bj: invariant<'r> = bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&blk = bi; //~ ERROR mismatched types
|
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
|
||||||
bi //~ ERROR mismatched types
|
bi //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,18 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct invariant {
|
struct invariant {
|
||||||
f: &int
|
f: @mut &'self int
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_same_lifetime(bi: invariant/&r) {
|
fn to_same_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&r = bi;
|
let bj: invariant<'r> = bi;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||||
let bj: invariant/&blk = bi;
|
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
fn to_longer_lifetime(bi: invariant<'r>) -> invariant/&static {
|
||||||
bi //~ ERROR mismatched types
|
bi //~ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct direct {
|
struct direct<'self> {
|
||||||
f: &int
|
f: &'self int
|
||||||
}
|
}
|
||||||
|
|
||||||
struct indirect1 {
|
struct indirect1 {
|
||||||
|
@ -21,7 +21,7 @@ struct indirect2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct indirect3 {
|
struct indirect3 {
|
||||||
g: @fn(direct/&self)
|
g: @fn(direct<'self>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types
|
fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types
|
||||||
|
|
|
@ -11,17 +11,17 @@
|
||||||
// Check that we correctly infer that b and c must be region
|
// Check that we correctly infer that b and c must be region
|
||||||
// parameterized because they reference a which requires a region.
|
// parameterized because they reference a which requires a region.
|
||||||
|
|
||||||
type a = ∫
|
type a<'self> = &'self int;
|
||||||
type b = @a;
|
type b<'self> = @a<'self>;
|
||||||
type c = {f: @b};
|
type c<'self> = {f: @b<'self>};
|
||||||
|
|
||||||
trait set_f {
|
trait set_f<'self> {
|
||||||
fn set_f_ok(b: @b/&self);
|
fn set_f_ok(b: @b<'self>);
|
||||||
fn set_f_bad(b: @b);
|
fn set_f_bad(b: @b);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl set_f for c {
|
impl<'self> set_f<'self> for c<'self> {
|
||||||
fn set_f_ok(b: @b/&self) {
|
fn set_f_ok(b: @b<'self>) {
|
||||||
self.f = b;
|
self.f = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,22 +11,22 @@
|
||||||
// Here: foo is parameterized because it contains a method that
|
// Here: foo is parameterized because it contains a method that
|
||||||
// refers to self.
|
// refers to self.
|
||||||
|
|
||||||
trait foo {
|
trait foo<'self> {
|
||||||
fn self_int() -> &self/int;
|
fn self_int() -> &'self int;
|
||||||
|
|
||||||
fn any_int() -> ∫
|
fn any_int() -> ∫
|
||||||
}
|
}
|
||||||
|
|
||||||
struct with_foo {
|
struct with_foo<'self> {
|
||||||
f: foo
|
f: foo<'self>
|
||||||
}
|
}
|
||||||
|
|
||||||
trait set_foo_foo {
|
trait set_foo_foo {
|
||||||
fn set_foo(&mut self, f: foo);
|
fn set_foo(&mut self, f: @foo);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl set_foo_foo for with_foo {
|
impl<'self> set_foo_foo for with_foo<'self> {
|
||||||
fn set_foo(&mut self, f: foo) {
|
fn set_foo(&mut self, f: @foo) {
|
||||||
self.f = f; //~ ERROR mismatched types: expected `@foo/&self` but found `@foo/&`
|
self.f = f; //~ ERROR mismatched types: expected `@foo/&self` but found `@foo/&`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
struct closure_box {
|
struct closure_box<'self> {
|
||||||
cl: &fn()
|
cl: &'self fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn box_it(x: &r/fn()) -> closure_box/&r {
|
fn box_it(x: &'r fn()) -> closure_box<'r> {
|
||||||
closure_box {cl: x}
|
closure_box {cl: x}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@ trait get_ctxt {
|
||||||
fn get_ctxt() -> &ctxt;
|
fn get_ctxt() -> &ctxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct has_ctxt { c: &ctxt }
|
struct has_ctxt { c: &'self ctxt }
|
||||||
|
|
||||||
impl get_ctxt for has_ctxt {
|
impl get_ctxt for has_ctxt<'self> {
|
||||||
|
|
||||||
// Here an error occurs because we used `&self` but
|
// Here an error occurs because we used `&self` but
|
||||||
// the definition used `&`:
|
// the definition used `&`:
|
||||||
fn get_ctxt() -> &self/ctxt { //~ ERROR method `get_ctxt` has an incompatible type
|
fn get_ctxt() -> &'self ctxt { //~ ERROR method `get_ctxt` has an incompatible type
|
||||||
self.c
|
self.c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
|
|
||||||
struct ctxt { v: uint }
|
struct ctxt { v: uint }
|
||||||
|
|
||||||
trait get_ctxt {
|
trait get_ctxt<'self> {
|
||||||
fn get_ctxt() -> &self/ctxt;
|
fn get_ctxt() -> &'self ctxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct has_ctxt { c: &ctxt }
|
struct has_ctxt<'self> { c: &'self ctxt }
|
||||||
|
|
||||||
impl get_ctxt for has_ctxt {
|
impl<'self> get_ctxt<'self> for has_ctxt<'self> {
|
||||||
fn get_ctxt() -> &self/ctxt { self.c }
|
fn get_ctxt() -> &self/ctxt { self.c }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ trait iterable<A> {
|
||||||
fn iterate(blk: fn(x: &A) -> bool);
|
fn iterate(blk: fn(x: &A) -> bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A> iterable<A> for &[A] {
|
impl<A> iterable<A> for &self/[A] {
|
||||||
fn iterate(f: fn(x: &A) -> bool) {
|
fn iterate(f: fn(x: &A) -> bool) {
|
||||||
for vec::each(self) |e| {
|
for vec::each(self) |e| {
|
||||||
if !f(e) { break; }
|
if !f(e) { break; }
|
||||||
|
|
|
@ -16,12 +16,12 @@ trait MyIter {
|
||||||
pure fn test_const(&const self);
|
pure fn test_const(&const self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyIter for &[int] {
|
impl MyIter for &'self [int] {
|
||||||
pure fn test_imm(&self) { assert self[0] == 1 }
|
pure fn test_imm(&self) { assert self[0] == 1 }
|
||||||
pure fn test_const(&const self) { assert self[0] == 1 }
|
pure fn test_const(&const self) { assert self[0] == 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyIter for &str {
|
impl MyIter for &'self str {
|
||||||
pure fn test_imm(&self) { assert *self == "test" }
|
pure fn test_imm(&self) { assert *self == "test" }
|
||||||
pure fn test_const(&const self) { assert *self == "test" }
|
pure fn test_const(&const self) { assert *self == "test" }
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ trait Stuff {
|
||||||
fn printme();
|
fn printme();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stuff for &Foo {
|
impl Stuff for &self/Foo {
|
||||||
fn printme() {
|
fn printme() {
|
||||||
io::println(fmt!("%d", self.x));
|
io::println(fmt!("%d", self.x));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ trait Foo {
|
||||||
fn foo(self);
|
fn foo(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Foo for &[int] {
|
impl Foo for &'self [int] {
|
||||||
fn foo(self) {}
|
fn foo(self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ pub impl<T> cat<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> BaseIter<(int, &T)> for cat<T> {
|
impl<T> BaseIter<(int, &'self T)> for cat<T> {
|
||||||
pure fn each(&self, f: fn(&(int, &self/T)) -> bool) {
|
pure fn each(&self, f: fn(&(int, &'self T)) -> bool) {
|
||||||
let mut n = int::abs(self.meows);
|
let mut n = int::abs(self.meows);
|
||||||
while n > 0 {
|
while n > 0 {
|
||||||
if !f(&(n, &self.name)) { break; }
|
if !f(&(n, &self.name)) { break; }
|
||||||
|
@ -86,7 +86,7 @@ impl<T> Map<int, T> for cat<T> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn find(&self, k: &int) -> Option<&self/T> {
|
pure fn find(&self, k: &int) -> Option<&'self T> {
|
||||||
if *k <= self.meows {
|
if *k <= self.meows {
|
||||||
Some(&self.name)
|
Some(&self.name)
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,7 +104,7 @@ impl<T> Map<int, T> for cat<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub impl<T> cat<T> {
|
pub impl<T> cat<T> {
|
||||||
pure fn get(&self, k: &int) -> &self/T {
|
pure fn get(&self, k: &int) -> &'self T {
|
||||||
match self.find(k) {
|
match self.find(k) {
|
||||||
Some(v) => { v }
|
Some(v) => { v }
|
||||||
None => { fail!(~"epic fail"); }
|
None => { fail!(~"epic fail"); }
|
||||||
|
|
|
@ -2,7 +2,7 @@ trait Reverser {
|
||||||
fn reverse(&self);
|
fn reverse(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reverser for &mut [uint] {
|
impl Reverser for &'self mut [uint] {
|
||||||
fn reverse(&self) {
|
fn reverse(&self) {
|
||||||
vec::reverse(*self);
|
vec::reverse(*self);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
enum E { V1(int), V0 }
|
enum E { V1(int), V0 }
|
||||||
const C: &[E] = &[V0, V1(0xDEADBEE)];
|
const C: &'static [E] = &[V0, V1(0xDEADBEE)];
|
||||||
const C0: E = C[0];
|
const C0: E = C[0];
|
||||||
const C1: E = C[1];
|
const C1: E = C[1];
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
const x : [int * 4] = [1,2,3,4];
|
const x : [int * 4] = [1,2,3,4];
|
||||||
const p : int = x[2];
|
const p : int = x[2];
|
||||||
const y : &[int] = &[1,2,3,4];
|
const y : &'static [int] = &[1,2,3,4];
|
||||||
const q : int = y[2];
|
const q : int = y[2];
|
||||||
|
|
||||||
struct S {a: int, b: int}
|
struct S {a: int, b: int}
|
||||||
|
|
|
@ -12,9 +12,9 @@ fn foo() -> int {
|
||||||
return 0xca7f000d;
|
return 0xca7f000d;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Bar { f: &fn() -> int }
|
struct Bar { f: &'self fn() -> int }
|
||||||
|
|
||||||
const b : Bar = Bar { f: foo };
|
const b : Bar/&static = Bar { f: foo };
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
assert (b.f)() == 0xca7f000d;
|
assert (b.f)() == 0xca7f000d;
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
struct Pair { a: int, b: &int }
|
struct Pair { a: int, b: &'self int }
|
||||||
|
|
||||||
const x: &int = &10;
|
const x: &'static int = &10;
|
||||||
|
|
||||||
const y: &Pair = &Pair {a: 15, b: x};
|
const y: &'static Pair<'static> = &Pair {a: 15, b: x};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
io::println(fmt!("x = %?", *x));
|
io::println(fmt!("x = %?", *x));
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl cmp::Eq for foo {
|
||||||
|
|
||||||
const x : foo = foo { a:1, b:2, c: 3 };
|
const x : foo = foo { a:1, b:2, c: 3 };
|
||||||
const y : foo = foo { b:2, c:3, a: 1 };
|
const y : foo = foo { b:2, c:3, a: 1 };
|
||||||
const z : &foo = &foo { a: 10, b: 22, c: 12 };
|
const z : &'static foo = &foo { a: 10, b: 22, c: 12 };
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
assert x.b == 2;
|
assert x.b == 2;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue