You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 29, 2025. It is now read-only.
The portability lint as planned just lints the code that did not get cfg'd away. But an extension (raised many time including by me in #8 (comment)) would have it be done on everything. This entails delaying the pruning of cfg-dead code until after name resolution, or even type checking.
I always assumed this would be a long ways off, but I just realized something vary similar has been proposed with with inlining and target_feature. For the static #[target_feature], the inline rules are just a hard-error version of the compatibility lint, which is great! (I hope in a future epoch the compatibility lint can be made a hard error.). But for cfg!(target_feature), we have some very interesting things going on:
Portability per node. For a fully analyzed cfg!(target_feature) we can look at the portability per mode of the CFG instead of per item. We'd probably want a difference syntax but the short story is that different branches of an if cfg!(...) have statically known portability, the dynamism is just the choice of edge. For cfg_feature_enabled! it's just the same except no branches must be pruned in the end.
Selective hygiene: A function must always be statically safe to call/inline if it is safe at all, but we "break" normal lexical rules to allow "improving" the interpretation of the formula. This can be formalized as passing in an exact portability as a static-parameter to be monomorphized.
More broadly, the concept of compiling for multiple variations of a platforms neatly extends into compiling for multiple platforms. #[target_feature] is just #[cfg(target_feature ...)] where the target_feature is neither true nor false in all current platforms. There is very little conceptual overhead in extending this to interpreting arbitrary cfg formulae over arbitrary sets of "active" (concurrently targeted) models. Given that one general system of "delayed cfg resolution" can implement both features, I'd strongly consider planning that.
As an aside, I guess we might as well track over areas of overlap between these two features in this issue too.
The portability lint as planned just lints the code that did not get
cfg'd away. But an extension (raised many time including by me in #8 (comment)) would have it be done on everything. This entails delaying the pruning ofcfg-dead code until after name resolution, or even type checking.I always assumed this would be a long ways off, but I just realized something vary similar has been proposed with with inlining and
target_feature. For the static#[target_feature], the inline rules are just a hard-error version of the compatibility lint, which is great! (I hope in a future epoch the compatibility lint can be made a hard error.). But forcfg!(target_feature), we have some very interesting things going on:cfg!(target_feature)we can look at the portability per mode of the CFG instead of per item. We'd probably want a difference syntax but the short story is that different branches of anif cfg!(...)have statically known portability, the dynamism is just the choice of edge. Forcfg_feature_enabled!it's just the same except no branches must be pruned in the end.More broadly, the concept of compiling for multiple variations of a platforms neatly extends into compiling for multiple platforms.
#[target_feature]is just#[cfg(target_feature ...)]where thetarget_featureis neither true nor false in all current platforms. There is very little conceptual overhead in extending this to interpreting arbitrarycfgformulae over arbitrary sets of "active" (concurrently targeted) models. Given that one general system of "delayedcfgresolution" can implement both features, I'd strongly consider planning that.As an aside, I guess we might as well track over areas of overlap between these two features in this issue too.
CC @gnzlbg