diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 0000000000..eeac9f7826 --- /dev/null +++ b/clippy.toml @@ -0,0 +1,4 @@ +[[disallowed-methods]] +path = "futures::future::Future::wait" +replacement = "common::block_on_f01" +reason = "Use the default KDF async executor (using block_on/block_on_f01)." \ No newline at end of file diff --git a/mm2src/common/common.rs b/mm2src/common/common.rs index 58f74e7661..e390893bae 100644 --- a/mm2src/common/common.rs +++ b/mm2src/common/common.rs @@ -634,29 +634,20 @@ pub fn var(name: &str) -> Result { #[cfg(target_arch = "wasm32")] pub fn var(_name: &str) -> Result { ERR!("Environment variable not supported in WASM") } -#[cfg(not(target_arch = "wasm32"))] +/// Runs the given future on MM2's executor and waits for the result. +/// +/// This is compatible with futures 0.1. pub fn block_on_f01(f: F) -> Result where F: Future, { - if var("TRACE_BLOCK_ON").map(|v| v == "true") == Ok(true) { - let mut trace = String::with_capacity(4096); - stack_trace(&mut stack_trace_frame, &mut |l| trace.push_str(l)); - log::info!("block_on_f01 at\n{}", trace); - } - - wio::CORE.0.block_on(f.compat()) -} - -#[cfg(target_arch = "wasm32")] -pub fn block_on_f01(_f: F) -> Result -where - F: Future, -{ - panic!("block_on_f01 is not supported in WASM!"); + block_on(f.compat()) } #[cfg(not(target_arch = "wasm32"))] +/// Runs the given future on MM2's executor and waits for the result. +/// +/// This is compatible with futures 0.3. pub fn block_on(f: F) -> F::Output where F: Future03,