2012-08-09 11:59:50 -05:00
|
|
|
// Contravariant with respect to a region:
|
|
|
|
//
|
|
|
|
// You can upcast to a *smaller region* but not a larger one. This is
|
|
|
|
// the normal case.
|
|
|
|
|
|
|
|
struct contravariant {
|
2012-09-07 16:50:47 -05:00
|
|
|
f: fn@() -> &self/int
|
2012-08-09 11:59:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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_longer_lifetime(bi: contravariant/&r) -> contravariant/&static {
|
|
|
|
bi //~ ERROR mismatched types
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|