@@ -329,6 +329,51 @@ There are a number of drawbacks to this approach:
329
329
problems. It is difficult to get sufficient testing, particularly when only
330
330
available as an unstable feature.
331
331
332
+ ## Subtle behaviors
333
+
334
+ The following are behaviors that may be confusing or surprising, and are
335
+ highlighted here as potential concerns.
336
+
337
+ ### Optional dependency feature names
338
+
339
+ * ` dep_name/feat_name ` will always enable the feature ` dep_name ` , even if it
340
+ is an inactive optional dependency (such as a dependency for another
341
+ platform). The intent here is to be consistent where features are always
342
+ activated when explicitly written, but the * dependency* is not activated.
343
+
344
+ * ` --all-features ` enables features for inactive optional dependencies (but
345
+ does not activate the * dependency* ). This is consistent with `--features
346
+ foo` enabling ` foo` , even if the ` foo` dependency is not activated.
347
+
348
+ Code that needs to have a ` cfg ` expression for a dependency of this kind
349
+ should use a ` cfg ` that matches the condition (like ` cfg(windows) ` ) or use
350
+ ` cfg(accessible(dep_name)) ` when that syntax is stabilized.
351
+
352
+ This is somewhat intertwined with the upcoming [ namespaced features] . For an
353
+ optional dependency, the feature is decoupled from the activating of the
354
+ dependency itself.
355
+
356
+ ### Proc-macro unification in a workspace
357
+
358
+ If there is a proc-macro in a workspace, and the proc-macro is included as a
359
+ "root" package along with other packages in a workspace (for example with
360
+ ` cargo build --workspace ` ), then there can be some potentially surprising
361
+ feature unification between the proc-macro and the other members of the
362
+ workspace. This is because proc-macros * may* have normal targets such as
363
+ binaries or tests, which need feature unification with the rest of the
364
+ workspace.
365
+
366
+ This issue is detailed in [ issue #8312 ] .
367
+
368
+ At this time, there isn't a clear solution to this problem. If this is an
369
+ issue, projects are encouraged to avoid using ` --workspace ` or use ` --exclude `
370
+ or otherwise avoid building multiple workspace members together. This is also
371
+ related to the [ workspace unification issue] .
372
+
373
+ [ namespaced features ] : https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#namespaced-features
374
+ [ issue #8312 ] : https://github.com/rust-lang/cargo/issues/8312
375
+ [ workspace unification issue ] : https://github.com/rust-lang/cargo/issues/4463
376
+
332
377
# Rationale and alternatives
333
378
334
379
* These changes could be forced on all users without an opt-in. The amount of
0 commit comments