diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs index 1ff2aad1944..0c5c0231125 100644 --- a/src/bin/cargo/commands/add.rs +++ b/src/bin/cargo/commands/add.rs @@ -6,10 +6,10 @@ use cargo::core::FeatureValue; use cargo::ops::cargo_add::add; use cargo::ops::cargo_add::AddOptions; use cargo::ops::cargo_add::DepOp; -use cargo::ops::cargo_add::DepTable; use cargo::ops::resolve_ws; use cargo::util::command_prelude::*; use cargo::util::interning::InternedString; +use cargo::util::toml_mut::manifest::DepTable; use cargo::CargoResult; pub fn cli() -> clap::Command<'static> { diff --git a/src/cargo/ops/cargo_add/crate_spec.rs b/src/cargo/ops/cargo_add/crate_spec.rs index 33b4957f758..f07e2fae59b 100644 --- a/src/cargo/ops/cargo_add/crate_spec.rs +++ b/src/cargo/ops/cargo_add/crate_spec.rs @@ -3,7 +3,7 @@ use anyhow::Context as _; use super::Dependency; -use super::RegistrySource; +use crate::util::toml_mut::dependency::RegistrySource; use crate::util::validate_package_name; use crate::CargoResult; diff --git a/src/cargo/ops/cargo_add/mod.rs b/src/cargo/ops/cargo_add/mod.rs index 48963284e0e..31d3a97fe2a 100644 --- a/src/cargo/ops/cargo_add/mod.rs +++ b/src/cargo/ops/cargo_add/mod.rs @@ -1,8 +1,6 @@ //! Core of cargo-add command mod crate_spec; -mod dependency; -mod manifest; use std::collections::BTreeMap; use std::collections::BTreeSet; @@ -26,18 +24,17 @@ use crate::core::Registry; use crate::core::Shell; use crate::core::Summary; use crate::core::Workspace; +use crate::util::toml_mut::dependency::Dependency; +use crate::util::toml_mut::dependency::GitSource; +use crate::util::toml_mut::dependency::MaybeWorkspace; +use crate::util::toml_mut::dependency::PathSource; +use crate::util::toml_mut::dependency::Source; +use crate::util::toml_mut::dependency::WorkspaceSource; +use crate::util::toml_mut::manifest::DepTable; +use crate::util::toml_mut::manifest::LocalManifest; use crate::CargoResult; use crate::Config; use crate_spec::CrateSpec; -use dependency::Dependency; -use dependency::GitSource; -use dependency::PathSource; -use dependency::RegistrySource; -use dependency::Source; -use manifest::LocalManifest; - -use crate::ops::cargo_add::dependency::{MaybeWorkspace, WorkspaceSource}; -pub use manifest::DepTable; /// Information on what dependencies should be added #[derive(Clone, Debug)] diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 2cfea54d2ea..28f685c209a 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -57,6 +57,7 @@ pub mod rustc; mod semver_ext; pub mod to_semver; pub mod toml; +pub mod toml_mut; mod vcs; mod workspace; diff --git a/src/cargo/ops/cargo_add/dependency.rs b/src/cargo/util/toml_mut/dependency.rs similarity index 99% rename from src/cargo/ops/cargo_add/dependency.rs rename to src/cargo/util/toml_mut/dependency.rs index d105d9d9728..9d83a508290 100644 --- a/src/cargo/ops/cargo_add/dependency.rs +++ b/src/cargo/util/toml_mut/dependency.rs @@ -895,7 +895,7 @@ impl Display for WorkspaceSource { mod tests { use std::path::Path; - use crate::ops::cargo_add::manifest::LocalManifest; + use crate::util::toml_mut::manifest::LocalManifest; use cargo_util::paths; use super::*; diff --git a/src/cargo/ops/cargo_add/manifest.rs b/src/cargo/util/toml_mut/manifest.rs similarity index 100% rename from src/cargo/ops/cargo_add/manifest.rs rename to src/cargo/util/toml_mut/manifest.rs diff --git a/src/cargo/util/toml_mut/mod.rs b/src/cargo/util/toml_mut/mod.rs new file mode 100644 index 00000000000..76ea2f094f7 --- /dev/null +++ b/src/cargo/util/toml_mut/mod.rs @@ -0,0 +1,4 @@ +//! Utilities for editing Cargo.toml manifests + +pub mod dependency; +pub mod manifest;