@@ -1224,7 +1224,10 @@ impl<'cfg> Workspace<'cfg> {
1224
1224
// really mean anything (either the member is built or it isn't).
1225
1225
// * With `--features nonmember?/feat`, cwd_features will
1226
1226
// handle processing it correctly.
1227
- let is_member = self . members ( ) . any ( |member| member. name ( ) == * dep_name) ;
1227
+ let is_member = self . members ( ) . any ( |member| {
1228
+ // Check if `dep_name` is member of the workspace, but isn't associated with current package.
1229
+ self . current_opt ( ) != Some ( member) && member. name ( ) == * dep_name
1230
+ } ) ;
1228
1231
if is_member && specs. iter ( ) . any ( |spec| spec. name ( ) == * dep_name) {
1229
1232
member_specific_features
1230
1233
. entry ( * dep_name)
@@ -1237,49 +1240,57 @@ impl<'cfg> Workspace<'cfg> {
1237
1240
}
1238
1241
}
1239
1242
1240
- let ms = self . members ( ) . filter_map ( |member| {
1241
- let member_id = member. package_id ( ) ;
1242
- match self . current_opt ( ) {
1243
- // The features passed on the command-line only apply to
1244
- // the "current" package (determined by the cwd).
1245
- Some ( current) if member_id == current. package_id ( ) => {
1246
- let feats = CliFeatures {
1247
- features : Rc :: new ( cwd_features. clone ( ) ) ,
1248
- all_features : cli_features. all_features ,
1249
- uses_default_features : cli_features. uses_default_features ,
1250
- } ;
1251
- Some ( ( member, feats) )
1252
- }
1253
- _ => {
1254
- // Ignore members that are not enabled on the command-line.
1255
- if specs. iter ( ) . any ( |spec| spec. matches ( member_id) ) {
1256
- // -p for a workspace member that is not the "current"
1257
- // one.
1258
- //
1259
- // The odd behavior here is due to backwards
1260
- // compatibility. `--features` and
1261
- // `--no-default-features` used to only apply to the
1262
- // "current" package. As an extension, this allows
1263
- // member-name/feature-name to set member-specific
1264
- // features, which should be backwards-compatible.
1243
+ let ms: Vec < _ > = self
1244
+ . members ( )
1245
+ . filter_map ( |member| {
1246
+ let member_id = member. package_id ( ) ;
1247
+ match self . current_opt ( ) {
1248
+ // The features passed on the command-line only apply to
1249
+ // the "current" package (determined by the cwd).
1250
+ Some ( current) if member_id == current. package_id ( ) => {
1265
1251
let feats = CliFeatures {
1266
- features : Rc :: new (
1267
- member_specific_features
1268
- . remove ( member. name ( ) . as_str ( ) )
1269
- . unwrap_or_default ( ) ,
1270
- ) ,
1271
- uses_default_features : true ,
1252
+ features : Rc :: new ( cwd_features. clone ( ) ) ,
1272
1253
all_features : cli_features. all_features ,
1254
+ uses_default_features : cli_features. uses_default_features ,
1273
1255
} ;
1274
1256
Some ( ( member, feats) )
1275
- } else {
1276
- // This member was not requested on the command-line, skip.
1277
- None
1257
+ }
1258
+ _ => {
1259
+ // Ignore members that are not enabled on the command-line.
1260
+ if specs. iter ( ) . any ( |spec| spec. matches ( member_id) ) {
1261
+ // -p for a workspace member that is not the "current"
1262
+ // one.
1263
+ //
1264
+ // The odd behavior here is due to backwards
1265
+ // compatibility. `--features` and
1266
+ // `--no-default-features` used to only apply to the
1267
+ // "current" package. As an extension, this allows
1268
+ // member-name/feature-name to set member-specific
1269
+ // features, which should be backwards-compatible.
1270
+ let feats = CliFeatures {
1271
+ features : Rc :: new (
1272
+ member_specific_features
1273
+ . remove ( member. name ( ) . as_str ( ) )
1274
+ . unwrap_or_default ( ) ,
1275
+ ) ,
1276
+ uses_default_features : true ,
1277
+ all_features : cli_features. all_features ,
1278
+ } ;
1279
+ Some ( ( member, feats) )
1280
+ } else {
1281
+ // This member was not requested on the command-line, skip.
1282
+ None
1283
+ }
1278
1284
}
1279
1285
}
1280
- }
1281
- } ) ;
1282
- ms. collect ( )
1286
+ } )
1287
+ . collect ( ) ;
1288
+
1289
+ // If any member specific features were not removed while iterating over members
1290
+ // some features will be ignored.
1291
+ assert ! ( member_specific_features. is_empty( ) ) ;
1292
+
1293
+ ms
1283
1294
}
1284
1295
}
1285
1296
0 commit comments