@@ -5,8 +5,10 @@ static FOO: fn() = || { assert_ne!(42, 43) };
5
5
static BAR : fn ( i32 , i32 ) = |a, b| { assert_ne ! ( a, b) } ;
6
6
7
7
// use to first make the closure FnOnce() before making it fn()
8
- fn magic0 < R , F : FnOnce ( ) -> R > ( f : F ) -> F { f }
9
- fn magic1 < T , R , F : FnOnce ( T ) -> R > ( f : F ) -> F { f }
8
+ fn force_once0 < R , F : FnOnce ( ) -> R > ( f : F ) -> F { f }
9
+ fn force_once1 < T , R , F : FnOnce ( T ) -> R > ( f : F ) -> F { f }
10
+ fn force_mut0 < R , F : FnMut ( ) -> R > ( f : F ) -> F { f }
11
+ fn force_mut1 < T , R , F : FnMut ( T ) -> R > ( f : F ) -> F { f }
10
12
11
13
fn main ( ) {
12
14
FOO ( ) ;
@@ -18,19 +20,15 @@ fn main() {
18
20
19
21
let f: fn ( ) = ||{ } ;
20
22
f ( ) ;
21
- let f = magic0 ( ||{ } ) as fn ( ) ;
23
+ let f = force_once0 ( ||{ } ) as fn ( ) ;
24
+ f ( ) ;
25
+ let f = force_mut0 ( ||{ } ) as fn ( ) ;
22
26
f ( ) ;
23
27
24
28
let g: fn ( i32 ) = |i| assert_eq ! ( i, 2 ) ;
25
29
g ( 2 ) ;
26
- let g = magic1 ( |i| assert_eq ! ( i, 2 ) ) as fn ( i32 ) ;
30
+ let g = force_once1 ( |i| assert_eq ! ( i, 2 ) ) as fn ( i32 ) ;
31
+ g ( 2 ) ;
32
+ let g = force_mut1 ( |i| assert_eq ! ( i, 2 ) ) as fn ( i32 ) ;
27
33
g ( 2 ) ;
28
-
29
- // FIXME: This fails with "invalid use of NULL pointer" <https://github.com/rust-lang/miri/issues/1075>
30
- //let h: fn() -> ! = || std::process::exit(0);
31
- //h();
32
- // FIXME: This does not even compile?!? <https://github.com/rust-lang/rust/issues/66738>
33
- //let h = magic0(|| std::process::exit(0)) as fn() -> !;
34
- //h();
35
- // Once these tests pass, they should be in separate files as they terminate the process.
36
34
}
0 commit comments