rust/src/test/compile-fail/regions-infer-contravariance-due-to-immutability.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
329 B
Rust

struct contravariant {
f: ∫
}
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() {
}