Skip to content

Ignore zero-sized types in wasm future-compat warning #139498

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 18, 2025

Conversation

alexcrichton
Copy link
Member

This commit fixes a false positive of the warning triggered for #138762 and the fix is to codify that zero-sized types are "safe" in both the old and new ABIs.

@rustbot
Copy link
Collaborator

rustbot commented Apr 7, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 7, 2025
@alexcrichton alexcrichton added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 7, 2025
@alexcrichton
Copy link
Member Author

I've additionally tagged this for a beta backport since the false positive is currently in beta too.

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

r=me with jieyouxu's suggestion addressed

@jieyouxu
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 17, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jieyouxu jieyouxu added the O-wasm Target: WASM (WebAssembly), http://webassembly.org/ label Apr 17, 2025
This commit fixes a false positive of the warning triggered for rust-lang#138762
and the fix is to codify that zero-sized types are "safe" in both the
old and new ABIs.
@alexcrichton
Copy link
Member Author

@bors: r=wesleywiser

@bors
Copy link
Collaborator

bors commented Apr 17, 2025

📌 Commit f9091e2 has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 17, 2025
Comment on lines +114 to +117
// Zero-sized types are dropped in both ABIs, so they're safe
if arg.layout.is_zst() {
return true;
}
Copy link
Member

Choose a reason for hiding this comment

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

That's not actually a stable guarantee, nobody should rely on this...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that this at least respects the status quo where the purpose of the wasm_c_abi warning is "this will change" and for ZSTs behavior isn't changing.

Otherwise though for relying on ZSTs, I know wasm-bindgen definitely does rely on ZSTs getting dropped at the ABI level, and AFAIK it's quite difficult to remove the reliance. I can't speak for other projects though.

Copy link
Member

Choose a reason for hiding this comment

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

for ZSTs behavior isn't changing.

Yeah, that's a fair point, we don't have to warn about them.

But it seems quite concerning that wasm-bindgen would rely on unstable undocumented ABI guarantees without (apparently) any effort to make those things into stable guarantees. We don't guarantee that ZST are skipped in any form for any ABI, and I'm not even aware of an issue someone opened asking for this as a guarantee.

@jieyouxu
Copy link
Member

Unsettled discussions re. lack of guarantee
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 17, 2025
@RalfJung
Copy link
Member

@bors r=wesleywiser

Silencing the warning for ZST is fine, relying on their being skipped does not become any less correct via this change.

@bors
Copy link
Collaborator

bors commented Apr 17, 2025

📌 Commit f9091e2 has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 17, 2025
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 17, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 17, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#139351 (Autodiff batching2)
 - rust-lang#139483 (f*::NAN: guarantee that this is a quiet NaN)
 - rust-lang#139498 (Ignore zero-sized types in wasm future-compat warning)
 - rust-lang#139967 (Introduce and use specialized `//@ ignore-auxiliary` for test support files instead of using `//@ ignore-test`)
 - rust-lang#139969 (update libc)
 - rust-lang#139971 (Make C string merging test work on MIPS)
 - rust-lang#139974 (Change `InterpCx::instantiate*` function visibility to pub)
 - rust-lang#139977 (Fix drop handling in `hint::select_unpredictable`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8b7a289 into rust-lang:master Apr 18, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 18, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 18, 2025
Rollup merge of rust-lang#139498 - alexcrichton:wasm-zst-safe, r=wesleywiser

Ignore zero-sized types in wasm future-compat warning

This commit fixes a false positive of the warning triggered for rust-lang#138762 and the fix is to codify that zero-sized types are "safe" in both the old and new ABIs.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
beta-nominated Nominated for backporting to the compiler in the beta channel. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants