@@ -21,6 +21,7 @@ use crate::core::{
21
21
use crate :: core:: { EitherManifest , Package , SourceId , VirtualManifest } ;
22
22
use crate :: ops;
23
23
use crate :: sources:: { PathSource , SourceConfigMap , CRATES_IO_INDEX , CRATES_IO_REGISTRY } ;
24
+ use crate :: util:: context:: FeatureUnification ;
24
25
use crate :: util:: edit_distance;
25
26
use crate :: util:: errors:: { CargoResult , ManifestError } ;
26
27
use crate :: util:: interning:: InternedString ;
@@ -112,7 +113,8 @@ pub struct Workspace<'gctx> {
112
113
/// and other places that use rust version.
113
114
/// This is set based on the resolver version, config settings, and CLI flags.
114
115
resolve_honors_rust_version : bool ,
115
-
116
+ /// The feature unification mode used when building packages.
117
+ resolve_feature_unification : FeatureUnification ,
116
118
/// Workspace-level custom metadata
117
119
custom_metadata : Option < toml:: Value > ,
118
120
@@ -246,6 +248,7 @@ impl<'gctx> Workspace<'gctx> {
246
248
requested_lockfile_path : None ,
247
249
resolve_behavior : ResolveBehavior :: V1 ,
248
250
resolve_honors_rust_version : false ,
251
+ resolve_feature_unification : FeatureUnification :: Selected ,
249
252
custom_metadata : None ,
250
253
local_overlays : HashMap :: new ( ) ,
251
254
}
@@ -307,13 +310,20 @@ impl<'gctx> Workspace<'gctx> {
307
310
}
308
311
}
309
312
}
310
- if let CargoResolverConfig {
311
- incompatible_rust_versions : Some ( incompatible_rust_versions) ,
312
- } = self . gctx ( ) . get :: < CargoResolverConfig > ( "resolver" ) ?
313
- {
313
+ let config = self . gctx ( ) . get :: < CargoResolverConfig > ( "resolver" ) ?;
314
+ if let Some ( incompatible_rust_versions) = config. incompatible_rust_versions {
314
315
self . resolve_honors_rust_version =
315
316
incompatible_rust_versions == IncompatibleRustVersions :: Fallback ;
316
317
}
318
+ if self . gctx ( ) . cli_unstable ( ) . feature_unification {
319
+ self . resolve_feature_unification = config
320
+ . feature_unification
321
+ . unwrap_or ( FeatureUnification :: Selected ) ;
322
+ } else if config. feature_unification . is_some ( ) {
323
+ self . gctx ( )
324
+ . shell ( )
325
+ . warn ( "ignoring `resolver.feature-unification` without `-Zfeature-unification`" ) ?;
326
+ } ;
317
327
318
328
Ok ( ( ) )
319
329
}
@@ -663,6 +673,14 @@ impl<'gctx> Workspace<'gctx> {
663
673
self . resolve_honors_rust_version
664
674
}
665
675
676
+ pub fn set_resolve_feature_unification ( & mut self , feature_unification : FeatureUnification ) {
677
+ self . resolve_feature_unification = feature_unification;
678
+ }
679
+
680
+ pub fn resolve_feature_unification ( & self ) -> FeatureUnification {
681
+ self . resolve_feature_unification
682
+ }
683
+
666
684
pub fn custom_metadata ( & self ) -> Option < & toml:: Value > {
667
685
self . custom_metadata . as_ref ( )
668
686
}
0 commit comments