File tree Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -194,8 +194,8 @@ impl ResolvedFeatures {
194194 }
195195
196196 /// Variant of `activated_features` that returns an empty Vec if this is
197- /// not a valid pkg_id/is_build combination. Used by `cargo clean` which
198- /// doesn't know the exact set .
197+ /// not a valid pkg_id/is_build combination. Used in places which do
198+ /// not know which packages are activated (like `cargo clean`) .
199199 pub fn activated_features_unverified (
200200 & self ,
201201 pkg_id : PackageId ,
Original file line number Diff line number Diff line change @@ -956,8 +956,8 @@ fn resolve_all_features(
956956 } else {
957957 FeaturesFor :: NormalOrDev
958958 } ;
959- for feature in resolved_features. activated_features ( dep_id, features_for) {
960- features. insert ( dep. name_in_toml ( ) . to_string ( ) + "/" + & feature) ;
959+ for feature in resolved_features. activated_features_unverified ( dep_id, features_for) {
960+ features. insert ( format ! ( "{}/{}" , dep. name_in_toml( ) , feature) ) ;
961961 }
962962 }
963963 }
Original file line number Diff line number Diff line change 11//! Tests for the new feature resolver.
22
3- use cargo_test_support:: project;
43use cargo_test_support:: registry:: { Dependency , Package } ;
4+ use cargo_test_support:: { basic_manifest, project} ;
55
66#[ cargo_test]
77fn inactivate_targets ( ) {
@@ -893,3 +893,41 @@ fn disabled_shared_build_dep() {
893893 . with_stdout ( "hello from somedep" )
894894 . run ( ) ;
895895}
896+
897+ #[ cargo_test]
898+ fn required_features_inactive_dep ( ) {
899+ // required-features with an inactivated dep.
900+ let p = project ( )
901+ . file (
902+ "Cargo.toml" ,
903+ r#"
904+ [package]
905+ name = "foo"
906+ version = "0.1.0"
907+
908+ [target.'cfg(whatever)'.dependencies]
909+ bar = {path="bar"}
910+
911+ [[bin]]
912+ name = "foo"
913+ required-features = ["feat1"]
914+
915+ [features]
916+ feat1 = []
917+ "# ,
918+ )
919+ . file ( "src/main.rs" , "fn main() {}" )
920+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
921+ . file ( "bar/src/lib.rs" , "" )
922+ . build ( ) ;
923+
924+ p. cargo ( "check -Zfeatures=itarget" )
925+ . masquerade_as_nightly_cargo ( )
926+ . with_stderr ( "[FINISHED] [..]" )
927+ . run ( ) ;
928+
929+ p. cargo ( "check -Zfeatures=itarget --features=feat1" )
930+ . masquerade_as_nightly_cargo ( )
931+ . with_stderr ( "[CHECKING] foo[..]\n [FINISHED] [..]" )
932+ . run ( ) ;
933+ }
You can’t perform that action at this time.
0 commit comments