@@ -408,7 +408,10 @@ pub struct TomlProfile {
408408 pub panic : Option < String > ,
409409 pub overflow_checks : Option < bool > ,
410410 pub incremental : Option < bool > ,
411+ // `overrides` has been renamed to `package`, this should be removed when
412+ // stabilized.
411413 pub overrides : Option < BTreeMap < ProfilePackageSpec , TomlProfile > > ,
414+ pub package : Option < BTreeMap < ProfilePackageSpec , TomlProfile > > ,
412415 pub build_override : Option < Box < TomlProfile > > ,
413416 pub dir_name : Option < String > ,
414417 pub inherits : Option < String > ,
@@ -457,12 +460,23 @@ impl TomlProfile {
457460 ) -> CargoResult < ( ) > {
458461 if let Some ( ref profile) = self . build_override {
459462 features. require ( Feature :: profile_overrides ( ) ) ?;
460- profile. validate_override ( ) ?;
463+ profile. validate_override ( "build-override" ) ?;
461464 }
462465 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+ ) ;
463471 features. require ( Feature :: profile_overrides ( ) ) ?;
464472 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" ) ?;
466480 }
467481 }
468482
@@ -555,18 +569,21 @@ impl TomlProfile {
555569 Ok ( ( ) )
556570 }
557571
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" ) ;
561578 }
562579 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 )
564581 }
565582 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 )
567584 }
568585 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 )
570587 }
571588 Ok ( ( ) )
572589 }
@@ -612,6 +629,10 @@ impl TomlProfile {
612629 self . overrides = Some ( v. clone ( ) ) ;
613630 }
614631
632+ if let Some ( v) = & profile. package {
633+ self . package = Some ( v. clone ( ) ) ;
634+ }
635+
615636 if let Some ( v) = & profile. build_override {
616637 self . build_override = Some ( v. clone ( ) ) ;
617638 }
0 commit comments