1 //@run-rustfix 2 #![feature(lint_reasons)] 3 #![feature(async_closure)] 4 #![warn(clippy::async_yields_async)] 5 #![allow(clippy::redundant_async_block)] 6 7 use core::future::Future; 8 use core::pin::Pin; 9 use core::task::{Context, Poll}; 10 11 struct CustomFutureType; 12 13 impl Future for CustomFutureType { 14 type Output = u8; 15 poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output>16 fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> { 17 Poll::Ready(3) 18 } 19 } 20 custom_future_type_ctor() -> CustomFutureType21fn custom_future_type_ctor() -> CustomFutureType { 22 CustomFutureType 23 } 24 f() -> CustomFutureType25async fn f() -> CustomFutureType { 26 // Don't warn for functions since you have to explicitly declare their 27 // return types. 28 CustomFutureType 29 } 30 31 #[rustfmt::skip] main()32fn main() { 33 let _f = { 34 3 35 }; 36 let _g = async { 37 3 38 }; 39 let _h = async { 40 async { 41 3 42 } 43 }; 44 let _i = async { 45 CustomFutureType 46 }; 47 let _i = async || { 48 3 49 }; 50 let _j = async || { 51 async { 52 3 53 } 54 }; 55 let _k = async || { 56 CustomFutureType 57 }; 58 let _l = async || CustomFutureType; 59 let _m = async || { 60 println!("I'm bored"); 61 // Some more stuff 62 63 // Finally something to await 64 CustomFutureType 65 }; 66 let _n = async || custom_future_type_ctor(); 67 let _o = async || f(); 68 } 69 70 #[rustfmt::skip] 71 #[allow(dead_code)] check_expect_suppression()72fn check_expect_suppression() { 73 #[expect(clippy::async_yields_async)] 74 let _j = async || { 75 async { 76 3 77 } 78 }; 79 } 80