From 3623e278a5a2a0df45812d070674ffd56c29bf74 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Thu, 31 Aug 2023 20:15:50 -0700 Subject: [PATCH] Remove profiles information from the package structure. Signed-off-by: David Calavera --- src/cargo/core/package.rs | 4 ---- src/cargo/ops/cargo_output_metadata.rs | 11 +++-------- tests/testsuite/metadata.rs | 22 +++++++++++----------- tests/testsuite/script.rs | 14 +++++++------- 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 49b494dba2be..aa673e937ceb 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -31,7 +31,6 @@ use crate::util::network::http::http_handle_and_timeout; use crate::util::network::http::HttpTimeout; use crate::util::network::retry::{Retry, RetryResult}; use crate::util::network::sleep::SleepTracker; -use crate::util::toml::TomlProfiles; use crate::util::PartialVersion; use crate::util::{self, internal, Config, Progress, ProgressStyle}; @@ -106,8 +105,6 @@ pub struct SerializedPackage { metabuild: Option>, default_run: Option, rust_version: Option, - #[serde(skip_serializing_if = "Option::is_none")] - profiles: Option, } impl Package { @@ -267,7 +264,6 @@ impl Package { publish: self.publish().as_ref().cloned(), default_run: self.manifest().default_run().map(|s| s.to_owned()), rust_version: self.rust_version(), - profiles: self.manifest().profiles().cloned(), } } } diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 22031716fa63..5002c9fadaae 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -3,7 +3,7 @@ use crate::core::compiler::{CompileKind, RustcTargetData}; use crate::core::dependency::DepKind; use crate::core::package::SerializedPackage; use crate::core::resolver::{features::CliFeatures, HasDevUnits, Resolve}; -use crate::core::{MaybePackage, Package, PackageId, Workspace}; +use crate::core::{Package, PackageId, Workspace}; use crate::ops::{self, Packages}; use crate::util::interning::InternedString; use crate::util::toml::TomlProfiles; @@ -41,11 +41,6 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo (packages, Some(resolve)) }; - let workspace_profiles = match ws.root_maybe() { - MaybePackage::Virtual(vm) => vm.profiles().cloned(), - _ => None, // regular packages include the profile information under their package section - }; - Ok(ExportInfo { packages, workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(), @@ -55,7 +50,7 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo version: VERSION, workspace_root: ws.root().to_path_buf(), metadata: ws.custom_metadata().cloned(), - workspace_profiles, + profiles: ws.profiles().cloned(), }) } @@ -73,7 +68,7 @@ pub struct ExportInfo { workspace_root: PathBuf, metadata: Option, #[serde(skip_serializing_if = "Option::is_none")] - workspace_profiles: Option, + profiles: Option, } #[derive(Serialize)] diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index ce76c774b0c9..9b9b2f0263a4 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -4322,15 +4322,7 @@ lto = "thin" "features": {}, "manifest_path": "[..]Cargo.toml", "metadata": null, - "publish": null, - "profiles": { - "custom-lto": { - "lto": "thin" - }, - "release": { - "strip": "symbols" - } - } + "publish": null } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], @@ -4349,7 +4341,15 @@ lto = "thin" "target_directory": "[..]foo/target", "version": 1, "workspace_root": "[..]/foo", - "metadata": null + "metadata": null, + "profiles": { + "custom-lto": { + "lto": "thin" + }, + "release": { + "strip": "symbols" + } + } }"#, ) .run(); @@ -4484,7 +4484,7 @@ fn workspace_metadata_with_profiles() { "version": 1, "workspace_root": "[..]/foo", "metadata": null, - "workspace_profiles": { + "profiles": { "custom-lto": { "lto": "thin" }, diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 663f5c3b72ae..cdac10974e70 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -1061,12 +1061,7 @@ fn cmd_metadata_with_embedded() { "features": {}, "manifest_path": "[..]script.rs", "metadata": null, - "publish": [], - "profiles": { - "release": { - "strip": true - } - } + "publish": [] } ], "workspace_members": ["script 0.0.0 (path+file:[..]foo)"], @@ -1085,7 +1080,12 @@ fn cmd_metadata_with_embedded() { "target_directory": "[ROOT]/home/.cargo/target/[..]", "version": 1, "workspace_root": "[..]/foo", - "metadata": null + "metadata": null, + "profiles": { + "release": { + "strip": true + } + } }"#, ) .with_stderr(