1
- use std:: collections:: { BTreeSet , HashMap } ;
1
+ use std:: collections:: { BTreeSet , HashMap , HashSet } ;
2
2
use std:: env;
3
3
use std:: ffi:: { OsStr , OsString } ;
4
4
use std:: path:: PathBuf ;
@@ -398,14 +398,22 @@ fn target_runner(
398
398
return Ok ( Some ( ( path, v. args ) ) ) ;
399
399
}
400
400
401
+ let mut invalid_cfgs: HashSet < String > = HashSet :: default ( ) ;
401
402
// try target.'cfg(...)'.runner
402
403
let target_cfg = bcx. target_data . info ( kind) . cfg ( ) ;
403
404
let mut cfgs = bcx
404
405
. config
405
406
. target_cfgs ( ) ?
406
407
. iter ( )
407
408
. filter_map ( |( key, cfg) | cfg. runner . as_ref ( ) . map ( |runner| ( key, runner) ) )
408
- . filter ( |( key, _runner) | CfgExpr :: matches_key ( key, target_cfg) ) ;
409
+ . filter ( |( key, _runner) | {
410
+ if !CfgExpr :: is_valid_key ( key) {
411
+ invalid_cfgs. insert ( key. to_string ( ) ) ;
412
+ return false ;
413
+ }
414
+ CfgExpr :: matches_key ( key, target_cfg)
415
+ } ) ;
416
+
409
417
let matching_runner = cfgs. next ( ) ;
410
418
if let Some ( ( key, runner) ) = cfgs. next ( ) {
411
419
anyhow:: bail!(
@@ -418,6 +426,13 @@ fn target_runner(
418
426
runner. definition
419
427
) ;
420
428
}
429
+ if !invalid_cfgs. is_empty ( ) {
430
+ bcx. config . shell ( ) . warn ( format ! (
431
+ "invalid target configuration key{}: {}" ,
432
+ if invalid_cfgs. len( ) == 1 { "" } else { "s" } ,
433
+ invalid_cfgs. into_iter( ) . collect:: <Vec <_>>( ) . join( ", " )
434
+ ) ) ?;
435
+ }
421
436
Ok ( matching_runner. map ( |( _k, runner) | {
422
437
(
423
438
runner. val . path . clone ( ) . resolve_program ( bcx. config ) ,
0 commit comments