Skip to content

Commit 66770d2

Browse files
committed
test: Add lifetime binders and new-style lifetime parameters to the test suite
1 parent 6d81307 commit 66770d2

17 files changed

+47
-47
lines changed

src/test/compile-fail/regions-infer-contravariance-due-to-immutability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn to_shorter_lifetime(bi: contravariant<'r>) {
2020
let bj: contravariant<'blk> = bi;
2121
}
2222

23-
fn to_longer_lifetime(bi: contravariant<'r>) -> contravariant/&static {
23+
fn to_longer_lifetime(bi: contravariant<'r>) -> contravariant<'static> {
2424
bi //~ ERROR mismatched types
2525
}
2626

src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
// You can upcast to a *smaller region* but not a larger one. This is
1414
// the normal case.
1515

16-
struct contravariant {
16+
struct contravariant<'self> {
1717
f: @fn() -> &'self int
1818
}
1919

20-
fn to_same_lifetime(bi: contravariant/&r) {
21-
let bj: contravariant/&r = bi;
20+
fn to_same_lifetime<'r>(bi: contravariant<'r>) {
21+
let bj: contravariant<'r> = bi;
2222
}
2323

24-
fn to_shorter_lifetime(bi: contravariant/&r) {
25-
let bj: contravariant/&blk = bi;
24+
fn to_shorter_lifetime<'r>(bi: contravariant<'r>) {
25+
let bj: contravariant<'blk> = bi;
2626
}
2727

28-
fn to_longer_lifetime(bi: contravariant/&r) -> contravariant/&static {
28+
fn to_longer_lifetime<'r>(bi: contravariant<'r>) -> contravariant<'static> {
2929
bi //~ ERROR mismatched types
3030
}
3131

src/test/compile-fail/regions-infer-covariance-due-to-arg.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ struct covariant {
1616
f: @fn(x: &'self int) -> int
1717
}
1818

19-
fn to_same_lifetime(bi: covariant/&r) {
20-
let bj: covariant/&r = bi;
19+
fn to_same_lifetime<'r>(bi: covariant<'r>) {
20+
let bj: covariant<'r> = bi;
2121
}
2222

23-
fn to_shorter_lifetime(bi: covariant/&r) {
24-
let bj: covariant/&blk = bi; //~ ERROR mismatched types
23+
fn to_shorter_lifetime<'r>(bi: covariant<'r>) {
24+
let bj: covariant<'blk> = bi; //~ ERROR mismatched types
2525
}
2626

27-
fn to_longer_lifetime(bi: covariant/&r) -> covariant/&static {
27+
fn to_longer_lifetime<'r>(bi: covariant<'r>) -> covariant<'static> {
2828
bi
2929
}
3030

src/test/compile-fail/regions-infer-invariance-due-to-arg-and-ret.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
//
1313
// You cannot convert between regions.
1414

15-
struct invariant {
15+
struct invariant<'self> {
1616
f: &'self fn(x: &'self int) -> &'self int
1717
}
1818

19-
fn to_same_lifetime(bi: invariant<'r>) {
19+
fn to_same_lifetime<'r>(bi: invariant<'r>) {
2020
let bj: invariant<'r> = bi;
2121
}
2222

23-
fn to_shorter_lifetime(bi: invariant<'r>) {
23+
fn to_shorter_lifetime<'r>(bi: invariant<'r>) {
2424
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
2525
}
2626

27-
fn to_longer_lifetime(bi: invariant<'r>) -> invariant/&static {
27+
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
2828
bi //~ ERROR mismatched types
2929
}
3030

src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct invariant {
11+
struct invariant<'self> {
1212
f: @fn(x: @mut &'self int)
1313
}
1414

15-
fn to_same_lifetime(bi: invariant/&r) {
16-
let bj: invariant/&r = bi;
15+
fn to_same_lifetime<'r>(bi: invariant<'r>) {
16+
let bj: invariant<'r> = bi;
1717
}
1818

19-
fn to_shorter_lifetime(bi: invariant/&r) {
20-
let bj: invariant/&blk = bi; //~ ERROR mismatched types
19+
fn to_shorter_lifetime(bi: invariant<'r>) {
20+
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
2121
}
2222

23-
fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
23+
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
2424
bi //~ ERROR mismatched types
2525
}
2626

src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct invariant {
11+
struct invariant<'self> {
1212
f: @fn() -> @mut &'self int
1313
}
1414

15-
fn to_same_lifetime(bi: invariant/&r) {
16-
let bj: invariant/&r = bi;
15+
fn to_same_lifetime(bi: invariant<'r>) {
16+
let bj: invariant<'r> = bi;
1717
}
1818

19-
fn to_shorter_lifetime(bi: invariant/&r) {
20-
let bj: invariant/&blk = bi; //~ ERROR mismatched types
19+
fn to_shorter_lifetime(bi: invariant<'r>) {
20+
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
2121
}
2222

23-
fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
23+
fn to_longer_lifetime(bi: invariant<'r>) -> invariant<'static> {
2424
bi //~ ERROR mismatched types
2525
}
2626

src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct invariant {
11+
struct invariant<'self> {
1212
f: @mut &'self int
1313
}
1414

15-
fn to_same_lifetime(bi: invariant<'r>) {
15+
fn to_same_lifetime<'r>(bi: invariant<'r>) {
1616
let bj: invariant<'r> = bi;
1717
}
1818

19-
fn to_shorter_lifetime(bi: invariant<'r>) {
19+
fn to_shorter_lifetime<'r>(bi: invariant<'r>) {
2020
let bj: invariant<'blk> = bi; //~ ERROR mismatched types
2121
}
2222

23-
fn to_longer_lifetime(bi: invariant<'r>) -> invariant/&static {
23+
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
2424
bi //~ ERROR mismatched types
2525
}
2626

src/test/compile-fail/regions-trait-3.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// option. This file may not be copied, modified, or distributed
1212
// except according to those terms.
1313

14-
trait get_ctxt {
14+
trait get_ctxt<'self> {
1515
fn get_ctxt(self) -> &'self uint;
1616
}
1717

18-
fn make_gc1(gc: @get_ctxt/&a) -> @get_ctxt/&b {
18+
fn make_gc1(gc: @get_ctxt<'a>) -> @get_ctxt<'b> {
1919
return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b` but found `@get_ctxt/&a`
2020
}
2121

@@ -27,7 +27,7 @@ impl get_ctxt for Foo<'self> {
2727
fn get_ctxt(&self) -> &'self uint { self.r }
2828
}
2929

30-
fn make_gc2(foo: Foo/&a) -> @get_ctxt/&b {
30+
fn make_gc2<'a,'b>(foo: Foo<'a>) -> @get_ctxt<'b> {
3131
return @foo as @get_ctxt; //~ ERROR cannot infer an appropriate lifetime
3232
}
3333

src/test/run-pass/const-fn-val.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn foo() -> int {
1414

1515
struct Bar { f: &'self fn() -> int }
1616

17-
static b : Bar/&static = Bar { f: foo };
17+
static b : Bar<'static> = Bar { f: foo };
1818

1919
pub fn main() {
2020
fail_unless!((b.f)() == 0xca7f000d);

src/test/run-pass/issue-2502.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ struct font {
1212
fontbuf: &'self ~[u8],
1313
}
1414

15-
pub impl font/&self {
15+
pub impl<'self> font<'self> {
1616
fn buf(&self) -> &'self ~[u8] {
1717
self.fontbuf
1818
}
1919
}
2020

21-
fn font(fontbuf: &'r ~[u8]) -> font/&r {
21+
fn font(fontbuf: &'r ~[u8]) -> font<'r> {
2222
font {
2323
fontbuf: fontbuf
2424
}

src/test/run-pass/issue-2735-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ struct defer {
1414
}
1515

1616
#[unsafe_destructor]
17-
impl Drop for defer/&self {
17+
impl<'self> Drop for defer<'self> {
1818
fn finalize(&self) {
1919
unsafe {
2020
*(self.b) = true;
2121
}
2222
}
2323
}
2424

25-
fn defer(b: &'r mut bool) -> defer/&r {
25+
fn defer<'r>(b: &'r mut bool) -> defer<'r> {
2626
defer {
2727
b: b
2828
}

src/test/run-pass/issue-2735-3.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ struct defer {
1414
}
1515

1616
#[unsafe_destructor]
17-
impl Drop for defer/&self {
17+
impl<'self> Drop for defer<'self> {
1818
fn finalize(&self) {
1919
unsafe {
2020
*(self.b) = true;
2121
}
2222
}
2323
}
2424

25-
fn defer(b: &'r mut bool) -> defer/&r {
25+
fn defer(b: &'r mut bool) -> defer<'r> {
2626
defer {
2727
b: b
2828
}

src/test/run-pass/issue-2748-a.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct CMap {
1212
buf: &'self [u8],
1313
}
1414

15-
fn CMap(buf: &'r [u8]) -> CMap/&r {
15+
fn CMap<'r>(buf: &'r [u8]) -> CMap<'r> {
1616
CMap {
1717
buf: buf
1818
}

src/test/run-pass/regions-copy-closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct closure_box {
1212
cl: &'self fn(),
1313
}
1414

15-
fn box_it(+x: &'r fn()) -> closure_box/&r {
15+
fn box_it<'r>(+x: &'r fn()) -> closure_box<'r> {
1616
closure_box {cl: x}
1717
}
1818

src/test/run-pass/regions-infer-contravariance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn with(bi: &'r boxed_int) {
2020
// Here, the upcast is allowed because the `boxed_int` type is
2121
// contravariant with respect to `&r`. See also
2222
// compile-fail/regions-infer-invariance-due-to-mutability.rs
23-
let bi: &'blk boxed_int/&blk = bi;
23+
let bi: &'blk boxed_int<'blk> = bi;
2424
fail_unless!(*get(bi) == 22);
2525
}
2626

src/test/run-pass/regions-mock-trans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct Ccx {
2626
fn alloc(_bcx : &'a arena) -> &'a Bcx<'a> {
2727
unsafe {
2828
return cast::reinterpret_cast(
29-
&libc::malloc(sys::size_of::<Bcx/&blk>() as libc::size_t));
29+
&libc::malloc(sys::size_of::<Bcx<'blk>>() as libc::size_t));
3030
}
3131
}
3232

src/test/run-pass/regions-static-closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn box_it(+x: &'r fn()) -> closure_box<'r> {
1616
closure_box {cl: x}
1717
}
1818

19-
fn call_static_closure(cl: closure_box/&static) {
19+
fn call_static_closure(cl: closure_box<'static>) {
2020
(cl.cl)();
2121
}
2222

0 commit comments

Comments
 (0)