]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/func-arg-incomplete-pattern.rs
Add new tests for irrefutable patterns used in various tricky ways
[rust.git] / src / test / run-pass / func-arg-incomplete-pattern.rs
1 // Test that we do not leak when the arg pattern must drop part of the
2 // argument (in this case, the `y` field).
3
4 struct Foo {
5     x: ~uint,
6     y: ~uint,
7 }
8
9 fn foo(Foo {x, _}: Foo) -> *uint {
10     let addr: *uint = &*x;
11     addr
12 }
13
14 fn main() {
15     let obj = ~1;
16     let objptr: *uint = &*obj;
17     let f = Foo {x: obj, y: ~2};
18     let xptr = foo(f);
19     assert_eq!(objptr, xptr);
20 }