|
5 | 5 | //! new behaviors. When `-Zfeatures` is not used, it will fall back to using
|
6 | 6 | //! the original `Resolve` feature computation. With `-Zfeatures` enabled,
|
7 | 7 | //! this will walk the dependency graph and compute the features using a
|
8 |
| -//! different algorithm. One of its key characteristics is that it can avoid |
9 |
| -//! unifying features for shared dependencies in some situations. |
| 8 | +//! different algorithm. |
| 9 | +//! |
| 10 | +//! One of its key characteristics is that it can avoid unifying features for |
| 11 | +//! shared dependencies in some situations. See `FeatureOpts` for the |
| 12 | +//! different behaviors that can be enabled. If no extra options are enabled, |
| 13 | +//! then it should behave exactly the same as the dependency resolver's |
| 14 | +//! feature resolution. This can be verified by setting the |
| 15 | +//! `__CARGO_FORCE_NEW_FEATURES=compare` environment variable and running |
| 16 | +//! Cargo's test suite (or building other projects), and checking if it |
| 17 | +//! panics. Note: the `features2` tests will fail because they intentionally |
| 18 | +//! compare the old vs new behavior, so forcing the old behavior will |
| 19 | +//! naturally fail the tests. |
10 | 20 | //!
|
11 | 21 | //! The preferred way to engage this new resolver is via
|
12 | 22 | //! `resolve_ws_with_opts`.
|
13 | 23 | //!
|
14 |
| -//! There are many assumptions made about the resolver itself. It assumes |
15 |
| -//! validation has already been done on the feature maps, and doesn't do any |
16 |
| -//! validation itself. It assumes dev-dependencies within a dependency have |
17 |
| -//! been removed. |
| 24 | +//! This does not *replace* feature resolution in the dependency resolver, but |
| 25 | +//! instead acts as a second pass which can *narrow* the features selected in |
| 26 | +//! the dependency resolver. The dependency resolver still needs to do its own |
| 27 | +//! feature resolution in order to avoid selecting optional dependencies that |
| 28 | +//! are never enabled. The dependency resolver could, in theory, just assume |
| 29 | +//! all optional dependencies on all packages are enabled (and remove all |
| 30 | +//! knowledge of features), but that could introduce new requirements that |
| 31 | +//! might change old behavior or cause conflicts. Maybe some day in the future |
| 32 | +//! we could experiment with that, but it seems unlikely to work or be all |
| 33 | +//! that helpful. |
| 34 | +//! |
| 35 | +//! There are many assumptions made about the dependency resolver. This |
| 36 | +//! feature resolver assumes validation has already been done on the feature |
| 37 | +//! maps, and doesn't do any validation itself. It assumes dev-dependencies |
| 38 | +//! within a dependency have been removed. There are probably other |
| 39 | +//! assumptions that I am forgetting. |
18 | 40 |
|
19 | 41 | use crate::core::compiler::{CompileKind, RustcTargetData};
|
20 | 42 | use crate::core::dependency::{DepKind, Dependency};
|
|
0 commit comments