@@ -97,8 +97,13 @@ CfgAliasAttribute:
9797 cfg_alias(IDENTIFIER `=` ConfigurationPredicate)
9898```
9999
100- The identifier is added to the ` cfg ` namespace. It must not conflict with any
101- builtin configuration names, or with those passed via ` --cfg ` or ` --check-cfg ` . [ ^ check-cfg ]
100+ The identifier is added to the ` cfg ` namespace. It must not conflict with:
101+
102+ - Any builtin configuration names
103+ - Any configuration passed via ` --cfg `
104+ - Any configuration passed with ` --check-cfg ` , since this indicates a possible
105+ but omitted ` --cfg ` option
106+ - Other aliases that are in scope
102107
103108Once defined, the alias can be used as a regular predicate.
104109
@@ -125,8 +130,38 @@ other?
125130If we go with the first option, we should limit to a single expansion to avoid
126131recursing (as is done for ` #define ` in C).
127132
128- [ ^ check-cfg ] : ` --check-cfg ` is included here because it indicates there may be a
129- corresponding ` --cfg ` .
133+ ## Optional: ` cfg_alias ` in non-crate attributes
134+
135+ At a language level, it should be possbile to allow using ` cfg_alias ` as a
136+ module-level attribute rather than crate-level:
137+
138+ ``` rust
139+ #[cfg_alias(foo = bar)]
140+ mod uses_bar {
141+ // Enabled/disabled based on `cfg(bar)`
142+ #[cfg(foo)]
143+ fn qux () { /* ... */ }
144+ }
145+
146+ #[cfg_alias(foo = baz)]
147+ mod uses_baz {
148+ // Enabled/disabled based on `cfg(baz)`
149+ #[cfg(foo)]
150+ fn qux () { /* ... */ }
151+ }
152+ ```
153+
154+ This has the advantage of keeping aliases in closer proximity to where they are
155+ used; if a configuration pattern is only used within a specific module, an alias
156+ can be added at the top of the file rather than making it crate-global.
157+
158+ This RFC proposes that the use of ` cfg_alias ` on modules _ should_ be included if
159+ possible. However, this may bring implementation complexity since (to the RFC
160+ author's knowledge), the rustc configuration system is not designed to allow
161+ scoped configuration.
162+
163+ If implementation of module-level aliases turns out to be nontrivial, this
164+ portion of the feature may be deferred or dropped before stabilization.
130165
131166# Drawbacks
132167
0 commit comments