Move cfg_if macro from libstd to libcore
dlrobertson opened this issue ยท 5 comments
Summary
If possible I would like to move the cfg_if
macro from src/libstd/macros.rs
to src/libcore/macros.rs
.
Motivation
The cfg_if
macro could potentially increase the readability of some cfg
s in no_std
code. In particular it could dramatically improve the readability of some code in libcore
e.g. ffi::VaList
(why I'm interested in moving it ๐). I don't see anything in the macro that would make it invalid in libcore
.
Unfortunately we don't have a great way to export a macro from libcore to use in libstd that isn't part of the public API. We aren't quite ready yet I think to make this part of the public API but duplicating the definition should be fine as its a pretty simple macro
@alexcrichton ๐ Thanks for the info. I'll hold off on duplicating it in libstd
until I know I need it then.
@alexcrichton can you elaborate on why we don't want to make cfg_if
public? It came up recently in the left-pad index dicussions, seems like it would be good to expose this publicly in std and core.
More discussion about this is at #59443 as well. I do not personally have an opinion on whether or not this should be exported from core
or not. I don't personally have the motivation to push for that stabilization and/or inclusion myself.
I am going to close this issue as it's been somewhat obsoleted by the fact that libstd depends on cfg-if (the crate) now, and libcore can always duplicate if necessary. I imagine we might even be able to get libcore to depend on cfg-if (since it's a macro-only crate I believe), but that's likely harder :)