-
Notifications
You must be signed in to change notification settings - Fork 308
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
Open
magodo
wants to merge
3
commits into
Azure:main
Choose a base branch
from
magodo:create_async_runtime_exhaustive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
wasm_bindgen
, you'd get the standard runtime which, yes, would fail on wasm anyway. But it would fail with thecompile_error
now so nothing has changed except that with how I had it, if - somehow - standard did support wasm (highly doubtful, but imagine a world forstd
did support this) it would just work.Is your goal here only to provide a better error message?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
wasm_bindgen
but not targetingwasm32
. In this case, this function will return a()
(instead of one of the runtime instance). By doing this change, this case will be caught by thiscfg
, and return the standard runtime as expected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
wasm_bindgen
feature at all and instead rely solely ontarget_arch = "wasm"
or, where the difference matters,target = "wasm32-unknown-unknown"
.Can you remind me again why we actually needed a separate feature? Was it only to provide an
AsyncRuntime
for WASM based onbindgen
- much like we default toreqwest
for our default HTTP stack but don't necessitate it?If that's the case, maybe we need to manage this in a more central place e.g., in
src/lib.rs
we have something like:Should we have to add other features - which I want to avoid parity features - in the future, we can just add in an
any()
for feature names.@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
lib.rs
already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
create_async_runtime
.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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
reqwest
but with the added caveat to be useful it has to be on WASM.That said, it did make me think of an issue: if customers are building out for
wasm32-unknown-unknown
orwasm32-wasip2
plus typical PC targets, we might not want thiscompile_error!()
. It means they can't just take a platform-agnostic dependency onazure_core = { version = "*", features = ["wasm_bindgen"] }
and have it just work for whichever platform. They'd need platform-specific targets e.g.,Not the most approachable. So maybe we terminate
create_async_runtime
with thecompile_error!()
instead. I realize I just flipped-flopped, but had some time to think about more use cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heaths This is when we wanted to introduce a feature: #2770 (comment).