Skip to content

Commit 9bb7c97

Browse files
committed
refactor(toml): Make rest of TomlManifest logic free functions
1 parent 89f8f5c commit 9bb7c97

File tree

4 files changed

+979
-989
lines changed

4 files changed

+979
-989
lines changed

src/cargo/core/features.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub const SEE_CHANNELS: &str =
168168
/// - Update [`CLI_VALUES`] to include the new edition.
169169
/// - Set [`LATEST_UNSTABLE`] to Some with the new edition.
170170
/// - Add an unstable feature to the [`features!`] macro invocation below for the new edition.
171-
/// - Gate on that new feature in [`TomlManifest::to_real_manifest`].
171+
/// - Gate on that new feature in [`toml::to_real_manifest`].
172172
/// - Update the shell completion files.
173173
/// - Update any failing tests (hopefully there are very few).
174174
/// - Update unstable.md to add a new section for this new edition (see [this example]).
@@ -195,7 +195,7 @@ pub const SEE_CHANNELS: &str =
195195
/// [`LATEST_STABLE`]: Edition::LATEST_STABLE
196196
/// [this example]: https://github.com/rust-lang/cargo/blob/3ebb5f15a940810f250b68821149387af583a79e/src/doc/src/reference/unstable.md?plain=1#L1238-L1264
197197
/// [`is_stable`]: Edition::is_stable
198-
/// [`TomlManifest::to_real_manifest`]: crate::util::toml::schema::TomlManifest::to_real_manifest
198+
/// [`toml::to_real_manifest`]: crate::util::toml::to_real_manifest
199199
/// [`features!`]: macro.features.html
200200
#[derive(Clone, Copy, Debug, Hash, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)]
201201
pub enum Edition {

src/cargo/core/package.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::util::network::http::http_handle_and_timeout;
3131
use crate::util::network::http::HttpTimeout;
3232
use crate::util::network::retry::{Retry, RetryResult};
3333
use crate::util::network::sleep::SleepTracker;
34+
use crate::util::toml::prepare_for_publish;
3435
use crate::util::RustVersion;
3536
use crate::util::{self, internal, Config, Progress, ProgressStyle};
3637

@@ -197,10 +198,7 @@ impl Package {
197198
}
198199

199200
pub fn to_registry_toml(&self, ws: &Workspace<'_>) -> CargoResult<String> {
200-
let manifest = self
201-
.manifest()
202-
.original()
203-
.prepare_for_publish(ws, self.root())?;
201+
let manifest = prepare_for_publish(self.manifest().original(), ws, self.root())?;
204202
let toml = toml::to_string_pretty(&manifest)?;
205203
Ok(format!("{}\n{}", MANIFEST_PREAMBLE, toml))
206204
}

src/cargo/ops/cargo_package.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::sources::PathSource;
1616
use crate::util::cache_lock::CacheLockMode;
1717
use crate::util::config::JobsConfig;
1818
use crate::util::errors::CargoResult;
19-
use crate::util::toml::schema::TomlManifest;
19+
use crate::util::toml::{prepare_for_publish, to_real_manifest};
2020
use crate::util::{self, human_readable_bytes, restricted_names, Config, FileLock};
2121
use crate::{drop_println, ops};
2222
use anyhow::Context as _;
@@ -454,14 +454,11 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
454454
let orig_resolve = ops::load_pkg_lockfile(ws)?;
455455

456456
// Convert Package -> TomlManifest -> Manifest -> Package
457-
let toml_manifest = orig_pkg
458-
.manifest()
459-
.original()
460-
.prepare_for_publish(ws, orig_pkg.root())?;
457+
let toml_manifest = prepare_for_publish(orig_pkg.manifest().original(), ws, orig_pkg.root())?;
461458
let package_root = orig_pkg.root();
462459
let source_id = orig_pkg.package_id().source_id();
463460
let (manifest, _nested_paths) =
464-
TomlManifest::to_real_manifest(toml_manifest, false, source_id, package_root, config)?;
461+
to_real_manifest(toml_manifest, false, source_id, package_root, config)?;
465462
let new_pkg = Package::new(manifest, orig_pkg.manifest_path());
466463

467464
let max_rust_version = new_pkg.rust_version().cloned();

0 commit comments

Comments
 (0)