From 2bdb037300cc1b30c44bd28e4da1cfece54495da Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 21 Aug 2025 14:55:01 +1000 Subject: [PATCH 1/3] `create_async_runtime`: Make `cfg` checks exhaustive --- .../typespec_client_core/src/async_runtime/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs b/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs index 65a58b2e8f..47a8404837 100644 --- a/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs +++ b/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs @@ -187,13 +187,16 @@ pub fn set_async_runtime(runtime: Arc) -> crate::Result<()> { fn create_async_runtime() -> Arc { #[cfg(all(target_arch = "wasm32", feature = "wasm_bindgen"))] { - Arc::new(web_runtime::WasmBindgenRuntime) as Arc + return Arc::new(web_runtime::WasmBindgenRuntime) as Arc; } #[cfg(feature = "tokio")] { - Arc::new(tokio_runtime::TokioRuntime) as Arc + return Arc::new(tokio_runtime::TokioRuntime) as Arc; } - #[cfg(not(any(feature = "tokio", feature = "wasm_bindgen")))] + #[cfg(not(any( + feature = "tokio", + all(target_arch = "wasm32", feature = "wasm_bindgen") + )))] { Arc::new(standard_runtime::StdRuntime) as Arc } From 61048cdabb72b1904f7caef1445ddea9335c1b53 Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 21 Aug 2025 15:00:12 +1000 Subject: [PATCH 2/3] remove return --- sdk/typespec/typespec_client_core/src/async_runtime/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs b/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs index 47a8404837..5ff5c06c81 100644 --- a/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs +++ b/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs @@ -187,11 +187,11 @@ pub fn set_async_runtime(runtime: Arc) -> crate::Result<()> { fn create_async_runtime() -> Arc { #[cfg(all(target_arch = "wasm32", feature = "wasm_bindgen"))] { - return Arc::new(web_runtime::WasmBindgenRuntime) as Arc; + Arc::new(web_runtime::WasmBindgenRuntime) as Arc } #[cfg(feature = "tokio")] { - return Arc::new(tokio_runtime::TokioRuntime) as Arc; + Arc::new(tokio_runtime::TokioRuntime) as Arc } #[cfg(not(any( feature = "tokio", From d65a3f16f511a48b5347002fb300f516cdbd11f4 Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 21 Aug 2025 15:16:42 +1000 Subject: [PATCH 3/3] update --- sdk/typespec/typespec_client_core/src/async_runtime/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs b/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs index 5ff5c06c81..fa76e9a5b1 100644 --- a/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs +++ b/sdk/typespec/typespec_client_core/src/async_runtime/mod.rs @@ -185,6 +185,11 @@ pub fn set_async_runtime(runtime: Arc) -> crate::Result<()> { } fn create_async_runtime() -> Arc { + #[cfg(all(feature = "wasm_bindgen", feature = "tokio"))] + compile_error!( + "feature \"wasm_bindgen\" and feature \"tokio\" cannot be enabled at the same time" + ); + #[cfg(all(target_arch = "wasm32", feature = "wasm_bindgen"))] { Arc::new(web_runtime::WasmBindgenRuntime) as Arc