diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-07-12 09:36:56 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-07-13 10:20:50 -0700 |
| commit | 90e435e8082105f86f45a11186450ffb50653ffd (patch) | |
| tree | b9d9dfd85632310a4a2954bbf851d8662f161b49 | |
| parent | 1fe0d8d7d70c78ea69647f765dd1bb780b5e6d86 (diff) | |
| download | rust-90e435e8082105f86f45a11186450ffb50653ffd.tar.gz rust-90e435e8082105f86f45a11186450ffb50653ffd.zip | |
change region syntax to &r/T in place of &r.T
28 files changed, 87 insertions, 82 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4a013f20dfd..e1f3eb3217c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -420,15 +420,20 @@ class parser { } } - // Parses something like "&x." (note the trailing dot) - fn parse_region_dot() -> @region { + // Parses something like "&x/" (note the trailing slash) + fn parse_region_with_sep() -> @region { let name = alt copy self.token { - token::IDENT(sid, _) if self.look_ahead(1u) == token::DOT { - self.bump(); self.bump(); - some(self.get_str(sid)) + token::IDENT(sid, _) => { + if self.look_ahead(1u) == token::DOT || // backwards compat + self.look_ahead(1u) == token::BINOP(token::SLASH) { + self.bump(); self.bump(); + some(self.get_str(sid)) + } else { + none + } } - _ { none } + _ => { none } }; self.region_from_name(name) } @@ -495,7 +500,7 @@ class parser { t } else if self.token == token::BINOP(token::AND) { self.bump(); - let region = self.parse_region_dot(); + let region = self.parse_region_with_sep(); let mt = self.parse_mt(); ty_rptr(region, mt) } else if self.eat_keyword("pure") { diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 4df6e3e9d9b..91edf4bb0d7 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -183,10 +183,10 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { ty_ptr(tm) { "*" + mt_to_str(cx, tm) } ty_rptr(r, tm) { let rs = region_to_str(cx, r); - if str::len(rs) == 1u { + if rs == "&" { rs + mt_to_str(cx, tm) } else { - rs + "." + mt_to_str(cx, tm) + rs + "/" + mt_to_str(cx, tm) } } ty_vec(tm) { "[" + mt_to_str(cx, tm) + "]" } diff --git a/src/test/compile-fail/regions-addr-of-arg.rs b/src/test/compile-fail/regions-addr-of-arg.rs index 09b5008aa99..6ef6e219e13 100644 --- a/src/test/compile-fail/regions-addr-of-arg.rs +++ b/src/test/compile-fail/regions-addr-of-arg.rs @@ -1,9 +1,9 @@ fn foo(a: int) { - let _p: &static.int = &a; //~ ERROR mismatched types + let _p: &static/int = &a; //~ ERROR mismatched types } fn bar(a: int) { - let _q: &blk.int = &a; + let _q: &blk/int = &a; } fn main() { diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index 39e9f568758..969361db63e 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -6,12 +6,12 @@ class dog { } fn chase_cat() { - let p: &static.mut uint = &mut self.cats_chased; //~ ERROR mismatched types + let p: &static/mut uint = &mut self.cats_chased; //~ ERROR mismatched types *p += 1u; } fn chase_cat_2() { - let p: &blk.mut uint = &mut self.cats_chased; + let p: &blk/mut uint = &mut self.cats_chased; *p += 1u; } } diff --git a/src/test/compile-fail/regions-addr-of-upvar-self.rs b/src/test/compile-fail/regions-addr-of-upvar-self.rs index 7fa455487e1..e61d5eb3d05 100644 --- a/src/test/compile-fail/regions-addr-of-upvar-self.rs +++ b/src/test/compile-fail/regions-addr-of-upvar-self.rs @@ -7,7 +7,7 @@ class dog { fn chase_cat() { for uint::range(0u, 10u) |i| { - let p: &static.mut uint = &mut self.food; //~ ERROR mismatched types + let p: &static/mut uint = &mut self.food; //~ ERROR mismatched types *p = 3u; } } diff --git a/src/test/compile-fail/regions-blk.rs b/src/test/compile-fail/regions-blk.rs index 9e6b5d0d342..7a69b456d0d 100644 --- a/src/test/compile-fail/regions-blk.rs +++ b/src/test/compile-fail/regions-blk.rs @@ -1,12 +1,12 @@ fn foo(cond: bool) { let x = 5; - let mut y: &blk.int = &x; + let mut y: &blk/int = &x; - let mut z: &blk.int; + let mut z: &blk/int; if cond { z = &x; } else { - let w: &blk.int = &x; + let w: &blk/int = &x; z = w; //~ ERROR mismatched types } } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index d19a0c83905..59e8af556de 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -3,8 +3,8 @@ // checked. enum an_enum = ∫ -iface an_iface { fn foo() -> &self.int; } -class a_class { let x:&self.int; new(x:&self.int) { self.x = x; } } +iface an_iface { fn foo() -> &self/int; } +class a_class { let x:&self/int; new(x:&self/int) { self.x = x; } } fn a_fn1(e: an_enum/&a) -> an_enum/&b { ret e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a` diff --git a/src/test/compile-fail/regions-creating-enums3.rs b/src/test/compile-fail/regions-creating-enums3.rs index 7f162b494aa..740a23f8a75 100644 --- a/src/test/compile-fail/regions-creating-enums3.rs +++ b/src/test/compile-fail/regions-creating-enums3.rs @@ -1,9 +1,9 @@ -enum ast/& { +enum ast { num(uint), add(&ast, &ast) } -fn mk_add_bad1(x: &a.ast, y: &b.ast) -> ast/&a { +fn mk_add_bad1(x: &a/ast, y: &b/ast) -> ast/&a { add(x, y) //~ ERROR mismatched types: expected `&a.ast/&a` but found `&b.ast/&b` } diff --git a/src/test/compile-fail/regions-creating-enums4.rs b/src/test/compile-fail/regions-creating-enums4.rs index a95b6f9f4bd..f43548c88f6 100644 --- a/src/test/compile-fail/regions-creating-enums4.rs +++ b/src/test/compile-fail/regions-creating-enums4.rs @@ -1,9 +1,9 @@ -enum ast/& { +enum ast { num(uint), add(&ast, &ast) } -fn mk_add_bad2(x: &a.ast, y: &a.ast, z: &ast) -> ast { +fn mk_add_bad2(x: &a/ast, y: &a/ast, z: &ast) -> ast { add(x, y) //~ ERROR mismatched types: expected `ast/&` but found `ast/&a` } diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index 571b5da41fe..09456b1ecaa 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -1,7 +1,7 @@ // Here, `f` is a function that takes a pointer `x` and a function // `g`, where `g` requires its argument `y` to be in the same region // that `x` is in. -fn has_same_region(f: fn(x: &a.int, g: fn(y: &a.int))) { +fn has_same_region(f: fn(x: &a/int, g: fn(y: &a/int))) { // Somewhat counterintuitively, this fails because, in // `wants_two_regions`, the `g` argument needs to be able to // accept any region. That is, the type that `has_same_region` diff --git a/src/test/compile-fail/regions-fns.rs b/src/test/compile-fail/regions-fns.rs index fc8a631c6b7..9427d4875a0 100644 --- a/src/test/compile-fail/regions-fns.rs +++ b/src/test/compile-fail/regions-fns.rs @@ -1,16 +1,16 @@ // Should fail region checking, because g can only accept a pointer // with lifetime r, and a is a pointer with unspecified lifetime. fn not_ok_1(a: &uint) { - let mut g: fn@(x: &uint) = fn@(x: &r.uint) {}; + let mut g: fn@(x: &uint) = fn@(x: &r/uint) {}; //~^ ERROR mismatched types g(a); } // Should fail region checking, because g can only accept a pointer // with lifetime r, and a is a pointer with lifetime s. -fn not_ok_2(s: &s.uint) +fn not_ok_2(s: &s/uint) { - let mut g: fn@(x: &uint) = fn@(x: &r.uint) {}; + let mut g: fn@(x: &uint) = fn@(x: &r/uint) {}; //~^ ERROR mismatched types g(s); } diff --git a/src/test/compile-fail/regions-iface-1.rs b/src/test/compile-fail/regions-iface-1.rs index 3478742c2ec..230bf150a1c 100644 --- a/src/test/compile-fail/regions-iface-1.rs +++ b/src/test/compile-fail/regions-iface-1.rs @@ -11,7 +11,7 @@ impl of get_ctxt for has_ctxt { // 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 } diff --git a/src/test/compile-fail/regions-iface-2.rs b/src/test/compile-fail/regions-iface-2.rs index 413e17c354f..7ea17cea45a 100644 --- a/src/test/compile-fail/regions-iface-2.rs +++ b/src/test/compile-fail/regions-iface-2.rs @@ -1,13 +1,13 @@ type ctxt = { v: uint }; iface get_ctxt { - fn get_ctxt() -> &self.ctxt; + fn get_ctxt() -> &self/ctxt; } type has_ctxt = { c: &ctxt }; impl of get_ctxt for has_ctxt { - fn get_ctxt() -> &self.ctxt { self.c } + fn get_ctxt() -> &self/ctxt { self.c } } fn make_gc() -> get_ctxt { diff --git a/src/test/compile-fail/regions-iface-3.rs b/src/test/compile-fail/regions-iface-3.rs index 6268846c3ec..ff6d7b42a53 100644 --- a/src/test/compile-fail/regions-iface-3.rs +++ b/src/test/compile-fail/regions-iface-3.rs @@ -1,5 +1,5 @@ iface get_ctxt { - fn get_ctxt() -> &self.uint; + fn get_ctxt() -> &self/uint; } fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b { diff --git a/src/test/compile-fail/regions-in-consts.rs b/src/test/compile-fail/regions-in-consts.rs index 83a117d951a..1816ed48063 100644 --- a/src/test/compile-fail/regions-in-consts.rs +++ b/src/test/compile-fail/regions-in-consts.rs @@ -1,7 +1,7 @@ // xfail-test -const c_x: &blk.int = 22; //~ ERROR only the static region is allowed here -const c_y: &static.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; //~ ERROR only the static region is allowed here fn main() { } \ No newline at end of file diff --git a/src/test/compile-fail/regions-in-enums.rs b/src/test/compile-fail/regions-in-enums.rs index 3a9f34892f6..61178979fc3 100644 --- a/src/test/compile-fail/regions-in-enums.rs +++ b/src/test/compile-fail/regions-in-enums.rs @@ -3,11 +3,11 @@ enum yes0 { } enum yes1 { - x4(&self.uint) + x4(&self/uint) } enum yes2 { - x5(&foo.uint) //~ ERROR named regions other than `self` are not allowed as part of a type declaration + x5(&foo/uint) //~ ERROR named regions other than `self` are not allowed as part of a type declaration } fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/regions-in-rsrcs.rs b/src/test/compile-fail/regions-in-rsrcs.rs index 297ff98ad4e..61ed8d3b6f3 100644 --- a/src/test/compile-fail/regions-in-rsrcs.rs +++ b/src/test/compile-fail/regions-in-rsrcs.rs @@ -5,14 +5,14 @@ class yes0 { } class yes1 { - let x: &self.uint; - new(x: &self.uint) { self.x = x; } + let x: &self/uint; + new(x: &self/uint) { self.x = x; } drop {} } class yes2 { - let x: &foo.uint; //~ ERROR named regions other than `self` are not allowed as part of a type declaration - new(x: &foo.uint) { self.x = x; } //~ ERROR named regions other than `self` are not allowed as part of a type declaration + let x: &foo/uint; //~ ERROR named regions other than `self` are not allowed as part of a type declaration + new(x: &foo/uint) { self.x = x; } //~ ERROR named regions other than `self` are not allowed as part of a type declaration drop {} } diff --git a/src/test/compile-fail/regions-in-type-items.rs b/src/test/compile-fail/regions-in-type-items.rs index 3ccae788651..8faf50fadbe 100644 --- a/src/test/compile-fail/regions-in-type-items.rs +++ b/src/test/compile-fail/regions-in-type-items.rs @@ -3,11 +3,11 @@ type item_ty_yes0 = { }; 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() {} \ No newline at end of file diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index 907f8e5e69d..b00ae17ddf7 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -11,7 +11,7 @@ impl methods for c { } fn set_f_bad(b: @b) { - self.f = b; //~ ERROR mismatched types: expected `@@&self.int` but found `@@&int` + self.f = b; //~ ERROR mismatched types: expected `@@&self/int` but found `@@&int` } } diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index bea901071a2..125abb5e0f7 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -2,7 +2,7 @@ // refers to self. iface foo { - fn self_int() -> &self.int; + fn self_int() -> &self/int; fn any_int() -> ∫ } diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index c6393d89d2b..2d0fc08f597 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -1,16 +1,16 @@ fn ignore<T>(t: T) {} -fn nested(x: &x.int) { +fn nested(x: &x/int) { let y = 3; let mut ay = &y; - ignore(fn&(z: &z.int) { + ignore(fn&(z: &z/int) { ay = x; ay = &y; ay = z; //~ ERROR references with lifetime }); - ignore(fn&(z: &z.int) -> &z.int { + ignore(fn&(z: &z/int) -> &z/int { if false { ret x; } //~ ERROR references with lifetime if false { ret &y; } //~ ERROR references with lifetime if false { ret ay; } //~ ERROR references with lifetime diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs index cf31a308e77..becfa8e7671 100644 --- a/src/test/compile-fail/regions-ret.rs +++ b/src/test/compile-fail/regions-ret.rs @@ -1,6 +1,6 @@ // error-pattern: mismatched types -fn f(x : &a.int) -> &a.int { +fn f(x : &a/int) -> &a/int { ret &3; } diff --git a/src/test/compile-fail/regions-scoping.rs b/src/test/compile-fail/regions-scoping.rs index 6e2bd60c4cc..ac9bef8ca5d 100644 --- a/src/test/compile-fail/regions-scoping.rs +++ b/src/test/compile-fail/regions-scoping.rs @@ -1,42 +1,42 @@ fn with<T>(t: T, f: fn(T)) { f(t) } -fn nested(x: &x.int) { // (1) +fn nested(x: &x/int) { // (1) do with( - fn&(x: &x.int, // Refers to the region `x` at (1) - y: &y.int, // A fresh region `y` (2) - z: fn(x: &x.int, // Refers to `x` at (1) - y: &y.int, // Refers to `y` at (2) - z: &z.int) -> &z.int) // A fresh region `z` (3) - -> &x.int { + fn&(x: &x/int, // Refers to the region `x` at (1) + y: &y/int, // A fresh region `y` (2) + z: fn(x: &x/int, // Refers to `x` at (1) + y: &y/int, // Refers to `y` at (2) + z: &z/int) -> &z/int) // A fresh region `z` (3) + -> &x/int { - if false { ret z(x, x, x); } //~ ERROR mismatched types: expected `&y.int` but found `&x.int` - if false { ret z(x, x, y); } //~ ERROR mismatched types: expected `&y.int` but found `&x.int` - //~^ ERROR mismatched types: expected `&x.int` but found `&y.int` + if false { ret z(x, x, x); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int` + if false { ret z(x, x, y); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int` + //~^ ERROR mismatched types: expected `&x/int` but found `&y/int` if false { ret z(x, y, x); } - if false { ret z(x, y, y); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int` - if false { ret z(y, x, x); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int` - //~^ ERROR mismatched types: expected `&y.int` but found `&x.int` - if false { ret z(y, x, y); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int` - //~^ ERROR mismatched types: expected `&y.int` but found `&x.int` - //~^^ ERROR mismatched types: expected `&x.int` but found `&y.int` - if false { ret z(y, y, x); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int` - if false { ret z(y, y, y); } //~ ERROR mismatched types: expected `&x.int` but found `&y.int` - //~^ ERROR mismatched types: expected `&x.int` but found `&y.int` + if false { ret z(x, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { ret z(y, x, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + //~^ ERROR mismatched types: expected `&y/int` but found `&x/int` + if false { ret z(y, x, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + //~^ ERROR mismatched types: expected `&y/int` but found `&x/int` + //~^^ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { ret z(y, y, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { ret z(y, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + //~^ ERROR mismatched types: expected `&x/int` but found `&y/int` fail; } ) |foo| { - let a: &x.int = foo(x, x, |_x, _y, z| z ); - let b: &x.int = foo(x, a, |_x, _y, z| z ); - let c: &x.int = foo(a, a, |_x, _y, z| z ); + let a: &x/int = foo(x, x, |_x, _y, z| z ); + let b: &x/int = foo(x, a, |_x, _y, z| z ); + let c: &x/int = foo(a, a, |_x, _y, z| z ); let z = 3i; - let d: &x.int = foo(x, x, |_x, _y, z| z ); - let e: &x.int = foo(x, &z, |_x, _y, z| z ); - let f: &x.int = foo(&z, &z, |_x, _y, z| z ); //~ ERROR mismatched types: expected `&x.int` but found + let d: &x/int = foo(x, x, |_x, _y, z| z ); + let e: &x/int = foo(x, &z, |_x, _y, z| z ); + let f: &x/int = foo(&z, &z, |_x, _y, z| z ); //~ ERROR mismatched types: expected `&x/int` but found - foo(x, &z, |x, _y, _z| x ); //~ ERROR mismatched types: expected `&z.int` but found `&x.int` - foo(x, &z, |_x, y, _z| y ); //~ ERROR mismatched types: expected `&z.int` but found `&<block at + foo(x, &z, |x, _y, _z| x ); //~ ERROR mismatched types: expected `&z/int` but found `&x/int` + foo(x, &z, |_x, y, _z| y ); //~ ERROR mismatched types: expected `&z/int` but found `&<block at } } diff --git a/src/test/run-pass/issue-2502.rs b/src/test/run-pass/issue-2502.rs index 5df083a9402..557bfd1383d 100644 --- a/src/test/run-pass/issue-2502.rs +++ b/src/test/run-pass/issue-2502.rs @@ -1,11 +1,11 @@ class font { - let fontbuf: &self.~[u8]; + let fontbuf: &self/~[u8]; - new(fontbuf: &self.~[u8]) { + new(fontbuf: &self/~[u8]) { self.fontbuf = fontbuf; } - fn buf() -> &self.~[u8] { + fn buf() -> &self/~[u8] { self.fontbuf } } diff --git a/src/test/run-pass/issue-2748-a.rs b/src/test/run-pass/issue-2748-a.rs index bf027bdd060..2d8dd45b043 100644 --- a/src/test/run-pass/issue-2748-a.rs +++ b/src/test/run-pass/issue-2748-a.rs @@ -1,7 +1,7 @@ class CMap { let buf: &[u8]; - new(buf: &self.[u8]) { + new(buf: &self/[u8]) { self.buf = buf; } } diff --git a/src/test/run-pass/regions-creating-enums5.rs b/src/test/run-pass/regions-creating-enums5.rs index 0ca55e99e12..7931f83965c 100644 --- a/src/test/run-pass/regions-creating-enums5.rs +++ b/src/test/run-pass/regions-creating-enums5.rs @@ -3,7 +3,7 @@ enum ast { add(&ast, &ast) } -fn mk_add_ok(x: &a.ast, y: &a.ast, z: &ast) -> ast/&a { +fn mk_add_ok(x: &a/ast, y: &a/ast, z: &ast) -> ast/&a { add(x, y) } diff --git a/src/test/run-pass/regions-iface.rs b/src/test/run-pass/regions-iface.rs index 3f8301cd26c..ec4a0a2dcfe 100644 --- a/src/test/run-pass/regions-iface.rs +++ b/src/test/run-pass/regions-iface.rs @@ -1,13 +1,13 @@ type ctxt = { v: uint }; iface get_ctxt { - fn get_ctxt() -> &self.ctxt; + fn get_ctxt() -> &self/ctxt; } type has_ctxt = { c: &ctxt }; impl of get_ctxt for has_ctxt { - fn get_ctxt() -> &self.ctxt { + fn get_ctxt() -> &self/ctxt { self.c } } diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 4e0cd5b1aee..d8d33273b8f 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -1,7 +1,7 @@ type clam = { chowder: &int }; impl clam for clam { - fn get_chowder() -> &self.int { ret self.chowder; } + fn get_chowder() -> &self/int { ret self.chowder; } } fn main() { |
