]> git.lizzy.rs Git - rust.git/blob - tests/ui/binding/func-arg-incomplete-pattern.rs
Rollup merge of #106648 - Nilstrieb:poly-cleanup, r=compiler-errors
[rust.git] / tests / 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 struct Foo {
7     x: Box<usize>,
8     y: Box<usize>,
9 }
10
11 fn foo(Foo {x, ..}: Foo) -> *const usize {
12     let addr: *const usize = &*x;
13     addr
14 }
15
16 pub fn main() {
17     let obj: Box<_> = Box::new(1);
18     let objptr: *const usize = &*obj;
19     let f = Foo { x: obj, y: Box::new(2) };
20     let xptr = foo(f);
21     assert_eq!(objptr, xptr);
22 }