Skip to content

Commit a5fa676

Browse files
committed
Auto merge of #13097 - epage:schemas, r=ehuss
refactor(schemas): Pull out mod for proposed schemas package Originally for #12801 we talked about a `cargo-util-manifest-schema` package - `util` in the name to not clash with plugins - manifest specific to keep the scope down The problem is we have types that aren't manifest specific, like - `PartialVersion` (currently slated for `cargo-util-semverext`) - `RustVersion` - `PackageIdSpec` - `SourceKind` (soon) Things get messy if we try to break things down into common packages. Instead, I think it'd be useful to have a schemas package that has mods for each type of schema, re-exporting what is needed. Normally, componentizing your package by the layer in the stack is a recipe for pain. I don't think that'll apply here because these are meant to be so low level. The other big concern could be compile times. My hope is it won't be too bad. So this moves the `util/toml` types into the module and we can add more in the future.
2 parents f88a44a + e46df98 commit a5fa676

File tree

13 files changed

+138
-129
lines changed

13 files changed

+138
-129
lines changed

src/bin/cargo/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
use cargo::util::network::http::http_handle;
44
use cargo::util::network::http::needs_custom_http_transport;
5-
use cargo::util::toml::schema::StringOrVec;
65
use cargo::util::CliError;
76
use cargo::util::{self, closest_msg, command_prelude, CargoResult, CliResult, Config};
7+
use cargo::util_schemas::manifest::StringOrVec;
88
use cargo_util::{ProcessBuilder, ProcessError};
99
use std::collections::BTreeMap;
1010
use std::env;

src/cargo/core/compiler/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ use crate::core::{Feature, PackageId, Target, Verbosity};
9393
use crate::util::errors::{CargoResult, VerboseError};
9494
use crate::util::interning::InternedString;
9595
use crate::util::machine_message::{self, Message};
96-
use crate::util::toml::schema::TomlDebugInfo;
97-
use crate::util::toml::schema::TomlTrimPaths;
9896
use crate::util::{add_path_args, internal, iter_join_onto, profile};
97+
use crate::util_schemas::manifest::TomlDebugInfo;
98+
use crate::util_schemas::manifest::TomlTrimPaths;
9999
use cargo_util::{paths, ProcessBuilder, ProcessError};
100100
use rustfix::diagnostics::Applicability;
101101

src/cargo/core/manifest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use crate::core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
1818
use crate::core::{Edition, Feature, Features, WorkspaceConfig};
1919
use crate::util::errors::*;
2020
use crate::util::interning::InternedString;
21-
use crate::util::toml::schema::{TomlManifest, TomlProfiles};
2221
use crate::util::{short_hash, Config, Filesystem, RustVersion};
22+
use crate::util_schemas::manifest::{TomlManifest, TomlProfiles};
2323

2424
pub enum EitherManifest {
2525
Real(Manifest),

src/cargo/core/profiles.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ use crate::core::resolver::features::FeaturesFor;
2727
use crate::core::Feature;
2828
use crate::core::{PackageId, PackageIdSpec, Resolve, Shell, Target, Workspace};
2929
use crate::util::interning::InternedString;
30-
use crate::util::toml::schema::TomlTrimPaths;
31-
use crate::util::toml::schema::TomlTrimPathsValue;
32-
use crate::util::toml::schema::{
33-
ProfilePackageSpec, StringOrBool, TomlDebugInfo, TomlProfile, TomlProfiles,
34-
};
3530
use crate::util::toml::validate_profile;
3631
use crate::util::{closest_msg, config, CargoResult, Config};
32+
use crate::util_schemas::manifest::TomlTrimPaths;
33+
use crate::util_schemas::manifest::TomlTrimPathsValue;
34+
use crate::util_schemas::manifest::{
35+
ProfilePackageSpec, StringOrBool, TomlDebugInfo, TomlProfile, TomlProfiles,
36+
};
3737
use anyhow::{bail, Context as _};
3838
use std::collections::{BTreeMap, HashMap, HashSet};
3939
use std::hash::Hash;

src/cargo/core/workspace.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ use crate::sources::{PathSource, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
2222
use crate::util::edit_distance;
2323
use crate::util::errors::{CargoResult, ManifestError};
2424
use crate::util::interning::InternedString;
25-
use crate::util::toml::{
26-
read_manifest, schema::TomlDependency, schema::TomlProfiles, InheritableFields,
27-
};
25+
use crate::util::toml::{read_manifest, InheritableFields};
2826
use crate::util::RustVersion;
2927
use crate::util::{config::ConfigRelativePath, Config, Filesystem, IntoUrl};
28+
use crate::util_schemas::manifest::{TomlDependency, TomlProfiles};
3029
use cargo_util::paths;
3130
use cargo_util::paths::normalize_path;
3231
use pathdiff::diff_paths;

src/cargo/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
//! Files that interact with cargo include
9999
//!
100100
//! - Package
101-
//! - `Cargo.toml`: User-written project manifest, loaded with [`util::toml::schema::TomlManifest`] and then
101+
//! - `Cargo.toml`: User-written project manifest, loaded with [`util_schemas::manifest::TomlManifest`] and then
102102
//! translated to [`core::manifest::Manifest`] which maybe stored in a [`core::Package`].
103103
//! - This is editable with [`util::toml_mut::manifest::LocalManifest`]
104104
//! - `Cargo.lock`: Generally loaded with [`ops::resolve_ws`] or a variant of it into a [`core::resolver::Resolve`]
@@ -152,6 +152,7 @@ pub mod core;
152152
pub mod ops;
153153
pub mod sources;
154154
pub mod util;
155+
pub mod util_schemas;
155156
pub mod util_semver;
156157
mod version;
157158

src/cargo/util/command_prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use crate::util::important_paths::find_root_manifest_for_wd;
77
use crate::util::interning::InternedString;
88
use crate::util::is_rustup;
99
use crate::util::restricted_names;
10-
use crate::util::toml::schema::StringOrVec;
1110
use crate::util::{
1211
print_available_benches, print_available_binaries, print_available_examples,
1312
print_available_packages, print_available_tests,
1413
};
14+
use crate::util_schemas::manifest::StringOrVec;
1515
use crate::CargoResult;
1616
use anyhow::bail;
1717
use cargo_util::paths;

0 commit comments

Comments
 (0)