1
- //! Feature resolver.
1
+ //! # Feature resolver
2
2
//!
3
- //! This is a new feature resolver that runs independently of the main
3
+ //! This is a [ new feature resolver] that runs independently of the main
4
4
//! dependency resolver. It has several options which can enable new feature
5
5
//! resolution behavior.
6
6
//!
7
7
//! One of its key characteristics is that it can avoid unifying features for
8
- //! shared dependencies in some situations. See `FeatureOpts` for the
8
+ //! shared dependencies in some situations. See [ `FeatureOpts`] for the
9
9
//! different behaviors that can be enabled. If no extra options are enabled,
10
10
//! then it should behave exactly the same as the dependency resolver's
11
11
//! feature resolution.
12
12
//!
13
- //! The preferred way to engage this new resolver is via
14
- //! `resolve_ws_with_opts`.
13
+ //! The preferred way to engage this new resolver is via [`resolve_ws_with_opts`].
15
14
//!
16
15
//! This does not *replace* feature resolution in the dependency resolver, but
17
16
//! instead acts as a second pass which can *narrow* the features selected in
24
23
//! we could experiment with that, but it seems unlikely to work or be all
25
24
//! that helpful.
26
25
//!
27
- //! There are many assumptions made about the dependency resolver. This
28
- //! feature resolver assumes validation has already been done on the feature
29
- //! maps, and doesn't do any validation itself. It assumes dev-dependencies
30
- //! within a dependency have been removed. There are probably other
31
- //! assumptions that I am forgetting.
26
+ //! ## Assumptions
27
+ //!
28
+ //! There are many assumptions made about the dependency resolver:
29
+ //!
30
+ //! * Assumes feature validation has already been done during the construction
31
+ //! of feature maps, so the feature resolver doesn't do that validation at all.
32
+ //! * Assumes `dev-dependencies` within a dependency have been removed
33
+ //! in the given [`Resolve`].
34
+ //!
35
+ //! There are probably other assumptions that I am forgetting.
36
+ //!
37
+ //! [new feature resolver]: https://doc.rust-lang.org/nightly/cargo/reference/resolver.html#feature-resolver-version-2
38
+ //! [`resolve_ws_with_opts`]: crate::ops::resolve_ws_with_opts
32
39
33
40
use crate :: core:: compiler:: { CompileKind , CompileTarget , RustcTargetData } ;
34
41
use crate :: core:: dependency:: { ArtifactTarget , DepKind , Dependency } ;
@@ -42,7 +49,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
42
49
use std:: rc:: Rc ;
43
50
44
51
/// The key used in various places to store features for a particular dependency.
45
- /// The actual discrimination happens with the `FeaturesFor` type.
52
+ /// The actual discrimination happens with the [ `FeaturesFor`] type.
46
53
type PackageFeaturesKey = ( PackageId , FeaturesFor ) ;
47
54
/// Map of activated features.
48
55
type ActivateMap = HashMap < PackageFeaturesKey , BTreeSet < InternedString > > ;
@@ -393,6 +400,12 @@ impl ResolvedFeatures {
393
400
/// Key is `(pkg_id, for_host)`. Value is a set of features or dependencies removed.
394
401
pub type DiffMap = BTreeMap < PackageFeaturesKey , BTreeSet < InternedString > > ;
395
402
403
+ /// The new feature resolver that [`resolve`]s your project.
404
+ ///
405
+ /// For more information, please see the [module-level documentation].
406
+ ///
407
+ /// [`resolve`]: Self::resolve
408
+ /// [module-level documentation]: crate::core::resolver::features
396
409
pub struct FeatureResolver < ' a , ' cfg > {
397
410
ws : & ' a Workspace < ' cfg > ,
398
411
target_data : & ' a RustcTargetData < ' cfg > ,
@@ -428,7 +441,7 @@ pub struct FeatureResolver<'a, 'cfg> {
428
441
}
429
442
430
443
impl < ' a , ' cfg > FeatureResolver < ' a , ' cfg > {
431
- /// Runs the resolution algorithm and returns a new `ResolvedFeatures`
444
+ /// Runs the resolution algorithm and returns a new [ `ResolvedFeatures`]
432
445
/// with the result.
433
446
pub fn resolve (
434
447
ws : & Workspace < ' cfg > ,
@@ -495,6 +508,10 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
495
508
Ok ( ( ) )
496
509
}
497
510
511
+ /// Activates [`FeatureValue`]s on the given package.
512
+ ///
513
+ /// This is the main entrance into the recursion of feature activation
514
+ /// for a package.
498
515
fn activate_pkg (
499
516
& mut self ,
500
517
pkg_id : PackageId ,
0 commit comments