Skip to content
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

Error on missing web_sys_unstable_apis #5104

Merged
merged 1 commit into from
Jan 21, 2024

Conversation

rukai
Copy link
Contributor

@rukai rukai commented Jan 20, 2024

closes #5095

I thought about this some more and I think we can and should just give the user a helpful error when they are missing the unstable cfg.
With this we no longer need to take up prime documentation real estate with it.
I imagine resources like sotrh's learn wgpu will push users towards using wgpu = { .. default-features = false, features = ["webgl"] } to make it easy for users to run on the web and then this error will catch the user when they get that slightly wrong.

Testing

I created a seperate crate that depends on wgpu and tested the following cases:
This compiles successfully:

wgpu = {version = "0.19", path = "", features = ["webgl"], default-features = false}

This compiles successfully:

wgpu = {version = "0.19", path = "", default-features = false}

This fails to compile with the new error:

wgpu = {version = "0.19", path = "" }

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@rukai rukai requested a review from a team as a code owner January 20, 2024 00:28
@rukai rukai force-pushed the error_on_missing_unstable_cfg branch from 550cc87 to 0e9b132 Compare January 20, 2024 00:28
@rukai
Copy link
Contributor Author

rukai commented Jan 20, 2024

I will investigate the CI failure.

@rukai rukai force-pushed the error_on_missing_unstable_cfg branch from 0e9b132 to 3820066 Compare January 20, 2024 02:59
@rukai rukai force-pushed the error_on_missing_unstable_cfg branch from 3820066 to f2c52c9 Compare January 20, 2024 03:12
@rukai
Copy link
Contributor Author

rukai commented Jan 20, 2024

cargo doc --target wasm32-unknown-unknown was failing in CI due to triggering the compile failure.
I resolved it by setting rustdocflags the same as we set for rustflags: https://doc.rust-lang.org/cargo/reference/config.html#buildrustdocflags
This fixed the issue locally.

Then I had to set RUSTDOCFLAGS env var in the CI script since it had a custom value that was overwriting rustdocflags config.
This fixed the issue in CI.

Then finally I changed the compile_error message to include setting rustdocflags since if we need to set it to get docs working then we should recommend that users set it too.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

This is great and a really novel solution I hadn't even considered!

@cwfitzgerald cwfitzgerald enabled auto-merge (squash) January 21, 2024 03:22
@cwfitzgerald cwfitzgerald added the PR: needs back-porting PR with a fix that needs to land on crates label Jan 21, 2024
@cwfitzgerald cwfitzgerald merged commit e128d6c into gfx-rs:trunk Jan 21, 2024
28 checks passed
cwfitzgerald pushed a commit to cwfitzgerald/wgpu that referenced this pull request Jan 21, 2024
@cwfitzgerald cwfitzgerald removed the PR: needs back-porting PR with a fix that needs to land on crates label Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

webgpu feature fails to compile
2 participants