]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/const-vec-of-fns.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / const-vec-of-fns.rs
1 /*!
2  * Try to double-check that static fns have the right size (with or
3  * without dummy env ptr, as appropriate) by iterating a size-2 array.
4  * If the static size differs from the runtime size, the second element
5  * should be read as a null or otherwise wrong pointer and crash.
6  */
7
8 fn f() {}
9 static mut CLOSURES: &'static mut [fn()] = &mut [f as fn(), f as fn()];
10
11 pub fn main() {
12     unsafe {
13         for closure in &mut *CLOSURES {
14             (*closure)()
15         }
16     }
17 }