Skip to content

Commit 90e2995

Browse files
committed
refactor(toml): Reduce visibility
This will make it clearer what each piece of logic belongs to
1 parent e3eda30 commit 90e2995

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/cargo/util/toml/embedded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const DEFAULT_EDITION: crate::core::features::Edition =
88
crate::core::features::Edition::LATEST_STABLE;
99
const AUTO_FIELDS: &[&str] = &["autobins", "autoexamples", "autotests", "autobenches"];
1010

11-
pub fn expand_manifest(
11+
pub(super) fn expand_manifest(
1212
content: &str,
1313
path: &std::path::Path,
1414
config: &Config,
@@ -329,7 +329,7 @@ impl DocFragment {
329329
}
330330

331331
#[derive(Clone, Copy, PartialEq, Debug)]
332-
pub enum CommentKind {
332+
enum CommentKind {
333333
Line,
334334
Block,
335335
}

src/cargo/util/toml/mod.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::util::{
2828
RustVersion,
2929
};
3030

31-
pub mod embedded;
31+
mod embedded;
3232
pub mod schema;
3333
mod targets;
3434
use self::targets::targets;
@@ -1446,7 +1446,7 @@ fn inheritable_from_path(
14461446
}
14471447

14481448
/// Returns the name of the README file for a [`schema::TomlPackage`].
1449-
pub fn readme_for_package(
1449+
fn readme_for_package(
14501450
package_root: &Path,
14511451
readme: Option<&schema::StringOrBool>,
14521452
) -> Option<String> {
@@ -1505,7 +1505,7 @@ macro_rules! inheritable_field_getter {
15051505
( $(($key:literal, $field:ident -> $ret:ty),)* ) => (
15061506
$(
15071507
#[doc = concat!("Gets the field `workspace.", $key, "`.")]
1508-
pub fn $field(&self) -> CargoResult<$ret> {
1508+
fn $field(&self) -> CargoResult<$ret> {
15091509
let Some(val) = &self.$field else {
15101510
bail!("`workspace.{}` was not defined", $key);
15111511
};
@@ -1518,7 +1518,6 @@ macro_rules! inheritable_field_getter {
15181518
impl schema::InheritableFields {
15191519
inheritable_field_getter! {
15201520
// Please keep this list lexicographically ordered.
1521-
("dependencies", dependencies -> BTreeMap<String, schema::TomlDependency>),
15221521
("lints", lints -> schema::TomlLints),
15231522
("package.authors", authors -> Vec<String>),
15241523
("package.badges", badges -> BTreeMap<String, BTreeMap<String, String>>),
@@ -1538,7 +1537,7 @@ impl schema::InheritableFields {
15381537
}
15391538

15401539
/// Gets a workspace dependency with the `name`.
1541-
pub fn get_dependency(
1540+
fn get_dependency(
15421541
&self,
15431542
name: &str,
15441543
package_root: &Path,
@@ -1557,41 +1556,41 @@ impl schema::InheritableFields {
15571556
}
15581557

15591558
/// Gets the field `workspace.package.license-file`.
1560-
pub fn license_file(&self, package_root: &Path) -> CargoResult<String> {
1559+
fn license_file(&self, package_root: &Path) -> CargoResult<String> {
15611560
let Some(license_file) = &self.license_file else {
15621561
bail!("`workspace.package.license-file` was not defined");
15631562
};
15641563
resolve_relative_path("license-file", &self.ws_root, package_root, license_file)
15651564
}
15661565

15671566
/// Gets the field `workspace.package.readme`.
1568-
pub fn readme(&self, package_root: &Path) -> CargoResult<schema::StringOrBool> {
1567+
fn readme(&self, package_root: &Path) -> CargoResult<schema::StringOrBool> {
15691568
let Some(readme) = readme_for_package(self.ws_root.as_path(), self.readme.as_ref()) else {
15701569
bail!("`workspace.package.readme` was not defined");
15711570
};
15721571
resolve_relative_path("readme", &self.ws_root, package_root, &readme)
15731572
.map(schema::StringOrBool::String)
15741573
}
15751574

1576-
pub fn ws_root(&self) -> &PathBuf {
1575+
fn ws_root(&self) -> &PathBuf {
15771576
&self.ws_root
15781577
}
15791578

1580-
pub fn update_deps(&mut self, deps: Option<BTreeMap<String, schema::TomlDependency>>) {
1579+
fn update_deps(&mut self, deps: Option<BTreeMap<String, schema::TomlDependency>>) {
15811580
self.dependencies = deps;
15821581
}
15831582

1584-
pub fn update_lints(&mut self, lints: Option<schema::TomlLints>) {
1583+
fn update_lints(&mut self, lints: Option<schema::TomlLints>) {
15851584
self.lints = lints;
15861585
}
15871586

1588-
pub fn update_ws_path(&mut self, ws_root: PathBuf) {
1587+
fn update_ws_path(&mut self, ws_root: PathBuf) {
15891588
self.ws_root = ws_root;
15901589
}
15911590
}
15921591

15931592
impl schema::TomlPackage {
1594-
pub fn to_package_id(&self, source_id: SourceId, version: semver::Version) -> PackageId {
1593+
fn to_package_id(&self, source_id: SourceId, version: semver::Version) -> PackageId {
15951594
PackageId::pure(self.name.as_str().into(), version, source_id)
15961595
}
15971596
}
@@ -2084,7 +2083,7 @@ impl schema::TomlProfiles {
20842083
///
20852084
/// It's a bit unfortunate both `-Z` flags and `cargo-features` are required,
20862085
/// because profiles can now be set in either `Cargo.toml` or `config.toml`.
2087-
pub fn validate(
2086+
fn validate(
20882087
&self,
20892088
cli_unstable: &CliUnstable,
20902089
features: &Features,

src/cargo/util/toml/targets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DEFAULT_BENCH_DIR_NAME: &'static str = "benches";
3131
const DEFAULT_EXAMPLE_DIR_NAME: &'static str = "examples";
3232
const DEFAULT_BIN_DIR_NAME: &'static str = "bin";
3333

34-
pub fn targets(
34+
pub(super) fn targets(
3535
features: &Features,
3636
manifest: &TomlManifest,
3737
package_name: &str,

0 commit comments

Comments
 (0)