1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#![cfg(feature = "macros")] use alloc_counter::{no_alloc, AllocCounterSystem}; use futures_executor::block_on; #[global_allocator] static A: AllocCounterSystem = AllocCounterSystem; #[test] fn async_fn() { #[no_alloc] async fn foo() -> i32 { 0 } async fn bar() { foo().await; } block_on(bar()); } #[test] #[cfg_attr(debug_assertions, should_panic)] fn async_fn_bad() { #[no_alloc] async fn foo() -> i32 { *Box::new(0) } async fn bar() { foo().await; } block_on(bar()); }