rust/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
Niko Matsakis 511e7626ae Infer variance of types with respect to the region parameter.
A similar approach could be used for type parameters.

Fixes #2282.
2012-08-23 06:30:43 -07:00

18 lines
347 B
Rust

struct invariant {
f: fn@() -> @mut &self/int;
}
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() {
}