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 {
194
194
}
195
195
196
196
/// 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`) .
199
199
pub fn activated_features_unverified (
200
200
& self ,
201
201
pkg_id : PackageId ,
Original file line number Diff line number Diff line change @@ -956,8 +956,8 @@ fn resolve_all_features(
956
956
} else {
957
957
FeaturesFor :: NormalOrDev
958
958
} ;
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) ) ;
961
961
}
962
962
}
963
963
}
Original file line number Diff line number Diff line change 1
1
//! Tests for the new feature resolver.
2
2
3
- use cargo_test_support:: project;
4
3
use cargo_test_support:: registry:: { Dependency , Package } ;
4
+ use cargo_test_support:: { basic_manifest, project} ;
5
5
6
6
#[ cargo_test]
7
7
fn inactivate_targets ( ) {
@@ -893,3 +893,41 @@ fn disabled_shared_build_dep() {
893
893
. with_stdout ( "hello from somedep" )
894
894
. run ( ) ;
895
895
}
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