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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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
}

0 commit comments

Comments
 (0)