File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -1091,7 +1091,8 @@ impl<'cfg> Workspace<'cfg> {
10911091 for feature in requested_features. features . iter ( ) {
10921092 if let Some ( index) = feature. find ( '/' ) {
10931093 let name = & feature[ ..index] ;
1094- if specs. iter ( ) . any ( |spec| spec. name ( ) == name) {
1094+ let is_member = self . members ( ) . any ( |member| member. name ( ) == name) ;
1095+ if is_member && specs. iter ( ) . any ( |spec| spec. name ( ) == name) {
10951096 member_specific_features
10961097 . entry ( name)
10971098 . or_default ( )
Original file line number Diff line number Diff line change @@ -458,3 +458,34 @@ fn resolver1_member_features() {
458458 . with_stdout ( "m1-feature set" )
459459 . run ( ) ;
460460}
461+
462+ #[ cargo_test]
463+ fn resolver1_non_member_optional_feature ( ) {
464+ // --features x/y for an optional dependency `x` with the v1 resolver.
465+ Package :: new ( "bar" , "1.0.0" )
466+ . feature ( "feat1" , & [ ] )
467+ . file (
468+ "src/lib.rs" ,
469+ r#"
470+ #[cfg(not(feature = "feat1"))]
471+ compile_error!("feat1 should be activated");
472+ "# ,
473+ )
474+ . publish ( ) ;
475+ let p = project ( )
476+ . file (
477+ "Cargo.toml" ,
478+ r#"
479+ [package]
480+ name = "foo"
481+ version = "0.1.0"
482+
483+ [dependencies]
484+ bar = { version="1.0", optional=true }
485+ "# ,
486+ )
487+ . file ( "src/lib.rs" , "" )
488+ . build ( ) ;
489+
490+ p. cargo ( "check -p bar --features bar/feat1" ) . run ( ) ;
491+ }
You can’t perform that action at this time.
0 commit comments