External Publication
Visit Post

[Pre-RFC] Make some feature-detected function-to-fn-pointer casts safe through ZST token types

Rust Internals [Unofficial] May 25, 2026
Source

That way of casting is an instruction I'd really like to see in wasm so that the environment has a choice in feature support instead of any mention of simd128 requiring it for the whole module.

As a language feature however it would be less flexible. It works for setup function calls but is inappropriate for most runtime call dispatch. This is as would exhibit the same problem as the is_*_feature_detect macro itself, each evaluation loads from an atomic (to avoid the repeated cpuid) and this causes LLVM to treat the cast as a side-effect and sequence point; if you write N casts you get N loads instead of being able to re-use the feature bitmask in any way. With struct_target_feature you get to avoid that part.

Discussion in the ATmosphere

Loading comments...