@@ -359,11 +359,6 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
359
359
}
360
360
} ;
361
361
362
- let bin_target = match scope {
363
- FlycheckScope :: Binary { ref bin_target, .. } => Some ( bin_target. clone ( ) ) ,
364
- _ => None ,
365
- } ;
366
-
367
362
let crate_root_paths: Vec < _ > = crate_ids
368
363
. iter ( )
369
364
. filter_map ( |& crate_id| {
@@ -401,7 +396,22 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
401
396
let pkg = cargo[ target] . package ;
402
397
let pkg_name = cargo[ pkg] . name . clone ( ) ;
403
398
Some ( flycheck:: PackageSpecifier :: Cargo {
404
- bin_target : bin_target. clone ( ) ,
399
+ // This is very hacky. But we are iterating through a lot of
400
+ // crates, many of which are reverse deps, and it doesn't make
401
+ // sense to attach --bin XXX to some random downstream dep in a
402
+ // different workspace.
403
+ bin_target : match & scope {
404
+ FlycheckScope :: Binary {
405
+ package_name : bin_pkg_name,
406
+ bin_target,
407
+ ..
408
+ } if bin_pkg_name. as_ref ( ) == Some ( & pkg_name)
409
+ && bin_target. name ( ) == & cargo[ target] . name =>
410
+ {
411
+ Some ( bin_target. clone ( ) )
412
+ }
413
+ _ => None ,
414
+ } ,
405
415
cargo_canonical_name : pkg_name,
406
416
} )
407
417
} )
0 commit comments