domain icon indicating copy to clipboard operation
domain copied to clipboard

[Code Style] Position of `#[cfg]` for modules

Open bal-e opened this issue 9 months ago • 1 comments

The codebase currently contains a mix of:

// In `lib.rs`:
#[cfg(feature = "foo")]
mod foo;

and:

// In `foo/mod.rs`:
#![cfg(feature = "foo")]

We should decide on which one is more appropriate and use it uniformly.

bal-e avatar Mar 06 '25 15:03 bal-e

What complicates the discussion is that we tend to do things like:

#![cfg_attr(feature = "foo", doc = "* [foo]:")]
#![cfg_attr(not(feature = "foo"), doc = "* foo:")]

in the parent module. So #![cfg(feature = "foo")] seems nicely self contained, but it spread the test over two modules.

Philip-NLnetLabs avatar Mar 06 '25 15:03 Philip-NLnetLabs