[Solved] Manually returning a boxed future does not trigger a must_use warning?

#![ feature( futures_api, async_await ) ]

use std::pin::Pin;
use std::future::Future;

fn must_use() -> Pin<Box< dyn Future<Output=()> >>
	Box::pin( async
		println!( "I was used" )

async fn must_use2() -> ()
	println!( "I was used 2" )

fn main()
	must_use();  // will not trigger warning
	must_use2(); // will trigger warning

I wonder whether there’s a way around this, since I use it quite alot to have async trait functions. I hope this can be solved without “newtype” pattern, for hopefully obvious reasons.

That being said I imagine that the async keyword does this by creating a newtype…

You can mark your functions as #[must_use] to get the lint back.


Thank you so much, that’s awesome!