@@ -23,9 +23,7 @@ use crate::sources::{PathSource, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
23
23
use crate :: util:: errors:: { CargoResult , ManifestError } ;
24
24
use crate :: util:: interning:: InternedString ;
25
25
use crate :: util:: lev_distance;
26
- use crate :: util:: toml:: {
27
- read_manifest, readme_for_project, StringOrBool , TomlDependency , TomlProfiles , VecStringOrBool ,
28
- } ;
26
+ use crate :: util:: toml:: { read_manifest, InheritableFields , TomlDependency , TomlProfiles } ;
29
27
use crate :: util:: { config:: ConfigRelativePath , Config , Filesystem , IntoUrl } ;
30
28
use cargo_util:: paths;
31
29
use cargo_util:: paths:: normalize_path;
@@ -1644,213 +1642,6 @@ impl WorkspaceRootConfig {
1644
1642
}
1645
1643
}
1646
1644
1647
- /// A group of fields that are inheritable by members of the workspace
1648
- #[ derive( Clone , Debug , Default ) ]
1649
- pub struct InheritableFields {
1650
- dependencies : Option < BTreeMap < String , TomlDependency > > ,
1651
- version : Option < semver:: Version > ,
1652
- authors : Option < Vec < String > > ,
1653
- description : Option < String > ,
1654
- homepage : Option < String > ,
1655
- documentation : Option < String > ,
1656
- readme : Option < StringOrBool > ,
1657
- keywords : Option < Vec < String > > ,
1658
- categories : Option < Vec < String > > ,
1659
- license : Option < String > ,
1660
- license_file : Option < String > ,
1661
- repository : Option < String > ,
1662
- publish : Option < VecStringOrBool > ,
1663
- edition : Option < String > ,
1664
- badges : Option < BTreeMap < String , BTreeMap < String , String > > > ,
1665
- rust_version : Option < String > ,
1666
- ws_root : PathBuf ,
1667
- }
1668
-
1669
- impl InheritableFields {
1670
- pub fn new (
1671
- dependencies : Option < BTreeMap < String , TomlDependency > > ,
1672
- version : Option < semver:: Version > ,
1673
- authors : Option < Vec < String > > ,
1674
- description : Option < String > ,
1675
- homepage : Option < String > ,
1676
- documentation : Option < String > ,
1677
- readme : Option < StringOrBool > ,
1678
- keywords : Option < Vec < String > > ,
1679
- categories : Option < Vec < String > > ,
1680
- license : Option < String > ,
1681
- license_file : Option < String > ,
1682
- repository : Option < String > ,
1683
- publish : Option < VecStringOrBool > ,
1684
- edition : Option < String > ,
1685
- badges : Option < BTreeMap < String , BTreeMap < String , String > > > ,
1686
- rust_version : Option < String > ,
1687
- ws_root : PathBuf ,
1688
- ) -> InheritableFields {
1689
- Self {
1690
- dependencies,
1691
- version,
1692
- authors,
1693
- description,
1694
- homepage,
1695
- documentation,
1696
- readme,
1697
- keywords,
1698
- categories,
1699
- license,
1700
- license_file,
1701
- repository,
1702
- publish,
1703
- edition,
1704
- badges,
1705
- rust_version,
1706
- ws_root,
1707
- }
1708
- }
1709
-
1710
- pub fn dependencies ( & self ) -> CargoResult < BTreeMap < String , TomlDependency > > {
1711
- self . dependencies . clone ( ) . map_or (
1712
- Err ( anyhow ! ( "`workspace.dependencies` was not defined" ) ) ,
1713
- |d| Ok ( d) ,
1714
- )
1715
- }
1716
-
1717
- pub fn get_dependency ( & self , name : & str ) -> CargoResult < TomlDependency > {
1718
- self . dependencies . clone ( ) . map_or (
1719
- Err ( anyhow ! ( "`workspace.dependencies` was not defined" ) ) ,
1720
- |deps| {
1721
- deps. get ( name) . map_or (
1722
- Err ( anyhow ! (
1723
- "`dependency.{}` was not found in `workspace.dependencies`" ,
1724
- name
1725
- ) ) ,
1726
- |dep| Ok ( dep. clone ( ) ) ,
1727
- )
1728
- } ,
1729
- )
1730
- }
1731
-
1732
- pub fn version ( & self ) -> CargoResult < semver:: Version > {
1733
- self . version
1734
- . clone ( )
1735
- . map_or ( Err ( anyhow ! ( "`workspace.version` was not defined" ) ) , |d| {
1736
- Ok ( d)
1737
- } )
1738
- }
1739
-
1740
- pub fn authors ( & self ) -> CargoResult < Vec < String > > {
1741
- self . authors
1742
- . clone ( )
1743
- . map_or ( Err ( anyhow ! ( "`workspace.authors` was not defined" ) ) , |d| {
1744
- Ok ( d)
1745
- } )
1746
- }
1747
-
1748
- pub fn description ( & self ) -> CargoResult < String > {
1749
- self . description . clone ( ) . map_or (
1750
- Err ( anyhow ! ( "`workspace.description` was not defined" ) ) ,
1751
- |d| Ok ( d) ,
1752
- )
1753
- }
1754
-
1755
- pub fn homepage ( & self ) -> CargoResult < String > {
1756
- self . homepage
1757
- . clone ( )
1758
- . map_or ( Err ( anyhow ! ( "`workspace.homepage` was not defined" ) ) , |d| {
1759
- Ok ( d)
1760
- } )
1761
- }
1762
-
1763
- pub fn documentation ( & self ) -> CargoResult < String > {
1764
- self . documentation . clone ( ) . map_or (
1765
- Err ( anyhow ! ( "`workspace.documentation` was not defined" ) ) ,
1766
- |d| Ok ( d) ,
1767
- )
1768
- }
1769
-
1770
- pub fn readme ( & self , package_root : & Path ) -> CargoResult < StringOrBool > {
1771
- readme_for_project ( self . ws_root . as_path ( ) , self . readme . clone ( ) ) . map_or (
1772
- Err ( anyhow ! ( "`workspace.readme` was not defined" ) ) ,
1773
- |readme| {
1774
- let rel_path =
1775
- resolve_relative_path ( "readme" , & self . ws_root , package_root, & readme) ?;
1776
- Ok ( StringOrBool :: String ( rel_path) )
1777
- } ,
1778
- )
1779
- }
1780
-
1781
- pub fn keywords ( & self ) -> CargoResult < Vec < String > > {
1782
- self . keywords
1783
- . clone ( )
1784
- . map_or ( Err ( anyhow ! ( "`workspace.keywords` was not defined" ) ) , |d| {
1785
- Ok ( d)
1786
- } )
1787
- }
1788
-
1789
- pub fn categories ( & self ) -> CargoResult < Vec < String > > {
1790
- self . categories . clone ( ) . map_or (
1791
- Err ( anyhow ! ( "`workspace.categories` was not defined" ) ) ,
1792
- |d| Ok ( d) ,
1793
- )
1794
- }
1795
-
1796
- pub fn license ( & self ) -> CargoResult < String > {
1797
- self . license
1798
- . clone ( )
1799
- . map_or ( Err ( anyhow ! ( "`workspace.license` was not defined" ) ) , |d| {
1800
- Ok ( d)
1801
- } )
1802
- }
1803
-
1804
- pub fn license_file ( & self , package_root : & Path ) -> CargoResult < String > {
1805
- self . license_file . clone ( ) . map_or (
1806
- Err ( anyhow ! ( "`workspace.license_file` was not defined" ) ) ,
1807
- |d| resolve_relative_path ( "license-file" , & self . ws_root , package_root, & d) ,
1808
- )
1809
- }
1810
-
1811
- pub fn repository ( & self ) -> CargoResult < String > {
1812
- self . repository . clone ( ) . map_or (
1813
- Err ( anyhow ! ( "`workspace.repository` was not defined" ) ) ,
1814
- |d| Ok ( d) ,
1815
- )
1816
- }
1817
-
1818
- pub fn publish ( & self ) -> CargoResult < VecStringOrBool > {
1819
- self . publish
1820
- . clone ( )
1821
- . map_or ( Err ( anyhow ! ( "`workspace.publish` was not defined" ) ) , |d| {
1822
- Ok ( d)
1823
- } )
1824
- }
1825
-
1826
- pub fn edition ( & self ) -> CargoResult < String > {
1827
- self . edition
1828
- . clone ( )
1829
- . map_or ( Err ( anyhow ! ( "`workspace.edition` was not defined" ) ) , |d| {
1830
- Ok ( d)
1831
- } )
1832
- }
1833
-
1834
- pub fn rust_version ( & self ) -> CargoResult < String > {
1835
- self . rust_version . clone ( ) . map_or (
1836
- Err ( anyhow ! ( "`workspace.rust-version` was not defined" ) ) ,
1837
- |d| Ok ( d) ,
1838
- )
1839
- }
1840
-
1841
- pub fn badges ( & self ) -> CargoResult < BTreeMap < String , BTreeMap < String , String > > > {
1842
- self . badges
1843
- . clone ( )
1844
- . map_or ( Err ( anyhow ! ( "`workspace.badges` was not defined" ) ) , |d| {
1845
- Ok ( d)
1846
- } )
1847
- }
1848
-
1849
- pub fn ws_root ( & self ) -> & PathBuf {
1850
- & self . ws_root
1851
- }
1852
- }
1853
-
1854
1645
pub fn resolve_relative_path (
1855
1646
label : & str ,
1856
1647
old_root : & Path ,
0 commit comments