2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
//@ pretty-expanded FIXME #23616
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_upper_case_globals)]
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2013-03-04 01:18:18 +00:00
|
|
|
/*!
|
2013-03-22 21:00:15 +00:00
|
|
|
* Try to double-check that static fns have the right size (with or
|
2013-03-04 01:18:18 +00:00
|
|
|
* without dummy env ptr, as appropriate) by iterating a size-2 array.
|
2013-03-22 21:00:15 +00:00
|
|
|
* If the static size differs from the runtime size, the second element
|
2013-03-04 01:18:18 +00:00
|
|
|
* should be read as a null or otherwise wrong pointer and crash.
|
|
|
|
*/
|
|
|
|
|
|
|
|
fn f() { }
|
2014-02-14 04:23:01 +00:00
|
|
|
static bare_fns: &'static [fn()] = &[f, f];
|
2015-01-02 22:32:54 +00:00
|
|
|
struct S<F: FnOnce()>(F);
|
|
|
|
static mut closures: &'static mut [S<fn()>] = &mut [S(f as fn()), S(f as fn())];
|
2013-03-04 01:18:18 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
2014-02-21 19:31:50 +00:00
|
|
|
unsafe {
|
2015-01-31 17:20:46 +00:00
|
|
|
for &bare_fn in bare_fns { bare_fn() }
|
2015-02-01 01:02:00 +00:00
|
|
|
for closure in &mut *closures {
|
2014-04-22 06:25:18 +00:00
|
|
|
let S(ref mut closure) = *closure;
|
2014-02-21 19:31:50 +00:00
|
|
|
(*closure)()
|
|
|
|
}
|
2014-02-01 00:54:45 +00:00
|
|
|
}
|
2013-03-04 01:18:18 +00:00
|
|
|
}
|