-
Notifications
You must be signed in to change notification settings - Fork 313
create_async_runtime
: Make cfg
checks exhaustive
#2937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,13 +187,16 @@ pub fn set_async_runtime(runtime: Arc<dyn AsyncRuntime>) -> crate::Result<()> { | |
fn create_async_runtime() -> Arc<dyn AsyncRuntime> { | ||
#[cfg(all(target_arch = "wasm32", feature = "wasm_bindgen"))] | ||
{ | ||
Arc::new(web_runtime::WasmBindgenRuntime) as Arc<dyn AsyncRuntime> | ||
return Arc::new(web_runtime::WasmBindgenRuntime) as Arc<dyn AsyncRuntime>; | ||
} | ||
#[cfg(feature = "tokio")] | ||
{ | ||
Arc::new(tokio_runtime::TokioRuntime) as Arc<dyn AsyncRuntime> | ||
return Arc::new(tokio_runtime::TokioRuntime) as Arc<dyn AsyncRuntime>; | ||
magodo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
#[cfg(not(any(feature = "tokio", feature = "wasm_bindgen")))] | ||
#[cfg(not(any( | ||
feature = "tokio", | ||
all(target_arch = "wasm32", feature = "wasm_bindgen") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this way - with mutually-exclusive features as added above - instead of how I had it? Basically, if you were on wasm but didn't specify Is your goal here only to provide a better error message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @heaths It is a leak of the check here in case you have specified There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which won't compile, which is fine. It's an invalid combination - and one that is causing me to rethink whether we should have this Can you remind me again why we actually needed a separate feature? Was it only to provide an If that's the case, maybe we need to manage this in a more central place e.g., in #[cfg(all(feature = "wasm_bindgen", not(target_arch = "wasm")))]
compile_error!("nuh uh uh"); Should we have to add other features - which I want to avoid parity features - in the future, we can just add in an @LarryOsterman what do you think? I'd rather not hide this impossible combination check deep down. Or maybe we can solve this in another way but nothing comes to mind. I'd rather not add a build script just for this because it increases build times and we can achieve this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would much rather see this at the absolute top level in lib.rs if at all possible rather than in To be honest, I'd love to see the existance of the wasm_bindgen feature be conditional in the cargo.toml, but I don't believe that you can tie features to a specific architecture. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but I imagine platform-specific features would only push the difficulties upstream even if they were supported...and probably one reason they're not (probably many reasons). We probably just have to think of this like That said, it did make me think of an issue: if customers are building out for [dependencies]
azure_core.version = "1.0.0"
[target.'cfg(target_arch = "wasm32")'.dependencies]
azure_core = { version = "1.0.0", features = ["wasm_bindgen"] } Not the most approachable. So maybe we terminate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @heaths This is when we wanted to introduce a feature: #2770 (comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LarryOsterman do you think we could even get rid of the |
||
)))] | ||
{ | ||
Arc::new(standard_runtime::StdRuntime) as Arc<dyn AsyncRuntime> | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.