File tree 1 file changed +19
-6
lines changed
1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -253,12 +253,25 @@ fn get_targets_root_only(targets: &mut BTreeSet<Target>) -> Result<(), io::Error
253
253
let workspace_root_path = PathBuf :: from ( & metadata. workspace_root ) . canonicalize ( ) ?;
254
254
let in_workspace_root = workspace_root_path == current_dir;
255
255
256
- for package in metadata. packages {
257
- if in_workspace_root || PathBuf :: from ( & package. manifest_path ) == current_dir_manifest {
258
- for target in package. targets {
259
- targets. insert ( Target :: from_target ( & target) ) ;
260
- }
261
- }
256
+ let package_targets = match metadata. packages . len ( ) {
257
+ 1 => metadata. packages . into_iter ( ) . next ( ) . unwrap ( ) . targets ,
258
+ _ => metadata
259
+ . packages
260
+ . into_iter ( )
261
+ . filter ( |p| {
262
+ in_workspace_root
263
+ || PathBuf :: from ( & p. manifest_path )
264
+ . canonicalize ( )
265
+ . unwrap_or_default ( )
266
+ == current_dir_manifest
267
+ } )
268
+ . map ( |p| p. targets )
269
+ . flatten ( )
270
+ . collect ( ) ,
271
+ } ;
272
+
273
+ for target in package_targets {
274
+ targets. insert ( Target :: from_target ( & target) ) ;
262
275
}
263
276
264
277
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments