]> git.proxmox.com Git - rustc.git/blame - src/test/ui/binding/func-arg-ref-pattern.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / binding / func-arg-ref-pattern.rs
CommitLineData
b7449926 1// run-pass
1a4d82fc
JJ
2
3// Test argument patterns where we create refs to the inside of
4// boxes. Make sure that we don't free the box as we match the
5// pattern.
6
85aaf69f 7#![feature(box_patterns)]
1a4d82fc 8
c34b1796
AL
9fn getaddr(box ref x: Box<usize>) -> *const usize {
10 let addr: *const usize = &*x;
1a4d82fc
JJ
11 addr
12}
13
c34b1796 14fn checkval(box ref x: Box<usize>) -> usize {
1a4d82fc
JJ
15 *x
16}
17
18pub fn main() {
c295e0f8 19 let obj: Box<_> = Box::new(1);
c34b1796 20 let objptr: *const usize = &*obj;
1a4d82fc
JJ
21 let xptr = getaddr(obj);
22 assert_eq!(objptr, xptr);
23
c295e0f8 24 let obj = Box::new(22);
1a4d82fc
JJ
25 assert_eq!(checkval(obj), 22);
26}