2013-03-03 17:18:18 -08:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
/*!
|
2013-03-22 14:00:15 -07:00
|
|
|
* Try to double-check that static fns have the right size (with or
|
2013-03-03 17:18:18 -08:00
|
|
|
* without dummy env ptr, as appropriate) by iterating a size-2 array.
|
2013-03-22 14:00:15 -07:00
|
|
|
* If the static size differs from the runtime size, the second element
|
2013-03-03 17:18:18 -08:00
|
|
|
* should be read as a null or otherwise wrong pointer and crash.
|
|
|
|
*/
|
|
|
|
|
|
|
|
fn f() { }
|
2014-02-14 17:23:01 +13:00
|
|
|
static bare_fns: &'static [fn()] = &[f, f];
|
2014-04-02 09:47:11 -07:00
|
|
|
struct S<'a>(||:'a);
|
2014-04-21 23:25:18 -07:00
|
|
|
static mut closures: &'static mut [S<'static>] = &mut [S(f), S(f)];
|
2013-03-03 17:18:18 -08:00
|
|
|
|
|
|
|
pub fn main() {
|
2014-02-21 20:31:50 +01:00
|
|
|
unsafe {
|
|
|
|
for &bare_fn in bare_fns.iter() { bare_fn() }
|
2014-04-21 23:25:18 -07:00
|
|
|
for closure in closures.mut_iter() {
|
|
|
|
let S(ref mut closure) = *closure;
|
2014-02-21 20:31:50 +01:00
|
|
|
(*closure)()
|
|
|
|
}
|
2014-01-31 16:54:45 -08:00
|
|
|
}
|
2013-03-03 17:18:18 -08:00
|
|
|
}
|