rust/src/test/run-pass/infer-with-expected.rs
Marijn Haverbeke 10120cce0f typeck: Take more care to pass down expected types
This helps with prototype inference and avoids some 'must be known
in this context' errors.
2012-04-25 17:45:29 +02:00

13 lines
418 B
Rust

// Tests the passing down of expected types through boxing and
// wrapping in a record or tuple. (The a.x would complain about 'this
// type must be known in this context' if the passing down doesn't
// happen.)
fn eat_tup(_r: ~@(int, fn@({x: int, y: int}) -> int)) {}
fn eat_rec(_r: @~{a: int, b: fn@({x: int, y: int}) -> int}) {}
fn main() {
eat_tup(~@(10, {|a| a.x}));
eat_rec(@~{a: 10, b: {|a| a.x}});
}