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

Conditional visibility: for integration testing purpose. #3656

Open
crlf0710 opened this issue Jun 9, 2024 · 1 comment
Open

Conditional visibility: for integration testing purpose. #3656

crlf0710 opened this issue Jun 9, 2024 · 1 comment

Comments

@crlf0710
Copy link
Member

crlf0710 commented Jun 9, 2024

For integration testing purpose, it might be necessary to expose more API surface than usual. While it might be possible to directly add integration testing related support, it might be easier to add general purpose mechanism for this.

Strawman proposal:

#[cfg_vis(feature = "internals", pub)]
pub(crate) mod internal_api {
     #[cfg_vis(feature = "internals", pub)]
     pub(crate) fn foo() {
          todo!()
     }
}

or

pub (crate if cfg!(not(feature = "internals"))) mod internal_api {
     pub (crate if cfg!(not(feature = "internals"))) fn foo() {
          todo!()
     }
}

or even

#[cfg(feature = "internals")]
vis internals = pub;

#[cfg(not(feature = "internals"))]
vis internals = pub(crate);

pub(internals) mod internal_api {
     pub(internals) fn foo() {
          todo!()
     }
}

Related existing macro-based crates.

@kennytm
Copy link
Member

kennytm commented Jun 9, 2024

pub (crate if cfg!(not(feature = "internals"))) mod internal_api {

Maybe more natural as

pub(#[cfg(not(feature = "internals"))] crate) mod internal_api

assuming we accept pub() means pub. But you need to copy this huge thing everywhere, unlike the vis alias.


How is this proposal going to interact with #3323?

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

No branches or pull requests

2 participants