mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
refactor(manifest): Clarify the specialized role of RustVersion
This commit is contained in:
parent
d5336f813d
commit
4135f562b8
@ -17,7 +17,7 @@ use cargo::core::Resolve;
|
|||||||
use cargo::core::{Dependency, PackageId, Registry, Summary};
|
use cargo::core::{Dependency, PackageId, Registry, Summary};
|
||||||
use cargo::core::{GitReference, SourceId};
|
use cargo::core::{GitReference, SourceId};
|
||||||
use cargo::sources::source::QueryKind;
|
use cargo::sources::source::QueryKind;
|
||||||
use cargo::util::{CargoResult, Config, Graph, IntoUrl, PartialVersion};
|
use cargo::util::{CargoResult, Config, Graph, IntoUrl, RustVersion};
|
||||||
|
|
||||||
use proptest::collection::{btree_map, vec};
|
use proptest::collection::{btree_map, vec};
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
@ -185,7 +185,7 @@ pub fn resolve_with_config_raw(
|
|||||||
deps,
|
deps,
|
||||||
&BTreeMap::new(),
|
&BTreeMap::new(),
|
||||||
None::<&String>,
|
None::<&String>,
|
||||||
None::<PartialVersion>,
|
None::<RustVersion>,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let opts = ResolveOpts::everything();
|
let opts = ResolveOpts::everything();
|
||||||
@ -588,7 +588,7 @@ pub fn pkg_dep<T: ToPkgId>(name: T, dep: Vec<Dependency>) -> Summary {
|
|||||||
dep,
|
dep,
|
||||||
&BTreeMap::new(),
|
&BTreeMap::new(),
|
||||||
link,
|
link,
|
||||||
None::<PartialVersion>,
|
None::<RustVersion>,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ pub fn pkg_loc(name: &str, loc: &str) -> Summary {
|
|||||||
Vec::new(),
|
Vec::new(),
|
||||||
&BTreeMap::new(),
|
&BTreeMap::new(),
|
||||||
link,
|
link,
|
||||||
None::<PartialVersion>,
|
None::<RustVersion>,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ pub fn remove_dep(sum: &Summary, ind: usize) -> Summary {
|
|||||||
deps,
|
deps,
|
||||||
&BTreeMap::new(),
|
&BTreeMap::new(),
|
||||||
sum.links().map(|a| a.as_str()),
|
sum.links().map(|a| a.as_str()),
|
||||||
None::<PartialVersion>,
|
None::<RustVersion>,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ use crate::core::{Edition, Feature, Features, WorkspaceConfig};
|
|||||||
use crate::util::errors::*;
|
use crate::util::errors::*;
|
||||||
use crate::util::interning::InternedString;
|
use crate::util::interning::InternedString;
|
||||||
use crate::util::toml::{TomlManifest, TomlProfiles};
|
use crate::util::toml::{TomlManifest, TomlProfiles};
|
||||||
use crate::util::{short_hash, Config, Filesystem, PartialVersion};
|
use crate::util::{short_hash, Config, Filesystem, RustVersion};
|
||||||
|
|
||||||
pub enum EitherManifest {
|
pub enum EitherManifest {
|
||||||
Real(Manifest),
|
Real(Manifest),
|
||||||
@ -58,7 +58,7 @@ pub struct Manifest {
|
|||||||
original: Rc<TomlManifest>,
|
original: Rc<TomlManifest>,
|
||||||
unstable_features: Features,
|
unstable_features: Features,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
im_a_teapot: Option<bool>,
|
im_a_teapot: Option<bool>,
|
||||||
default_run: Option<String>,
|
default_run: Option<String>,
|
||||||
metabuild: Option<Vec<String>>,
|
metabuild: Option<Vec<String>>,
|
||||||
@ -112,7 +112,7 @@ pub struct ManifestMetadata {
|
|||||||
pub documentation: Option<String>, // URL
|
pub documentation: Option<String>, // URL
|
||||||
pub badges: BTreeMap<String, BTreeMap<String, String>>,
|
pub badges: BTreeMap<String, BTreeMap<String, String>>,
|
||||||
pub links: Option<String>,
|
pub links: Option<String>,
|
||||||
pub rust_version: Option<PartialVersion>,
|
pub rust_version: Option<RustVersion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
@ -401,7 +401,7 @@ impl Manifest {
|
|||||||
workspace: WorkspaceConfig,
|
workspace: WorkspaceConfig,
|
||||||
unstable_features: Features,
|
unstable_features: Features,
|
||||||
edition: Edition,
|
edition: Edition,
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
im_a_teapot: Option<bool>,
|
im_a_teapot: Option<bool>,
|
||||||
default_run: Option<String>,
|
default_run: Option<String>,
|
||||||
original: Rc<TomlManifest>,
|
original: Rc<TomlManifest>,
|
||||||
@ -570,7 +570,7 @@ impl Manifest {
|
|||||||
self.edition
|
self.edition
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rust_version(&self) -> Option<PartialVersion> {
|
pub fn rust_version(&self) -> Option<RustVersion> {
|
||||||
self.rust_version
|
self.rust_version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ use crate::util::network::http::http_handle_and_timeout;
|
|||||||
use crate::util::network::http::HttpTimeout;
|
use crate::util::network::http::HttpTimeout;
|
||||||
use crate::util::network::retry::{Retry, RetryResult};
|
use crate::util::network::retry::{Retry, RetryResult};
|
||||||
use crate::util::network::sleep::SleepTracker;
|
use crate::util::network::sleep::SleepTracker;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
use crate::util::{self, internal, Config, Progress, ProgressStyle};
|
use crate::util::{self, internal, Config, Progress, ProgressStyle};
|
||||||
|
|
||||||
pub const MANIFEST_PREAMBLE: &str = "\
|
pub const MANIFEST_PREAMBLE: &str = "\
|
||||||
@ -104,7 +104,7 @@ pub struct SerializedPackage {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
metabuild: Option<Vec<String>>,
|
metabuild: Option<Vec<String>>,
|
||||||
default_run: Option<String>,
|
default_run: Option<String>,
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Package {
|
impl Package {
|
||||||
@ -178,7 +178,7 @@ impl Package {
|
|||||||
self.targets().iter().any(|target| target.proc_macro())
|
self.targets().iter().any(|target| target.proc_macro())
|
||||||
}
|
}
|
||||||
/// Gets the package's minimum Rust version.
|
/// Gets the package's minimum Rust version.
|
||||||
pub fn rust_version(&self) -> Option<PartialVersion> {
|
pub fn rust_version(&self) -> Option<RustVersion> {
|
||||||
self.manifest().rust_version()
|
self.manifest().rust_version()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ use crate::core::{Dependency, FeatureValue, PackageId, PackageIdSpec, Registry,
|
|||||||
use crate::sources::source::QueryKind;
|
use crate::sources::source::QueryKind;
|
||||||
use crate::util::errors::CargoResult;
|
use crate::util::errors::CargoResult;
|
||||||
use crate::util::interning::InternedString;
|
use crate::util::interning::InternedString;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
|
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use std::collections::{BTreeSet, HashMap, HashSet};
|
use std::collections::{BTreeSet, HashMap, HashSet};
|
||||||
@ -36,7 +36,7 @@ pub struct RegistryQueryer<'a> {
|
|||||||
/// versions first. That allows `cargo update -Z minimal-versions` which will
|
/// versions first. That allows `cargo update -Z minimal-versions` which will
|
||||||
/// specify minimum dependency versions to be used.
|
/// specify minimum dependency versions to be used.
|
||||||
minimal_versions: bool,
|
minimal_versions: bool,
|
||||||
max_rust_version: Option<PartialVersion>,
|
max_rust_version: Option<RustVersion>,
|
||||||
/// a cache of `Candidate`s that fulfil a `Dependency` (and whether `first_minimal_version`)
|
/// a cache of `Candidate`s that fulfil a `Dependency` (and whether `first_minimal_version`)
|
||||||
registry_cache: HashMap<(Dependency, bool), Poll<Rc<Vec<Summary>>>>,
|
registry_cache: HashMap<(Dependency, bool), Poll<Rc<Vec<Summary>>>>,
|
||||||
/// a cache of `Dependency`s that are required for a `Summary`
|
/// a cache of `Dependency`s that are required for a `Summary`
|
||||||
@ -58,7 +58,7 @@ impl<'a> RegistryQueryer<'a> {
|
|||||||
replacements: &'a [(PackageIdSpec, Dependency)],
|
replacements: &'a [(PackageIdSpec, Dependency)],
|
||||||
version_prefs: &'a VersionPreferences,
|
version_prefs: &'a VersionPreferences,
|
||||||
minimal_versions: bool,
|
minimal_versions: bool,
|
||||||
max_rust_version: Option<PartialVersion>,
|
max_rust_version: Option<RustVersion>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
RegistryQueryer {
|
RegistryQueryer {
|
||||||
registry,
|
registry,
|
||||||
|
@ -71,7 +71,7 @@ use crate::util::config::Config;
|
|||||||
use crate::util::errors::CargoResult;
|
use crate::util::errors::CargoResult;
|
||||||
use crate::util::network::PollExt;
|
use crate::util::network::PollExt;
|
||||||
use crate::util::profile;
|
use crate::util::profile;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
|
|
||||||
use self::context::Context;
|
use self::context::Context;
|
||||||
use self::dep_cache::RegistryQueryer;
|
use self::dep_cache::RegistryQueryer;
|
||||||
@ -139,7 +139,7 @@ pub fn resolve(
|
|||||||
version_prefs: &VersionPreferences,
|
version_prefs: &VersionPreferences,
|
||||||
config: Option<&Config>,
|
config: Option<&Config>,
|
||||||
check_public_visible_dependencies: bool,
|
check_public_visible_dependencies: bool,
|
||||||
mut max_rust_version: Option<PartialVersion>,
|
mut max_rust_version: Option<RustVersion>,
|
||||||
) -> CargoResult<Resolve> {
|
) -> CargoResult<Resolve> {
|
||||||
let _p = profile::start("resolving");
|
let _p = profile::start("resolving");
|
||||||
let minimal_versions = match config {
|
let minimal_versions = match config {
|
||||||
|
@ -81,7 +81,7 @@ impl VersionPreferences {
|
|||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::core::SourceId;
|
use crate::core::SourceId;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
fn pkgid(name: &str, version: &str) -> PackageId {
|
fn pkgid(name: &str, version: &str) -> PackageId {
|
||||||
@ -104,7 +104,7 @@ mod test {
|
|||||||
Vec::new(),
|
Vec::new(),
|
||||||
&features,
|
&features,
|
||||||
None::<&String>,
|
None::<&String>,
|
||||||
None::<PartialVersion>,
|
None::<RustVersion>,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::core::{Dependency, PackageId, SourceId};
|
use crate::core::{Dependency, PackageId, SourceId};
|
||||||
use crate::util::interning::InternedString;
|
use crate::util::interning::InternedString;
|
||||||
use crate::util::CargoResult;
|
use crate::util::CargoResult;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
@ -26,7 +26,7 @@ struct Inner {
|
|||||||
features: Rc<FeatureMap>,
|
features: Rc<FeatureMap>,
|
||||||
checksum: Option<String>,
|
checksum: Option<String>,
|
||||||
links: Option<InternedString>,
|
links: Option<InternedString>,
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Summary {
|
impl Summary {
|
||||||
@ -35,7 +35,7 @@ impl Summary {
|
|||||||
dependencies: Vec<Dependency>,
|
dependencies: Vec<Dependency>,
|
||||||
features: &BTreeMap<InternedString, Vec<InternedString>>,
|
features: &BTreeMap<InternedString, Vec<InternedString>>,
|
||||||
links: Option<impl Into<InternedString>>,
|
links: Option<impl Into<InternedString>>,
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
) -> CargoResult<Summary> {
|
) -> CargoResult<Summary> {
|
||||||
// ****CAUTION**** If you change anything here that may raise a new
|
// ****CAUTION**** If you change anything here that may raise a new
|
||||||
// error, be sure to coordinate that change with either the index
|
// error, be sure to coordinate that change with either the index
|
||||||
@ -88,7 +88,7 @@ impl Summary {
|
|||||||
self.inner.links
|
self.inner.links
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rust_version(&self) -> Option<PartialVersion> {
|
pub fn rust_version(&self) -> Option<RustVersion> {
|
||||||
self.inner.rust_version
|
self.inner.rust_version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ use crate::util::edit_distance;
|
|||||||
use crate::util::errors::{CargoResult, ManifestError};
|
use crate::util::errors::{CargoResult, ManifestError};
|
||||||
use crate::util::interning::InternedString;
|
use crate::util::interning::InternedString;
|
||||||
use crate::util::toml::{read_manifest, InheritableFields, TomlDependency, TomlProfiles};
|
use crate::util::toml::{read_manifest, InheritableFields, TomlDependency, TomlProfiles};
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
use crate::util::{config::ConfigRelativePath, Config, Filesystem, IntoUrl};
|
use crate::util::{config::ConfigRelativePath, Config, Filesystem, IntoUrl};
|
||||||
use cargo_util::paths;
|
use cargo_util::paths;
|
||||||
use cargo_util::paths::normalize_path;
|
use cargo_util::paths::normalize_path;
|
||||||
@ -598,7 +598,7 @@ impl<'cfg> Workspace<'cfg> {
|
|||||||
|
|
||||||
/// Get the lowest-common denominator `package.rust-version` within the workspace, if specified
|
/// Get the lowest-common denominator `package.rust-version` within the workspace, if specified
|
||||||
/// anywhere
|
/// anywhere
|
||||||
pub fn rust_version(&self) -> Option<PartialVersion> {
|
pub fn rust_version(&self) -> Option<RustVersion> {
|
||||||
self.members().filter_map(|pkg| pkg.rust_version()).min()
|
self.members().filter_map(|pkg| pkg.rust_version()).min()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ use crate::util::toml_mut::dependency::Source;
|
|||||||
use crate::util::toml_mut::dependency::WorkspaceSource;
|
use crate::util::toml_mut::dependency::WorkspaceSource;
|
||||||
use crate::util::toml_mut::manifest::DepTable;
|
use crate::util::toml_mut::manifest::DepTable;
|
||||||
use crate::util::toml_mut::manifest::LocalManifest;
|
use crate::util::toml_mut::manifest::LocalManifest;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
use crate::CargoResult;
|
use crate::CargoResult;
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
use crate_spec::CrateSpec;
|
use crate_spec::CrateSpec;
|
||||||
@ -564,7 +564,7 @@ fn get_latest_dependency(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
if config.cli_unstable().msrv_policy && honor_rust_version {
|
if config.cli_unstable().msrv_policy && honor_rust_version {
|
||||||
fn parse_msrv(comp: PartialVersion) -> (u64, u64, u64) {
|
fn parse_msrv(comp: RustVersion) -> (u64, u64, u64) {
|
||||||
(comp.major, comp.minor.unwrap_or(0), comp.patch.unwrap_or(0))
|
(comp.major, comp.minor.unwrap_or(0), comp.patch.unwrap_or(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ fn get_latest_dependency(
|
|||||||
|
|
||||||
fn rust_version_incompat_error(
|
fn rust_version_incompat_error(
|
||||||
dep: &str,
|
dep: &str,
|
||||||
rust_version: PartialVersion,
|
rust_version: RustVersion,
|
||||||
lowest_rust_version: Option<&Summary>,
|
lowest_rust_version: Option<&Summary>,
|
||||||
) -> anyhow::Error {
|
) -> anyhow::Error {
|
||||||
let mut error_msg = format!(
|
let mut error_msg = format!(
|
||||||
|
@ -69,7 +69,7 @@ use crate::core::{GitReference, PackageId, PackageIdSpec, PackageSet, SourceId,
|
|||||||
use crate::ops;
|
use crate::ops;
|
||||||
use crate::sources::PathSource;
|
use crate::sources::PathSource;
|
||||||
use crate::util::errors::CargoResult;
|
use crate::util::errors::CargoResult;
|
||||||
use crate::util::PartialVersion;
|
use crate::util::RustVersion;
|
||||||
use crate::util::{profile, CanonicalUrl};
|
use crate::util::{profile, CanonicalUrl};
|
||||||
use anyhow::Context as _;
|
use anyhow::Context as _;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
@ -133,7 +133,7 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||||||
specs: &[PackageIdSpec],
|
specs: &[PackageIdSpec],
|
||||||
has_dev_units: HasDevUnits,
|
has_dev_units: HasDevUnits,
|
||||||
force_all_targets: ForceAllTargets,
|
force_all_targets: ForceAllTargets,
|
||||||
max_rust_version: Option<PartialVersion>,
|
max_rust_version: Option<RustVersion>,
|
||||||
) -> CargoResult<WorkspaceResolve<'cfg>> {
|
) -> CargoResult<WorkspaceResolve<'cfg>> {
|
||||||
let mut registry = PackageRegistry::new(ws.config())?;
|
let mut registry = PackageRegistry::new(ws.config())?;
|
||||||
let mut add_patches = true;
|
let mut add_patches = true;
|
||||||
@ -240,7 +240,7 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||||||
fn resolve_with_registry<'cfg>(
|
fn resolve_with_registry<'cfg>(
|
||||||
ws: &Workspace<'cfg>,
|
ws: &Workspace<'cfg>,
|
||||||
registry: &mut PackageRegistry<'cfg>,
|
registry: &mut PackageRegistry<'cfg>,
|
||||||
max_rust_version: Option<PartialVersion>,
|
max_rust_version: Option<RustVersion>,
|
||||||
) -> CargoResult<Resolve> {
|
) -> CargoResult<Resolve> {
|
||||||
let prev = ops::load_pkg_lockfile(ws)?;
|
let prev = ops::load_pkg_lockfile(ws)?;
|
||||||
let mut resolve = resolve_with_previous(
|
let mut resolve = resolve_with_previous(
|
||||||
@ -285,7 +285,7 @@ pub fn resolve_with_previous<'cfg>(
|
|||||||
to_avoid: Option<&HashSet<PackageId>>,
|
to_avoid: Option<&HashSet<PackageId>>,
|
||||||
specs: &[PackageIdSpec],
|
specs: &[PackageIdSpec],
|
||||||
register_patches: bool,
|
register_patches: bool,
|
||||||
max_rust_version: Option<PartialVersion>,
|
max_rust_version: Option<RustVersion>,
|
||||||
) -> CargoResult<Resolve> {
|
) -> CargoResult<Resolve> {
|
||||||
// We only want one Cargo at a time resolving a crate graph since this can
|
// We only want one Cargo at a time resolving a crate graph since this can
|
||||||
// involve a lot of frobbing of the global caches.
|
// involve a lot of frobbing of the global caches.
|
||||||
|
@ -91,7 +91,7 @@ use crate::core::{PackageId, SourceId, Summary};
|
|||||||
use crate::sources::registry::{LoadResponse, RegistryData};
|
use crate::sources::registry::{LoadResponse, RegistryData};
|
||||||
use crate::util::interning::InternedString;
|
use crate::util::interning::InternedString;
|
||||||
use crate::util::IntoUrl;
|
use crate::util::IntoUrl;
|
||||||
use crate::util::{internal, CargoResult, Config, Filesystem, OptVersionReq, PartialVersion};
|
use crate::util::{internal, CargoResult, Config, Filesystem, OptVersionReq, RustVersion};
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use cargo_util::{paths, registry::make_dep_path};
|
use cargo_util::{paths, registry::make_dep_path};
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
@ -358,7 +358,7 @@ pub struct IndexPackage<'a> {
|
|||||||
///
|
///
|
||||||
/// Added in 2023 (see <https://github.com/rust-lang/crates.io/pull/6267>),
|
/// Added in 2023 (see <https://github.com/rust-lang/crates.io/pull/6267>),
|
||||||
/// can be `None` if published before then or if not set in the manifest.
|
/// can be `None` if published before then or if not set in the manifest.
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
/// The schema version for this entry.
|
/// The schema version for this entry.
|
||||||
///
|
///
|
||||||
/// If this is None, it defaults to version `1`. Entries with unknown
|
/// If this is None, it defaults to version `1`. Entries with unknown
|
||||||
|
@ -22,7 +22,7 @@ pub use self::progress::{Progress, ProgressStyle};
|
|||||||
pub use self::queue::Queue;
|
pub use self::queue::Queue;
|
||||||
pub use self::restricted_names::validate_package_name;
|
pub use self::restricted_names::validate_package_name;
|
||||||
pub use self::rustc::Rustc;
|
pub use self::rustc::Rustc;
|
||||||
pub use self::semver_ext::{OptVersionReq, PartialVersion, VersionExt, VersionReqExt};
|
pub use self::semver_ext::{OptVersionReq, RustVersion, VersionExt, VersionReqExt};
|
||||||
pub use self::to_semver::ToSemver;
|
pub use self::to_semver::ToSemver;
|
||||||
pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo};
|
pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo};
|
||||||
pub use self::workspace::{
|
pub use self::workspace::{
|
||||||
|
@ -110,13 +110,13 @@ impl From<VersionReq> for OptVersionReq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug)]
|
||||||
pub struct PartialVersion {
|
pub struct RustVersion {
|
||||||
pub major: u64,
|
pub major: u64,
|
||||||
pub minor: Option<u64>,
|
pub minor: Option<u64>,
|
||||||
pub patch: Option<u64>,
|
pub patch: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialVersion {
|
impl RustVersion {
|
||||||
pub fn caret_req(&self) -> VersionReq {
|
pub fn caret_req(&self) -> VersionReq {
|
||||||
VersionReq {
|
VersionReq {
|
||||||
comparators: vec![Comparator {
|
comparators: vec![Comparator {
|
||||||
@ -130,11 +130,11 @@ impl PartialVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::str::FromStr for PartialVersion {
|
impl std::str::FromStr for RustVersion {
|
||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
||||||
// HACK: `PartialVersion` is a subset of the `VersionReq` syntax that only ever
|
// HACK: `RustVersion` is a subset of the `VersionReq` syntax that only ever
|
||||||
// has one comparator with a required minor and optional patch, and uses no
|
// has one comparator with a required minor and optional patch, and uses no
|
||||||
// other features.
|
// other features.
|
||||||
if is_req(value) {
|
if is_req(value) {
|
||||||
@ -163,7 +163,7 @@ impl std::str::FromStr for PartialVersion {
|
|||||||
semver::Prerelease::EMPTY,
|
semver::Prerelease::EMPTY,
|
||||||
"guarenteed by character check"
|
"guarenteed by character check"
|
||||||
);
|
);
|
||||||
Ok(PartialVersion {
|
Ok(RustVersion {
|
||||||
major: comp.major,
|
major: comp.major,
|
||||||
minor: comp.minor,
|
minor: comp.minor,
|
||||||
patch: comp.patch,
|
patch: comp.patch,
|
||||||
@ -171,7 +171,7 @@ impl std::str::FromStr for PartialVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for PartialVersion {
|
impl Display for RustVersion {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let major = self.major;
|
let major = self.major;
|
||||||
write!(f, "{major}")?;
|
write!(f, "{major}")?;
|
||||||
@ -185,7 +185,7 @@ impl Display for PartialVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl serde::Serialize for PartialVersion {
|
impl serde::Serialize for RustVersion {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
@ -194,7 +194,7 @@ impl serde::Serialize for PartialVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'de> serde::Deserialize<'de> for PartialVersion {
|
impl<'de> serde::Deserialize<'de> for RustVersion {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
|
@ -30,7 +30,7 @@ use crate::util::errors::{CargoResult, ManifestError};
|
|||||||
use crate::util::interning::InternedString;
|
use crate::util::interning::InternedString;
|
||||||
use crate::util::{
|
use crate::util::{
|
||||||
self, config::ConfigRelativePath, validate_package_name, Config, IntoUrl, OptVersionReq,
|
self, config::ConfigRelativePath, validate_package_name, Config, IntoUrl, OptVersionReq,
|
||||||
PartialVersion,
|
RustVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod embedded;
|
pub mod embedded;
|
||||||
@ -1182,8 +1182,8 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspaceString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MaybeWorkspacePartialVersion = MaybeWorkspace<PartialVersion, TomlWorkspaceField>;
|
type MaybeWorkspaceRustVersion = MaybeWorkspace<RustVersion, TomlWorkspaceField>;
|
||||||
impl<'de> de::Deserialize<'de> for MaybeWorkspacePartialVersion {
|
impl<'de> de::Deserialize<'de> for MaybeWorkspaceRustVersion {
|
||||||
fn deserialize<D>(d: D) -> Result<Self, D::Error>
|
fn deserialize<D>(d: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: de::Deserializer<'de>,
|
D: de::Deserializer<'de>,
|
||||||
@ -1191,7 +1191,7 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspacePartialVersion {
|
|||||||
struct Visitor;
|
struct Visitor;
|
||||||
|
|
||||||
impl<'de> de::Visitor<'de> for Visitor {
|
impl<'de> de::Visitor<'de> for Visitor {
|
||||||
type Value = MaybeWorkspacePartialVersion;
|
type Value = MaybeWorkspaceRustVersion;
|
||||||
|
|
||||||
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
f.write_str("a semver or workspace")
|
f.write_str("a semver or workspace")
|
||||||
@ -1201,8 +1201,8 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspacePartialVersion {
|
|||||||
where
|
where
|
||||||
E: de::Error,
|
E: de::Error,
|
||||||
{
|
{
|
||||||
let value = value.parse::<PartialVersion>().map_err(|e| E::custom(e))?;
|
let value = value.parse::<RustVersion>().map_err(|e| E::custom(e))?;
|
||||||
Ok(MaybeWorkspacePartialVersion::Defined(value))
|
Ok(MaybeWorkspaceRustVersion::Defined(value))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
|
fn visit_map<V>(self, map: V) -> Result<Self::Value, V::Error>
|
||||||
@ -1400,7 +1400,7 @@ impl WorkspaceInherit for TomlWorkspaceField {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct TomlPackage {
|
pub struct TomlPackage {
|
||||||
edition: Option<MaybeWorkspaceString>,
|
edition: Option<MaybeWorkspaceString>,
|
||||||
rust_version: Option<MaybeWorkspacePartialVersion>,
|
rust_version: Option<MaybeWorkspaceRustVersion>,
|
||||||
name: InternedString,
|
name: InternedString,
|
||||||
#[serde(deserialize_with = "version_trim_whitespace")]
|
#[serde(deserialize_with = "version_trim_whitespace")]
|
||||||
version: MaybeWorkspaceSemverVersion,
|
version: MaybeWorkspaceSemverVersion,
|
||||||
@ -1490,7 +1490,7 @@ pub struct InheritableFields {
|
|||||||
exclude: Option<Vec<String>>,
|
exclude: Option<Vec<String>>,
|
||||||
include: Option<Vec<String>>,
|
include: Option<Vec<String>>,
|
||||||
#[serde(rename = "rust-version")]
|
#[serde(rename = "rust-version")]
|
||||||
rust_version: Option<PartialVersion>,
|
rust_version: Option<RustVersion>,
|
||||||
// We use skip here since it will never be present when deserializing
|
// We use skip here since it will never be present when deserializing
|
||||||
// and we don't want it present when serializing
|
// and we don't want it present when serializing
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
@ -1530,7 +1530,7 @@ impl InheritableFields {
|
|||||||
("package.license", license -> String),
|
("package.license", license -> String),
|
||||||
("package.publish", publish -> VecStringOrBool),
|
("package.publish", publish -> VecStringOrBool),
|
||||||
("package.repository", repository -> String),
|
("package.repository", repository -> String),
|
||||||
("package.rust-version", rust_version -> PartialVersion),
|
("package.rust-version", rust_version -> RustVersion),
|
||||||
("package.version", version -> semver::Version),
|
("package.version", version -> semver::Version),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user