2012-08-09 11:59:50 -05:00
|
|
|
// Invariance with respect to a region:
|
|
|
|
//
|
|
|
|
// You cannot convert between regions.
|
|
|
|
|
|
|
|
struct invariant {
|
2012-09-07 16:50:47 -05:00
|
|
|
f: fn(x: &self/int) -> &self/int
|
2012-08-09 11:59:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
|
|
|
bi //~ ERROR mismatched types
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|