Skip to content
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

refactor(filesource): replace repetitive #[cfg()] usages with cfg_if!{} #3832

Closed
wants to merge 1 commit into from

Conversation

rami3l
Copy link
Member

@rami3l rami3l commented May 16, 2024

It occurred to me right after #3811 that we actually have cfg_if in our imports, so using it more should provide better ergonomics and prevent issues like #3811 happen again (i.e. "I forgot to add #[cfg()] to some constructs but not others").

I plan to adjust #3803 to use cfg_if!{} in rustup-init.rs as well, where we also tend to use quite a lot of conditionally compiled constructs.

@rami3l rami3l requested a review from djc May 16, 2024 02:03
@djc
Copy link
Contributor

djc commented May 16, 2024

A simpler way of doing this would be to just move all the test-gated implementations into an inline module which is guarded with #[cfg(feature = "test")] and a single use statement that exports from the inline module. I think I'd prefer that over the cfg_if!{} approach, which is less standard and noisier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants