Skip to content

Use cfg_if to simplify some cfgs #270

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

Closed
dlrobertson opened this issue Jan 15, 2019 · 5 comments
Closed

Use cfg_if to simplify some cfgs #270

dlrobertson opened this issue Jan 15, 2019 · 5 comments

Comments

@dlrobertson
Copy link
Collaborator

The cfg_if crate is no_std and use of the cfg_if! macro could simplify some of the code where we have a pattern like the following:

#[cfg(something)]
// Do something
#[cfg(not(something))]
// Do something else
@whitequark
Copy link
Contributor

I vaguely recall some issue with cfg-if as a reason to not use it. But I can't find it now. So I think it's OK.

@dlrobertson
Copy link
Collaborator Author

Looked at this briefly last night and I ran into rust-lang/cfg-if#8. This greatly limits the usefulness of cfg_if for us, but there still may be locations in the codebase that would benefit from the use of cfg_if.

@whitequark
Copy link
Contributor

Oh yeah pretty sure that was the issue. Maybe cfg-if can be fixed?

@dlrobertson
Copy link
Collaborator Author

Yeah it would require some reworking, but I don't see why you couldn't also allow a block or expr token. This is of particular interest to me because the current state of cfgs in src/libcore/ffi.rs for VaList are far from readable, so I'll likely look into this a bit over the next week or so.

@Dirbaio
Copy link
Member

Dirbaio commented Jun 6, 2022

I'm going to close this: it's rare that cfg's are paired in cfg(something), cfg(not(something)), other cases aren't made that better by cfg-if, and IMO it's nice if all cfgs are handled the same.

@Dirbaio Dirbaio closed this as completed Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants