@@ -76,24 +76,28 @@ pub(super) fn to_targets(
76
76
normalized_toml. bin . as_deref ( ) . unwrap_or_default ( ) ,
77
77
package_root,
78
78
edition,
79
+ warnings,
79
80
) ?) ;
80
81
81
82
targets. extend ( to_example_targets (
82
83
normalized_toml. example . as_deref ( ) . unwrap_or_default ( ) ,
83
84
package_root,
84
85
edition,
86
+ warnings,
85
87
) ?) ;
86
88
87
89
targets. extend ( to_test_targets (
88
90
normalized_toml. test . as_deref ( ) . unwrap_or_default ( ) ,
89
91
package_root,
90
92
edition,
93
+ warnings,
91
94
) ?) ;
92
95
93
96
targets. extend ( to_bench_targets (
94
97
normalized_toml. bench . as_deref ( ) . unwrap_or_default ( ) ,
95
98
package_root,
96
99
edition,
100
+ warnings,
97
101
) ?) ;
98
102
99
103
// processing the custom build script
@@ -259,7 +263,7 @@ fn to_lib_target(
259
263
} ;
260
264
261
265
let mut target = Target :: lib_target ( name_or_panic ( lib) , crate_types, path, edition) ;
262
- configure ( lib, & mut target) ?;
266
+ configure ( lib, & mut target, TARGET_KIND_HUMAN_LIB , warnings ) ?;
263
267
target. set_name_inferred ( original_lib. map_or ( true , |v| v. name . is_none ( ) ) ) ;
264
268
Ok ( Some ( target) )
265
269
}
@@ -348,6 +352,7 @@ fn to_bin_targets(
348
352
bins : & [ TomlBinTarget ] ,
349
353
package_root : & Path ,
350
354
edition : Edition ,
355
+ warnings : & mut Vec < String > ,
351
356
) -> CargoResult < Vec < Target > > {
352
357
// This loop performs basic checks on each of the TomlTarget in `bins`.
353
358
for bin in bins {
@@ -371,7 +376,7 @@ fn to_bin_targets(
371
376
edition,
372
377
) ;
373
378
374
- configure ( bin, & mut target) ?;
379
+ configure ( bin, & mut target, TARGET_KIND_HUMAN_BIN , warnings ) ?;
375
380
result. push ( target) ;
376
381
}
377
382
Ok ( result)
@@ -430,6 +435,7 @@ fn to_example_targets(
430
435
targets : & [ TomlExampleTarget ] ,
431
436
package_root : & Path ,
432
437
edition : Edition ,
438
+ warnings : & mut Vec < String > ,
433
439
) -> CargoResult < Vec < Target > > {
434
440
validate_unique_names ( & targets, TARGET_KIND_EXAMPLE ) ?;
435
441
@@ -448,7 +454,7 @@ fn to_example_targets(
448
454
toml. required_features . clone ( ) ,
449
455
edition,
450
456
) ;
451
- configure ( & toml, & mut target) ?;
457
+ configure ( & toml, & mut target, TARGET_KIND_HUMAN_EXAMPLE , warnings ) ?;
452
458
result. push ( target) ;
453
459
}
454
460
@@ -487,6 +493,7 @@ fn to_test_targets(
487
493
targets : & [ TomlTestTarget ] ,
488
494
package_root : & Path ,
489
495
edition : Edition ,
496
+ warnings : & mut Vec < String > ,
490
497
) -> CargoResult < Vec < Target > > {
491
498
validate_unique_names ( & targets, TARGET_KIND_TEST ) ?;
492
499
@@ -499,7 +506,7 @@ fn to_test_targets(
499
506
toml. required_features . clone ( ) ,
500
507
edition,
501
508
) ;
502
- configure ( & toml, & mut target) ?;
509
+ configure ( & toml, & mut target, TARGET_KIND_HUMAN_TEST , warnings ) ?;
503
510
result. push ( target) ;
504
511
}
505
512
Ok ( result)
@@ -554,6 +561,7 @@ fn to_bench_targets(
554
561
targets : & [ TomlBenchTarget ] ,
555
562
package_root : & Path ,
556
563
edition : Edition ,
564
+ warnings : & mut Vec < String > ,
557
565
) -> CargoResult < Vec < Target > > {
558
566
validate_unique_names ( & targets, TARGET_KIND_BENCH ) ?;
559
567
@@ -566,7 +574,7 @@ fn to_bench_targets(
566
574
toml. required_features . clone ( ) ,
567
575
edition,
568
576
) ;
569
- configure ( & toml, & mut target) ?;
577
+ configure ( & toml, & mut target, TARGET_KIND_HUMAN_BENCH , warnings ) ?;
570
578
result. push ( target) ;
571
579
}
572
580
@@ -892,7 +900,12 @@ fn validate_unique_names(targets: &[TomlTarget], target_kind: &str) -> CargoResu
892
900
Ok ( ( ) )
893
901
}
894
902
895
- fn configure ( toml : & TomlTarget , target : & mut Target ) -> CargoResult < ( ) > {
903
+ fn configure (
904
+ toml : & TomlTarget ,
905
+ target : & mut Target ,
906
+ target_kind_human : & str ,
907
+ warnings : & mut Vec < String > ,
908
+ ) -> CargoResult < ( ) > {
896
909
let t2 = target. clone ( ) ;
897
910
target
898
911
. set_tested ( toml. test . unwrap_or_else ( || t2. tested ( ) ) )
@@ -909,6 +922,10 @@ fn configure(toml: &TomlTarget, target: &mut Target) -> CargoResult<()> {
909
922
. set_for_host ( toml. proc_macro ( ) . unwrap_or_else ( || t2. for_host ( ) ) ) ;
910
923
911
924
if let Some ( edition) = toml. edition . clone ( ) {
925
+ let name = target. name ( ) ;
926
+ warnings. push ( format ! (
927
+ "`edition` is set on {target_kind_human} `{name}` which is deprecated"
928
+ ) ) ;
912
929
target. set_edition (
913
930
edition
914
931
. parse ( )
0 commit comments