fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![feature(generators)] 2#![warn(clippy::large_futures)] 3#![allow(clippy::never_loop)] 4#![allow(clippy::future_not_send)] 5#![allow(clippy::manual_async_fn)] 6 7async fn big_fut(_arg: [u8; 1024 * 16]) {} 8 9async fn wait() { 10 let f = async { 11 Box::pin(big_fut([0u8; 1024 * 16])).await; 12 //~^ ERROR: large future with a size of 16385 bytes 13 //~| NOTE: `-D clippy::large-futures` implied by `-D warnings` 14 }; 15 Box::pin(f).await 16 //~^ ERROR: large future with a size of 16386 bytes 17} 18async fn calls_fut(fut: impl std::future::Future<Output = ()>) { 19 loop { 20 Box::pin(wait()).await; 21 //~^ ERROR: large future with a size of 16387 bytes 22 if true { 23 return fut.await; 24 } else { 25 Box::pin(wait()).await; 26 //~^ ERROR: large future with a size of 16387 bytes 27 } 28 } 29} 30 31pub async fn test() { 32 let fut = big_fut([0u8; 1024 * 16]); 33 Box::pin(foo()).await; 34 //~^ ERROR: large future with a size of 65540 bytes 35 Box::pin(calls_fut(fut)).await; 36 //~^ ERROR: large future with a size of 49159 bytes 37} 38 39pub fn foo() -> impl std::future::Future<Output = ()> { 40 async { 41 let x = [0i32; 1024 * 16]; 42 async {}.await; 43 dbg!(x); 44 } 45} 46 47pub async fn lines() { 48 Box::pin(async { 49 //~^ ERROR: large future with a size of 65540 bytes 50 let x = [0i32; 1024 * 16]; 51 async {}.await; 52 println!("{:?}", x); 53 }) 54 .await; 55} 56 57pub async fn macro_expn() { 58 macro_rules! macro_ { 59 () => { 60 Box::pin(async { 61 let x = [0i32; 1024 * 16]; 62 async {}.await; 63 println!("macro: {:?}", x); 64 }) 65 }; 66 } 67 macro_!().await 68} 69 70fn main() {}