]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/func-arg-incomplete-pattern.rs
Rollup merge of #62759 - mark-i-m:rustc-guide-toolstate-check, r=kennytm
[rust.git] / src / test / ui / binding / func-arg-incomplete-pattern.rs
1 // run-pass
2 #![allow(dead_code)]
3 // Test that we do not leak when the arg pattern must drop part of the
4 // argument (in this case, the `y` field).
5
6 #![feature(box_syntax)]
7
8 struct Foo {
9     x: Box<usize>,
10     y: Box<usize>,
11 }
12
13 fn foo(Foo {x, ..}: Foo) -> *const usize {
14     let addr: *const usize = &*x;
15     addr
16 }
17
18 pub fn main() {
19     let obj: Box<_> = box 1;
20     let objptr: *const usize = &*obj;
21     let f = Foo {x: obj, y: box 2};
22     let xptr = foo(f);
23     assert_eq!(objptr, xptr);
24 }