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
|
|
@ -12,7 +12,10 @@ extern mod std;
|
|||
use std::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 {
|
||||
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,
|
||||
depth: int) -> &r/tree {
|
||||
depth: int) -> &'r tree<'r> {
|
||||
if depth > 0 {
|
||||
return arena.alloc(
|
||||
|| node(bottom_up_tree(arena, 2 * item - 1, depth - 1),
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ trait Stuff {
|
|||
fn printme();
|
||||
}
|
||||
|
||||
impl Stuff for &mut Foo {
|
||||
impl Stuff for &'self mut Foo {
|
||||
fn printme() {
|
||||
io::println(fmt!("%d", self.x));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ trait MyIter {
|
|||
pure fn test_mut(&mut self);
|
||||
}
|
||||
|
||||
impl MyIter for &[int] {
|
||||
impl MyIter for &'self [int] {
|
||||
pure fn test_mut(&mut self) { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
enum X = Either<(uint,uint),extern fn()>;
|
||||
pub impl &X {
|
||||
pub impl &'self X {
|
||||
fn with(blk: fn(x: &Either<(uint,uint),extern fn()>)) {
|
||||
blk(&**self)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct defer {
|
||||
x: &[&str],
|
||||
x: &'self [&'self str],
|
||||
}
|
||||
|
||||
impl Drop for defer {
|
||||
impl Drop for defer<'self> {
|
||||
fn finalize(&self) {
|
||||
error!("%?", self.x);
|
||||
}
|
||||
}
|
||||
|
||||
fn defer(x: &r/[&r/str]) -> defer/&r {
|
||||
fn defer(x: &'r [&'r str]) -> defer<'r> {
|
||||
defer {
|
||||
x: x
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct boxedFn { theFn: ~fn() -> uint }
|
||||
struct boxedFn { theFn: &'self fn() -> uint }
|
||||
|
||||
fn createClosure (closedUint: uint) -> boxedFn {
|
||||
let result: @fn() -> uint = || closedUint;
|
||||
boxedFn { theFn: result } //~ ERROR mismatched types
|
||||
boxedFn {theFn: @fn () -> uint { closedUint }} //~ ERROR illegal borrow
|
||||
}
|
||||
|
||||
fn main () {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct thing<Q> {
|
||||
x: &Q
|
||||
x: &'self Q
|
||||
}
|
||||
|
||||
fn thing<Q>(x: &Q) -> thing<Q> {
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@
|
|||
|
||||
#[legacy_mode]
|
||||
struct Foo {
|
||||
s: &str,
|
||||
s: &'self str,
|
||||
u: ~()
|
||||
}
|
||||
|
||||
pub impl Foo {
|
||||
pub impl Foo<'self> {
|
||||
fn get_s(&self) -> &self/str {
|
||||
self.s
|
||||
}
|
||||
}
|
||||
|
||||
fn bar(s: &str, f: fn(Option<Foo>)) {
|
||||
fn bar(s: &str, f: &fn(Option<Foo>)) {
|
||||
f(Some(Foo {s: s, u: ~()}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
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 () {
|
||||
f();
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@
|
|||
// be parameterized by a region due to the &self/int constraint.
|
||||
|
||||
trait foo {
|
||||
fn foo(i: &self/int) -> int;
|
||||
fn foo(i: &'self int) -> int;
|
||||
}
|
||||
|
||||
impl<T:Copy> foo for T {
|
||||
fn foo(i: &self/int) -> int {*i}
|
||||
impl<T:Copy> foo<'self> for T {
|
||||
fn foo(i: &'self int) -> int {*i}
|
||||
}
|
||||
|
||||
fn to_foo<T:Copy>(t: T) {
|
||||
|
|
|
|||
|
|
@ -12,25 +12,25 @@
|
|||
// nominal types (but not on other types) and that they are type
|
||||
// checked.
|
||||
|
||||
enum an_enum = ∫
|
||||
enum an_enum = &'self int;
|
||||
trait a_trait {
|
||||
fn foo() -> &'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`
|
||||
}
|
||||
|
||||
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`
|
||||
}
|
||||
|
||||
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`
|
||||
}
|
||||
|
||||
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
|
||||
return e;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
enum ast {
|
||||
num(uint),
|
||||
add(&ast, &ast)
|
||||
add(&'self ast<'self>, &'self ast<'self>)
|
||||
}
|
||||
|
||||
fn build() {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
enum ast {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
enum ast {
|
||||
enum ast<'self> {
|
||||
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)
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait deref {
|
|||
fn get() -> int;
|
||||
}
|
||||
|
||||
impl deref for &int {
|
||||
impl deref for &'self int {
|
||||
fn get() -> int {
|
||||
*self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@
|
|||
mod argparse {
|
||||
extern mod std;
|
||||
|
||||
pub struct Flag {
|
||||
name: &str,
|
||||
desc: &str,
|
||||
pub struct Flag<'self> {
|
||||
name: &'self str,
|
||||
desc: &'self str,
|
||||
max_count: 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 }
|
||||
}
|
||||
|
||||
pub impl Flag {
|
||||
fn set_desc(self, s: &str) -> Flag {
|
||||
pub impl Flag<'self> {
|
||||
fn set_desc(self, s: &str) -> Flag<'self> {
|
||||
Flag { //~ ERROR cannot infer an appropriate lifetime
|
||||
name: self.name,
|
||||
desc: s,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const c_x: &blk/int = &22; //~ ERROR only the static region is allowed here
|
||||
const c_y: &static/int = &22;
|
||||
const c_x: &'blk int = &22; //~ ERROR only the static region is allowed here
|
||||
const c_y: &int = &22; //~ ERROR only the static region is allowed here
|
||||
const c_z: &'static int = &22;
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,28 +8,16 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct yes0 {
|
||||
x: &uint,
|
||||
struct yes0<'self> {
|
||||
x: &uint, //~ ERROR anonymous region types are not permitted here
|
||||
}
|
||||
|
||||
impl Drop for yes0 {
|
||||
fn finalize(&self) {}
|
||||
struct yes1<'self> {
|
||||
x: &'self uint,
|
||||
}
|
||||
|
||||
struct yes1 {
|
||||
x: &self/uint,
|
||||
}
|
||||
|
||||
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) {}
|
||||
struct yes2<'self> {
|
||||
x: &'foo uint, //~ ERROR named regions other than `self` are not allowed as part of a type declaration
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -9,15 +9,15 @@
|
|||
// except according to those terms.
|
||||
|
||||
type item_ty_yes0 = {
|
||||
x: &uint
|
||||
x: &uint //~ ERROR anonymous region types are not permitted here
|
||||
};
|
||||
|
||||
type item_ty_yes1 = {
|
||||
x: &self/uint
|
||||
x: &'self uint
|
||||
};
|
||||
|
||||
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() {}
|
||||
|
|
|
|||
|
|
@ -8,25 +8,20 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct param1 {
|
||||
g: &fn()
|
||||
struct parameterized1 {
|
||||
g: &'self fn()
|
||||
}
|
||||
|
||||
struct param2 {
|
||||
g: fn()
|
||||
}
|
||||
|
||||
struct not_param1 {
|
||||
struct not_parameterized1 {
|
||||
g: @fn()
|
||||
}
|
||||
|
||||
struct not_param2 {
|
||||
struct not_parameterized2 {
|
||||
g: @fn()
|
||||
}
|
||||
|
||||
fn take1(p: param1) -> param1 { p } //~ ERROR mismatched types
|
||||
fn take2(p: param2) -> param2 { p } //~ ERROR mismatched types
|
||||
fn take3(p: not_param1) -> not_param1 { p }
|
||||
fn take4(p: not_param2) -> not_param2 { p }
|
||||
fn take1(p: parameterized1) -> parameterized1 { p } //~ ERROR mismatched types
|
||||
fn take3(p: not_parameterized1) -> not_parameterized1 { p }
|
||||
fn take4(p: not_parameterized2) -> not_parameterized2 { p }
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct contravariant {
|
||||
f: &int
|
||||
f: &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: contravariant/&r) {
|
||||
let bj: contravariant/&r = bi;
|
||||
fn to_same_lifetime(bi: contravariant<'r>) {
|
||||
let bj: contravariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: contravariant/&r) {
|
||||
let bj: contravariant/&blk = bi;
|
||||
fn to_shorter_lifetime(bi: contravariant<'r>) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@
|
|||
// You cannot convert between regions.
|
||||
|
||||
struct invariant {
|
||||
f: fn(x: &self/int) -> &self/int
|
||||
f: &'self fn(x: &'self int) -> &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&r = bi;
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&blk = bi; //~ ERROR mismatched types
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct invariant {
|
||||
f: @mut &int
|
||||
f: @mut &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&r = bi;
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&blk = bi; //~ ERROR mismatched types
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct invariant {
|
||||
f: @mut [&int]
|
||||
struct invariant<'self> {
|
||||
f: @mut [&'self int]
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&r = bi;
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&blk = bi; //~ ERROR mismatched types
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct invariant {
|
||||
f: &int
|
||||
f: @mut &'self int
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&r = bi;
|
||||
fn to_same_lifetime(bi: invariant<'r>) {
|
||||
let bj: invariant<'r> = bi;
|
||||
}
|
||||
|
||||
fn to_shorter_lifetime(bi: invariant/&r) {
|
||||
let bj: invariant/&blk = bi;
|
||||
}
|
||||
fn to_shorter_lifetime(bi: invariant<'r>) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct direct {
|
||||
f: &int
|
||||
struct direct<'self> {
|
||||
f: &'self int
|
||||
}
|
||||
|
||||
struct indirect1 {
|
||||
|
|
@ -21,7 +21,7 @@ struct indirect2 {
|
|||
}
|
||||
|
||||
struct indirect3 {
|
||||
g: @fn(direct/&self)
|
||||
g: @fn(direct<'self>)
|
||||
}
|
||||
|
||||
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
|
||||
// parameterized because they reference a which requires a region.
|
||||
|
||||
type a = ∫
|
||||
type b = @a;
|
||||
type c = {f: @b};
|
||||
type a<'self> = &'self int;
|
||||
type b<'self> = @a<'self>;
|
||||
type c<'self> = {f: @b<'self>};
|
||||
|
||||
trait set_f {
|
||||
fn set_f_ok(b: @b/&self);
|
||||
trait set_f<'self> {
|
||||
fn set_f_ok(b: @b<'self>);
|
||||
fn set_f_bad(b: @b);
|
||||
}
|
||||
|
||||
impl set_f for c {
|
||||
fn set_f_ok(b: @b/&self) {
|
||||
impl<'self> set_f<'self> for c<'self> {
|
||||
fn set_f_ok(b: @b<'self>) {
|
||||
self.f = b;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,22 +11,22 @@
|
|||
// Here: foo is parameterized because it contains a method that
|
||||
// refers to self.
|
||||
|
||||
trait foo {
|
||||
fn self_int() -> &self/int;
|
||||
trait foo<'self> {
|
||||
fn self_int() -> &'self int;
|
||||
|
||||
fn any_int() -> ∫
|
||||
}
|
||||
|
||||
struct with_foo {
|
||||
f: foo
|
||||
struct with_foo<'self> {
|
||||
f: foo<'self>
|
||||
}
|
||||
|
||||
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 {
|
||||
fn set_foo(&mut self, f: foo) {
|
||||
impl<'self> set_foo_foo for with_foo<'self> {
|
||||
fn set_foo(&mut self, f: @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
|
||||
// except according to those terms.
|
||||
|
||||
struct closure_box {
|
||||
cl: &fn()
|
||||
struct closure_box<'self> {
|
||||
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}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ trait get_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
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
struct ctxt { v: uint }
|
||||
|
||||
trait get_ctxt {
|
||||
fn get_ctxt() -> &self/ctxt;
|
||||
trait get_ctxt<'self> {
|
||||
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 }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait iterable<A> {
|
|||
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) {
|
||||
for vec::each(self) |e| {
|
||||
if !f(e) { break; }
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ trait MyIter {
|
|||
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_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_const(&const self) { assert *self == "test" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait Stuff {
|
|||
fn printme();
|
||||
}
|
||||
|
||||
impl Stuff for &Foo {
|
||||
impl Stuff for &self/Foo {
|
||||
fn printme() {
|
||||
io::println(fmt!("%d", self.x));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ trait Foo {
|
|||
fn foo(self);
|
||||
}
|
||||
|
||||
impl Foo for &[int] {
|
||||
impl Foo for &'self [int] {
|
||||
fn foo(self) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ pub impl<T> cat<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> BaseIter<(int, &T)> for cat<T> {
|
||||
pure fn each(&self, f: fn(&(int, &self/T)) -> bool) {
|
||||
impl<T> BaseIter<(int, &'self T)> for cat<T> {
|
||||
pure fn each(&self, f: fn(&(int, &'self T)) -> bool) {
|
||||
let mut n = int::abs(self.meows);
|
||||
while n > 0 {
|
||||
if !f(&(n, &self.name)) { break; }
|
||||
|
|
@ -86,7 +86,7 @@ impl<T> Map<int, T> for cat<T> {
|
|||
true
|
||||
}
|
||||
|
||||
pure fn find(&self, k: &int) -> Option<&self/T> {
|
||||
pure fn find(&self, k: &int) -> Option<&'self T> {
|
||||
if *k <= self.meows {
|
||||
Some(&self.name)
|
||||
} else {
|
||||
|
|
@ -104,7 +104,7 @@ impl<T> Map<int, T> for 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) {
|
||||
Some(v) => { v }
|
||||
None => { fail!(~"epic fail"); }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ trait Reverser {
|
|||
fn reverse(&self);
|
||||
}
|
||||
|
||||
impl Reverser for &mut [uint] {
|
||||
impl Reverser for &'self mut [uint] {
|
||||
fn reverse(&self) {
|
||||
vec::reverse(*self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
enum E { V1(int), V0 }
|
||||
const C: &[E] = &[V0, V1(0xDEADBEE)];
|
||||
const C: &'static [E] = &[V0, V1(0xDEADBEE)];
|
||||
const C0: E = C[0];
|
||||
const C1: E = C[1];
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
const x : [int * 4] = [1,2,3,4];
|
||||
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];
|
||||
|
||||
struct S {a: int, b: int}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ fn foo() -> int {
|
|||
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() {
|
||||
assert (b.f)() == 0xca7f000d;
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
// 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() {
|
||||
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 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() {
|
||||
assert x.b == 2;
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@
|
|||
*/
|
||||
|
||||
fn f() { }
|
||||
const bare_fns: &[extern fn()] = &[f, f];
|
||||
// NOTE Why does this not type without the struct?
|
||||
struct S(&fn());
|
||||
const closures: &[S] = &[S(f), S(f)];
|
||||
const bare_fns: &'static [extern fn()] = &[f, f];
|
||||
struct S<'self>(&'self fn());
|
||||
const closures: &'static [S<'static>] = &[S(f), S(f)];
|
||||
|
||||
pub fn main() {
|
||||
for bare_fns.each |&bare_fn| { bare_fn() }
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
const x : [int * 4] = [1,2,3,4];
|
||||
const y : &[int] = &[1,2,3,4];
|
||||
const y : &'static [int] = &[1,2,3,4];
|
||||
|
||||
pub fn main() {
|
||||
io::println(fmt!("%?", x[1]));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
fn eat_tup(_r: ~@(int, @fn(Pair) -> int)) {}
|
||||
fn eat_rec(_r: @~Rec) {}
|
||||
|
||||
struct Rec { a: int, b: fn(Pair) -> int }
|
||||
struct Rec { a: int, b: &'self fn(Pair) -> int }
|
||||
struct Pair { x: int, y: int }
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct font {
|
||||
fontbuf: &self/~[u8],
|
||||
fontbuf: &'self ~[u8],
|
||||
}
|
||||
|
||||
pub impl font {
|
||||
pub impl font/&self {
|
||||
fn buf() -> &self/~[u8] {
|
||||
self.fontbuf
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@
|
|||
|
||||
// This test should behave exactly like issue-2735-3
|
||||
struct defer {
|
||||
b: &mut bool,
|
||||
b: &'self mut bool,
|
||||
}
|
||||
|
||||
impl Drop for defer {
|
||||
impl Drop for defer/&self {
|
||||
fn finalize(&self) {
|
||||
*(self.b) = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn defer(b: &r/mut bool) -> defer/&r {
|
||||
fn defer(b: &'r mut bool) -> defer/&r {
|
||||
defer {
|
||||
b: b
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@
|
|||
|
||||
// This test should behave exactly like issue-2735-2
|
||||
struct defer {
|
||||
b: &mut bool,
|
||||
b: &'self mut bool,
|
||||
}
|
||||
|
||||
impl Drop for defer {
|
||||
impl Drop for defer/&self {
|
||||
fn finalize(&self) {
|
||||
*(self.b) = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn defer(b: &r/mut bool) -> defer/&r {
|
||||
fn defer(b: &'r mut bool) -> defer/&r {
|
||||
defer {
|
||||
b: b
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct CMap {
|
||||
buf: &[u8],
|
||||
buf: &'self [u8],
|
||||
}
|
||||
|
||||
fn CMap(buf: &r/[u8]) -> CMap/&r {
|
||||
fn CMap(buf: &'r [u8]) -> CMap/&r {
|
||||
CMap {
|
||||
buf: buf
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct list<T> {
|
||||
element: &self/T,
|
||||
next: Option<@mut list<T>>
|
||||
element: &'self T,
|
||||
next: Option<@mut list<'self, T>>
|
||||
}
|
||||
|
||||
pub impl<T> list<T>{
|
||||
fn addEnd(&mut self, element: &self/T) {
|
||||
pub impl<'self, T> list<'self, T>{
|
||||
fn addEnd(&mut self, element: &'self T) {
|
||||
let newList = list {
|
||||
element: element,
|
||||
next: option::None
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ trait get {
|
|||
}
|
||||
|
||||
// Note: impl on a slice
|
||||
impl get for &int {
|
||||
impl get for &'self int {
|
||||
fn get() -> int {
|
||||
return *self;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ trait sum {
|
|||
}
|
||||
|
||||
// Note: impl on a slice
|
||||
impl sum for &[int] {
|
||||
impl sum for &'self [int] {
|
||||
fn sum() -> int {
|
||||
let mut sum = 0;
|
||||
for vec::each(self) |e| { sum += *e; }
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct closure_box {
|
||||
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}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
enum ast {
|
||||
num(uint),
|
||||
add(&ast, &ast)
|
||||
add(&'self ast<'self>, &'self ast<'self>)
|
||||
}
|
||||
|
||||
fn mk_add_ok(x: &r/ast, y: &r/ast) -> ast/&r {
|
||||
fn mk_add_ok(x: &'r ast<'r>, y: &'r ast<'r>) -> ast<'r> {
|
||||
add(x, y)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
enum ast {
|
||||
num(uint),
|
||||
add(&ast, &ast)
|
||||
add(&'self ast<'self>, &'self ast<'self>)
|
||||
}
|
||||
|
||||
fn mk_add_ok(x: &a/ast, y: &a/ast, z: &ast) -> ast/&a {
|
||||
fn mk_add_ok(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'a> {
|
||||
add(x, y)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct boxed_int {
|
||||
f: &int,
|
||||
f: &'self int,
|
||||
}
|
||||
|
||||
fn max(bi: &r/boxed_int, f: &r/int) -> int {
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct boxed_int {
|
||||
f: &int,
|
||||
f: &'self int,
|
||||
}
|
||||
|
||||
fn get(bi: &r/boxed_int) -> &r/int {
|
||||
fn get(bi: &'r boxed_int<'r>) -> &'r int {
|
||||
bi.f
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ use core::cast;
|
|||
use std::arena::Arena;
|
||||
|
||||
struct Bcx {
|
||||
fcx: &Fcx
|
||||
fcx: &'self Fcx<'self>
|
||||
}
|
||||
|
||||
struct Fcx {
|
||||
arena: &Arena,
|
||||
ccx: &Ccx
|
||||
arena: &'self Arena,
|
||||
ccx: &'self Ccx
|
||||
}
|
||||
|
||||
struct Ccx {
|
||||
x: int
|
||||
}
|
||||
|
||||
fn h(bcx : &r/Bcx) -> &r/Bcx {
|
||||
fn h(bcx : &'r Bcx<'r>) -> &'r Bcx<'r> {
|
||||
return bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,26 +11,26 @@
|
|||
enum arena = ();
|
||||
|
||||
struct Bcx {
|
||||
fcx: &Fcx
|
||||
fcx: &'self Fcx<'self>
|
||||
}
|
||||
|
||||
struct Fcx {
|
||||
arena: &arena,
|
||||
ccx: &Ccx
|
||||
arena: &'self arena,
|
||||
ccx: &'self Ccx
|
||||
}
|
||||
|
||||
struct Ccx {
|
||||
x: int
|
||||
}
|
||||
|
||||
fn alloc(_bcx : &arena) -> &Bcx {
|
||||
fn alloc(_bcx : &'a arena) -> &'a Bcx<'a> {
|
||||
unsafe {
|
||||
return cast::reinterpret_cast(
|
||||
&libc::malloc(sys::size_of::<Bcx/&blk>() as libc::size_t));
|
||||
}
|
||||
}
|
||||
|
||||
fn h(bcx : &Bcx) -> &Bcx {
|
||||
fn h(bcx : &'a Bcx<'a>) -> &'a Bcx<'a> {
|
||||
return alloc(bcx.fcx.arena);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
enum roption {
|
||||
a, b(&uint)
|
||||
a, b(&'self uint)
|
||||
}
|
||||
|
||||
fn mk(cond: bool, ptr: &r/uint) -> roption/&r {
|
||||
fn mk(cond: bool, ptr: &'r uint) -> roption<'r> {
|
||||
if cond {a} else {b(ptr)}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
enum int_wrapper {
|
||||
int_wrapper_ctor(&int)
|
||||
int_wrapper_ctor(&'self int)
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct closure_box {
|
||||
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}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ trait get_ctxt {
|
|||
fn get_ctxt() -> &self/Ctxt;
|
||||
}
|
||||
|
||||
struct HasCtxt { c: &Ctxt }
|
||||
struct HasCtxt { c: &'self Ctxt }
|
||||
|
||||
impl get_ctxt for HasCtxt {
|
||||
impl get_ctxt<'self> for HasCtxt<'self> {
|
||||
fn get_ctxt() -> &self/Ctxt {
|
||||
self.c
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
struct Foo {
|
||||
x: &int
|
||||
x: &'self int
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue