@@ -14,6 +14,9 @@ pub struct S {
1414 #[ offset( 4 ) ]
1515 pub y : i32 ,
1616}
17+ pub fn read_0 ( v : Ptr < i32 > ) -> i32 {
18+ return ( v. read ( ) ) ;
19+ }
1720pub fn main ( ) {
1821 __cpp2rust_init_globals ( ) ;
1922 std:: process:: exit ( main_0 ( ) ) ;
@@ -66,6 +69,47 @@ fn main_0() -> i32 {
6669 }
6770 ) ) ) ;
6871 assert ! ( ( ( { ( * shifted. borrow( ) ) . call( 5 , ) } ) == 16 ) ) ;
72+ let k: Value < i32 > = Rc :: new ( RefCell :: new ( 3 ) ) ;
73+ let by_copy: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new ( lambda ! (
74+ {
75+ let k: Value <i32 > = Rc :: new( RefCell :: new( ( * k. borrow( ) ) ) ) ;
76+ } ,
77+ |x: i32 | -> i32 {
78+ let x: Value <i32 > = Rc :: new( RefCell :: new( x) ) ;
79+ return ( ( * x. borrow( ) ) + 3 ) ;
80+ }
81+ ) ) ) ;
82+ assert ! ( ( ( { ( * by_copy. borrow( ) ) . call( 1 , ) } ) == 4 ) ) ;
83+ let by_copy_used: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new ( lambda ! (
84+ {
85+ let k: Value <i32 > = Rc :: new( RefCell :: new( ( * k. borrow( ) ) ) ) ;
86+ } ,
87+ |x: i32 | -> i32 {
88+ let x: Value <i32 > = Rc :: new( RefCell :: new( x) ) ;
89+ return ( ( * x. borrow( ) ) + ( { read_0( k. as_pointer( ) ) } ) ) ;
90+ }
91+ ) ) ) ;
92+ assert ! ( ( ( { ( * by_copy_used. borrow( ) ) . call( 1 , ) } ) == 4 ) ) ;
93+ let implicit_used: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new ( lambda ! (
94+ {
95+ let k: Value <i32 > = Rc :: new( RefCell :: new( ( * k. borrow( ) ) ) ) ;
96+ } ,
97+ |x: i32 | -> i32 {
98+ let x: Value <i32 > = Rc :: new( RefCell :: new( x) ) ;
99+ return ( ( * x. borrow( ) ) + ( { read_0( k. as_pointer( ) ) } ) ) ;
100+ }
101+ ) ) ) ;
102+ assert ! ( ( ( { ( * implicit_used. borrow( ) ) . call( 1 , ) } ) == 4 ) ) ;
103+ let by_ref: Value < FnPtr < fn ( i32 ) -> i32 > > = Rc :: new ( RefCell :: new ( lambda ! (
104+ {
105+ let k: Ptr <i32 > = k. as_pointer( ) ;
106+ } ,
107+ |x: i32 | -> i32 {
108+ let x: Value <i32 > = Rc :: new( RefCell :: new( x) ) ;
109+ return ( ( * x. borrow( ) ) + 3 ) ;
110+ }
111+ ) ) ) ;
112+ assert ! ( ( ( { ( * by_ref. borrow( ) ) . call( 1 , ) } ) == 4 ) ) ;
69113 return 0 ;
70114}
71115pub fn __cpp2rust_init_globals ( ) { }
0 commit comments