@@ -408,7 +408,10 @@ pub struct TomlProfile {
408
408
pub panic : Option < String > ,
409
409
pub overflow_checks : Option < bool > ,
410
410
pub incremental : Option < bool > ,
411
+ // `overrides` has been renamed to `package`, this should be removed when
412
+ // stabilized.
411
413
pub overrides : Option < BTreeMap < ProfilePackageSpec , TomlProfile > > ,
414
+ pub package : Option < BTreeMap < ProfilePackageSpec , TomlProfile > > ,
412
415
pub build_override : Option < Box < TomlProfile > > ,
413
416
pub dir_name : Option < String > ,
414
417
pub inherits : Option < String > ,
@@ -457,12 +460,23 @@ impl TomlProfile {
457
460
) -> CargoResult < ( ) > {
458
461
if let Some ( ref profile) = self . build_override {
459
462
features. require ( Feature :: profile_overrides ( ) ) ?;
460
- profile. validate_override ( ) ?;
463
+ profile. validate_override ( "build-override" ) ?;
461
464
}
462
465
if let Some ( ref override_map) = self . overrides {
466
+ warnings. push (
467
+ "profile key `overrides` has been renamed to `package`, \
468
+ please update the manifest to the new key name"
469
+ . to_string ( ) ,
470
+ ) ;
463
471
features. require ( Feature :: profile_overrides ( ) ) ?;
464
472
for profile in override_map. values ( ) {
465
- profile. validate_override ( ) ?;
473
+ profile. validate_override ( "package" ) ?;
474
+ }
475
+ }
476
+ if let Some ( ref packages) = self . package {
477
+ features. require ( Feature :: profile_overrides ( ) ) ?;
478
+ for profile in packages. values ( ) {
479
+ profile. validate_override ( "package" ) ?;
466
480
}
467
481
}
468
482
@@ -555,18 +569,21 @@ impl TomlProfile {
555
569
Ok ( ( ) )
556
570
}
557
571
558
- fn validate_override ( & self ) -> CargoResult < ( ) > {
559
- if self . overrides . is_some ( ) || self . build_override . is_some ( ) {
560
- bail ! ( "Profile overrides cannot be nested." ) ;
572
+ fn validate_override ( & self , which : & str ) -> CargoResult < ( ) > {
573
+ if self . overrides . is_some ( ) || self . package . is_some ( ) {
574
+ bail ! ( "package-specific profiles cannot be nested" ) ;
575
+ }
576
+ if self . build_override . is_some ( ) {
577
+ bail ! ( "build-override profiles cannot be nested" ) ;
561
578
}
562
579
if self . panic . is_some ( ) {
563
- bail ! ( "`panic` may not be specified in a profile override." )
580
+ bail ! ( "`panic` may not be specified in a `{}` profile" , which )
564
581
}
565
582
if self . lto . is_some ( ) {
566
- bail ! ( "`lto` may not be specified in a profile override." )
583
+ bail ! ( "`lto` may not be specified in a `{}` profile" , which )
567
584
}
568
585
if self . rpath . is_some ( ) {
569
- bail ! ( "`rpath` may not be specified in a profile override." )
586
+ bail ! ( "`rpath` may not be specified in a `{}` profile" , which )
570
587
}
571
588
Ok ( ( ) )
572
589
}
@@ -612,6 +629,10 @@ impl TomlProfile {
612
629
self . overrides = Some ( v. clone ( ) ) ;
613
630
}
614
631
632
+ if let Some ( v) = & profile. package {
633
+ self . package = Some ( v. clone ( ) ) ;
634
+ }
635
+
615
636
if let Some ( v) = & profile. build_override {
616
637
self . build_override = Some ( v. clone ( ) ) ;
617
638
}
0 commit comments