@@ -503,7 +503,7 @@ impl schema::TomlManifest {
503
503
let version = package
504
504
. version
505
505
. clone ( )
506
- . map ( |version| version . inherit_with ( "version" , || inherit ( ) ?. version ( ) ) )
506
+ . map ( |version| field_inherit_with ( version , "version" , || inherit ( ) ?. version ( ) ) )
507
507
. transpose ( ) ?;
508
508
509
509
package. version = version. clone ( ) . map ( schema:: InheritableField :: Value ) ;
@@ -517,8 +517,7 @@ impl schema::TomlManifest {
517
517
) ;
518
518
519
519
let edition = if let Some ( edition) = package. edition . clone ( ) {
520
- let edition: Edition = edition
521
- . inherit_with ( "edition" , || inherit ( ) ?. edition ( ) ) ?
520
+ let edition: Edition = field_inherit_with ( edition, "edition" , || inherit ( ) ?. edition ( ) ) ?
522
521
. parse ( )
523
522
. with_context ( || "failed to parse the `edition` key" ) ?;
524
523
package. edition = Some ( schema:: InheritableField :: Value ( edition. to_string ( ) ) ) ;
@@ -543,9 +542,9 @@ impl schema::TomlManifest {
543
542
}
544
543
545
544
let rust_version = if let Some ( rust_version) = & package. rust_version {
546
- let rust_version = rust_version
547
- . clone ( )
548
- . inherit_with ( "rust_version" , || inherit ( ) ? . rust_version ( ) ) ?;
545
+ let rust_version = field_inherit_with ( rust_version. clone ( ) , "rust_version" , || {
546
+ inherit ( ) ? . rust_version ( )
547
+ } ) ?;
549
548
let req = rust_version. to_caret_req ( ) ;
550
549
if let Some ( first_version) = edition. first_version ( ) {
551
550
let unsupported =
@@ -800,13 +799,13 @@ impl schema::TomlManifest {
800
799
let exclude = package
801
800
. exclude
802
801
. clone ( )
803
- . map ( |mw| mw . inherit_with ( "exclude" , || inherit ( ) ?. exclude ( ) ) )
802
+ . map ( |mw| field_inherit_with ( mw , "exclude" , || inherit ( ) ?. exclude ( ) ) )
804
803
. transpose ( ) ?
805
804
. unwrap_or_default ( ) ;
806
805
let include = package
807
806
. include
808
807
. clone ( )
809
- . map ( |mw| mw . inherit_with ( "include" , || inherit ( ) ?. include ( ) ) )
808
+ . map ( |mw| field_inherit_with ( mw , "include" , || inherit ( ) ?. include ( ) ) )
810
809
. transpose ( ) ?
811
810
. unwrap_or_default ( ) ;
812
811
let empty_features = BTreeMap :: new ( ) ;
@@ -833,70 +832,72 @@ impl schema::TomlManifest {
833
832
description : package
834
833
. description
835
834
. clone ( )
836
- . map ( |mw| mw . inherit_with ( "description" , || inherit ( ) ?. description ( ) ) )
835
+ . map ( |mw| field_inherit_with ( mw , "description" , || inherit ( ) ?. description ( ) ) )
837
836
. transpose ( ) ?,
838
837
homepage : package
839
838
. homepage
840
839
. clone ( )
841
- . map ( |mw| mw . inherit_with ( "homepage" , || inherit ( ) ?. homepage ( ) ) )
840
+ . map ( |mw| field_inherit_with ( mw , "homepage" , || inherit ( ) ?. homepage ( ) ) )
842
841
. transpose ( ) ?,
843
842
documentation : package
844
843
. documentation
845
844
. clone ( )
846
- . map ( |mw| mw . inherit_with ( "documentation" , || inherit ( ) ?. documentation ( ) ) )
845
+ . map ( |mw| field_inherit_with ( mw , "documentation" , || inherit ( ) ?. documentation ( ) ) )
847
846
. transpose ( ) ?,
848
847
readme : readme_for_package (
849
848
package_root,
850
849
package
851
850
. readme
852
851
. clone ( )
853
- . map ( |mw| mw . inherit_with ( "readme" , || inherit ( ) ?. readme ( package_root) ) )
852
+ . map ( |mw| field_inherit_with ( mw , "readme" , || inherit ( ) ?. readme ( package_root) ) )
854
853
. transpose ( ) ?
855
854
. as_ref ( ) ,
856
855
) ,
857
856
authors : package
858
857
. authors
859
858
. clone ( )
860
- . map ( |mw| mw . inherit_with ( "authors" , || inherit ( ) ?. authors ( ) ) )
859
+ . map ( |mw| field_inherit_with ( mw , "authors" , || inherit ( ) ?. authors ( ) ) )
861
860
. transpose ( ) ?
862
861
. unwrap_or_default ( ) ,
863
862
license : package
864
863
. license
865
864
. clone ( )
866
- . map ( |mw| mw . inherit_with ( "license" , || inherit ( ) ?. license ( ) ) )
865
+ . map ( |mw| field_inherit_with ( mw , "license" , || inherit ( ) ?. license ( ) ) )
867
866
. transpose ( ) ?,
868
867
license_file : package
869
868
. license_file
870
869
. clone ( )
871
- . map ( |mw| mw. inherit_with ( "license" , || inherit ( ) ?. license_file ( package_root) ) )
870
+ . map ( |mw| {
871
+ field_inherit_with ( mw, "license" , || inherit ( ) ?. license_file ( package_root) )
872
+ } )
872
873
. transpose ( ) ?,
873
874
repository : package
874
875
. repository
875
876
. clone ( )
876
- . map ( |mw| mw . inherit_with ( "repository" , || inherit ( ) ?. repository ( ) ) )
877
+ . map ( |mw| field_inherit_with ( mw , "repository" , || inherit ( ) ?. repository ( ) ) )
877
878
. transpose ( ) ?,
878
879
keywords : package
879
880
. keywords
880
881
. clone ( )
881
- . map ( |mw| mw . inherit_with ( "keywords" , || inherit ( ) ?. keywords ( ) ) )
882
+ . map ( |mw| field_inherit_with ( mw , "keywords" , || inherit ( ) ?. keywords ( ) ) )
882
883
. transpose ( ) ?
883
884
. unwrap_or_default ( ) ,
884
885
categories : package
885
886
. categories
886
887
. clone ( )
887
- . map ( |mw| mw . inherit_with ( "categories" , || inherit ( ) ?. categories ( ) ) )
888
+ . map ( |mw| field_inherit_with ( mw , "categories" , || inherit ( ) ?. categories ( ) ) )
888
889
. transpose ( ) ?
889
890
. unwrap_or_default ( ) ,
890
891
badges : me
891
892
. badges
892
893
. clone ( )
893
- . map ( |mw| mw . inherit_with ( "badges" , || inherit ( ) ?. badges ( ) ) )
894
+ . map ( |mw| field_inherit_with ( mw , "badges" , || inherit ( ) ?. badges ( ) ) )
894
895
. transpose ( ) ?
895
896
. unwrap_or_default ( ) ,
896
897
links : package. links . clone ( ) ,
897
898
rust_version : package
898
899
. rust_version
899
- . map ( |mw| mw . inherit_with ( "rust-version" , || inherit ( ) ?. rust_version ( ) ) )
900
+ . map ( |mw| field_inherit_with ( mw , "rust-version" , || inherit ( ) ?. rust_version ( ) ) )
900
901
. transpose ( ) ?,
901
902
} ;
902
903
package. description = metadata
@@ -958,9 +959,7 @@ impl schema::TomlManifest {
958
959
}
959
960
960
961
let publish = package. publish . clone ( ) . map ( |publish| {
961
- publish
962
- . inherit_with ( "publish" , || inherit ( ) ?. publish ( ) )
963
- . unwrap ( )
962
+ field_inherit_with ( publish, "publish" , || inherit ( ) ?. publish ( ) ) . unwrap ( )
964
963
} ) ;
965
964
966
965
package. publish = publish. clone ( ) . map ( |p| schema:: InheritableField :: Value ( p) ) ;
@@ -1559,21 +1558,19 @@ impl InheritableFields {
1559
1558
}
1560
1559
}
1561
1560
1562
- impl < T > schema:: InheritableField < T > {
1563
- fn inherit_with < ' a > (
1564
- self ,
1565
- label : & str ,
1566
- get_ws_inheritable : impl FnOnce ( ) -> CargoResult < T > ,
1567
- ) -> CargoResult < T > {
1568
- match self {
1561
+ fn field_inherit_with < ' a , T > (
1562
+ field : schema:: InheritableField < T > ,
1563
+ label : & str ,
1564
+ get_ws_inheritable : impl FnOnce ( ) -> CargoResult < T > ,
1565
+ ) -> CargoResult < T > {
1566
+ match field {
1569
1567
schema:: InheritableField :: Value ( value) => Ok ( value) ,
1570
1568
schema:: InheritableField :: Inherit ( _) => get_ws_inheritable ( ) . with_context ( || {
1571
1569
format ! (
1572
1570
"error inheriting `{label}` from workspace root manifest's `workspace.package.{label}`" ,
1573
1571
)
1574
1572
} ) ,
1575
1573
}
1576
- }
1577
1574
}
1578
1575
1579
1576
impl schema:: InheritableLints {
0 commit comments