Skip to content

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
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

magodo
Copy link
Contributor

@magodo magodo commented Aug 21, 2025

This PR makes the cfg checks exhaustive in the create_async_runtime(), to avoid a case that a package depending on typespec_client_core, enabled wasm_bindgen feature, but build for native target (e.g. x86-84). This will hit no check conditions in the create_async_runtime(), makes it reutrn (). Instead, this shall use the standard runtime.

In fact, mutually exclusive features are not encouraged: https://doc.rust-lang.org/cargo/reference/features.html#mutually-exclusive-features. While I don't have any better idea in this case..

Related to: #2838.

@Copilot Copilot AI review requested due to automatic review settings August 21, 2025 04:59
@github-actions github-actions bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Aug 21, 2025
Copy link

Thank you for your contribution @magodo! We will review the pull request and get back to you soon.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a configuration gap in the create_async_runtime() function by making the cfg checks exhaustive. The change prevents a scenario where enabling the wasm_bindgen feature but building for a non-WASM target would result in no matching configuration, causing the function to return () instead of a proper runtime.

  • Made cfg conditions mutually exclusive by adding early returns
  • Updated the fallback condition to properly exclude the WASM+wasm_bindgen combination
  • Ensures all possible feature/target combinations are handled correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant