@@ -21,6 +21,7 @@ use crate::core::{
2121use crate :: core:: { EitherManifest , Package , SourceId , VirtualManifest } ;
2222use crate :: ops;
2323use crate :: sources:: { PathSource , SourceConfigMap , CRATES_IO_INDEX , CRATES_IO_REGISTRY } ;
24+ use crate :: util:: context:: FeatureUnification ;
2425use crate :: util:: edit_distance;
2526use crate :: util:: errors:: { CargoResult , ManifestError } ;
2627use crate :: util:: interning:: InternedString ;
@@ -112,7 +113,8 @@ pub struct Workspace<'gctx> {
112113 /// and other places that use rust version.
113114 /// This is set based on the resolver version, config settings, and CLI flags.
114115 resolve_honors_rust_version : bool ,
115-
116+ /// The feature unification mode used when building packages.
117+ resolve_feature_unification : FeatureUnification ,
116118 /// Workspace-level custom metadata
117119 custom_metadata : Option < toml:: Value > ,
118120
@@ -246,6 +248,7 @@ impl<'gctx> Workspace<'gctx> {
246248 requested_lockfile_path : None ,
247249 resolve_behavior : ResolveBehavior :: V1 ,
248250 resolve_honors_rust_version : false ,
251+ resolve_feature_unification : FeatureUnification :: Selected ,
249252 custom_metadata : None ,
250253 local_overlays : HashMap :: new ( ) ,
251254 }
@@ -307,13 +310,20 @@ impl<'gctx> Workspace<'gctx> {
307310 }
308311 }
309312 }
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 {
314315 self . resolve_honors_rust_version =
315316 incompatible_rust_versions == IncompatibleRustVersions :: Fallback ;
316317 }
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+ } ;
317327
318328 Ok ( ( ) )
319329 }
@@ -663,6 +673,14 @@ impl<'gctx> Workspace<'gctx> {
663673 self . resolve_honors_rust_version
664674 }
665675
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+
666684 pub fn custom_metadata ( & self ) -> Option < & toml:: Value > {
667685 self . custom_metadata . as_ref ( )
668686 }
0 commit comments