diff --git a/crates/resolver-tests/src/lib.rs b/crates/resolver-tests/src/lib.rs index 12f6171b1..f6e93e65c 100644 --- a/crates/resolver-tests/src/lib.rs +++ b/crates/resolver-tests/src/lib.rs @@ -17,7 +17,7 @@ use cargo::core::Resolve; use cargo::core::{Dependency, PackageId, Registry, Summary}; use cargo::core::{GitReference, SourceId}; 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::prelude::*; @@ -185,7 +185,7 @@ pub fn resolve_with_config_raw( deps, &BTreeMap::new(), None::<&String>, - None::, + None::, ) .unwrap(); let opts = ResolveOpts::everything(); @@ -588,7 +588,7 @@ pub fn pkg_dep(name: T, dep: Vec) -> Summary { dep, &BTreeMap::new(), link, - None::, + None::, ) .unwrap() } @@ -616,7 +616,7 @@ pub fn pkg_loc(name: &str, loc: &str) -> Summary { Vec::new(), &BTreeMap::new(), link, - None::, + None::, ) .unwrap() } @@ -630,7 +630,7 @@ pub fn remove_dep(sum: &Summary, ind: usize) -> Summary { deps, &BTreeMap::new(), sum.links().map(|a| a.as_str()), - None::, + None::, ) .unwrap() } diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index a6ccc07ce..3422bf8fa 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -19,7 +19,7 @@ use crate::core::{Edition, Feature, Features, WorkspaceConfig}; use crate::util::errors::*; use crate::util::interning::InternedString; 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 { Real(Manifest), @@ -58,7 +58,7 @@ pub struct Manifest { original: Rc, unstable_features: Features, edition: Edition, - rust_version: Option, + rust_version: Option, im_a_teapot: Option, default_run: Option, metabuild: Option>, @@ -112,7 +112,7 @@ pub struct ManifestMetadata { pub documentation: Option, // URL pub badges: BTreeMap>, pub links: Option, - pub rust_version: Option, + pub rust_version: Option, } #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] @@ -401,7 +401,7 @@ impl Manifest { workspace: WorkspaceConfig, unstable_features: Features, edition: Edition, - rust_version: Option, + rust_version: Option, im_a_teapot: Option, default_run: Option, original: Rc, @@ -570,7 +570,7 @@ impl Manifest { self.edition } - pub fn rust_version(&self) -> Option { + pub fn rust_version(&self) -> Option { self.rust_version } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index a4a0eaa34..b09d09cd4 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -31,7 +31,7 @@ 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::PartialVersion; +use crate::util::RustVersion; use crate::util::{self, internal, Config, Progress, ProgressStyle}; pub const MANIFEST_PREAMBLE: &str = "\ @@ -104,7 +104,7 @@ pub struct SerializedPackage { #[serde(skip_serializing_if = "Option::is_none")] metabuild: Option>, default_run: Option, - rust_version: Option, + rust_version: Option, } impl Package { @@ -178,7 +178,7 @@ impl Package { self.targets().iter().any(|target| target.proc_macro()) } /// Gets the package's minimum Rust version. - pub fn rust_version(&self) -> Option { + pub fn rust_version(&self) -> Option { self.manifest().rust_version() } diff --git a/src/cargo/core/resolver/dep_cache.rs b/src/cargo/core/resolver/dep_cache.rs index f4e1cfc12..47ad629dc 100644 --- a/src/cargo/core/resolver/dep_cache.rs +++ b/src/cargo/core/resolver/dep_cache.rs @@ -20,7 +20,7 @@ use crate::core::{Dependency, FeatureValue, PackageId, PackageIdSpec, Registry, use crate::sources::source::QueryKind; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; -use crate::util::PartialVersion; +use crate::util::RustVersion; use anyhow::Context as _; 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 /// specify minimum dependency versions to be used. minimal_versions: bool, - max_rust_version: Option, + max_rust_version: Option, /// a cache of `Candidate`s that fulfil a `Dependency` (and whether `first_minimal_version`) registry_cache: HashMap<(Dependency, bool), Poll>>>, /// a cache of `Dependency`s that are required for a `Summary` @@ -58,7 +58,7 @@ impl<'a> RegistryQueryer<'a> { replacements: &'a [(PackageIdSpec, Dependency)], version_prefs: &'a VersionPreferences, minimal_versions: bool, - max_rust_version: Option, + max_rust_version: Option, ) -> Self { RegistryQueryer { registry, diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 9e7d41f60..37a0563d9 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -71,7 +71,7 @@ use crate::util::config::Config; use crate::util::errors::CargoResult; use crate::util::network::PollExt; use crate::util::profile; -use crate::util::PartialVersion; +use crate::util::RustVersion; use self::context::Context; use self::dep_cache::RegistryQueryer; @@ -139,7 +139,7 @@ pub fn resolve( version_prefs: &VersionPreferences, config: Option<&Config>, check_public_visible_dependencies: bool, - mut max_rust_version: Option, + mut max_rust_version: Option, ) -> CargoResult { let _p = profile::start("resolving"); let minimal_versions = match config { diff --git a/src/cargo/core/resolver/version_prefs.rs b/src/cargo/core/resolver/version_prefs.rs index a61f7cac3..28de77f11 100644 --- a/src/cargo/core/resolver/version_prefs.rs +++ b/src/cargo/core/resolver/version_prefs.rs @@ -81,7 +81,7 @@ impl VersionPreferences { mod test { use super::*; use crate::core::SourceId; - use crate::util::PartialVersion; + use crate::util::RustVersion; use std::collections::BTreeMap; fn pkgid(name: &str, version: &str) -> PackageId { @@ -104,7 +104,7 @@ mod test { Vec::new(), &features, None::<&String>, - None::, + None::, ) .unwrap() } diff --git a/src/cargo/core/summary.rs b/src/cargo/core/summary.rs index 020073358..7783832be 100644 --- a/src/cargo/core/summary.rs +++ b/src/cargo/core/summary.rs @@ -1,7 +1,7 @@ use crate::core::{Dependency, PackageId, SourceId}; use crate::util::interning::InternedString; use crate::util::CargoResult; -use crate::util::PartialVersion; +use crate::util::RustVersion; use anyhow::bail; use semver::Version; use std::collections::{BTreeMap, HashMap, HashSet}; @@ -26,7 +26,7 @@ struct Inner { features: Rc, checksum: Option, links: Option, - rust_version: Option, + rust_version: Option, } impl Summary { @@ -35,7 +35,7 @@ impl Summary { dependencies: Vec, features: &BTreeMap>, links: Option>, - rust_version: Option, + rust_version: Option, ) -> CargoResult { // ****CAUTION**** If you change anything here that may raise a new // error, be sure to coordinate that change with either the index @@ -88,7 +88,7 @@ impl Summary { self.inner.links } - pub fn rust_version(&self) -> Option { + pub fn rust_version(&self) -> Option { self.inner.rust_version } diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 2d41e0956..a7767ec57 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -23,7 +23,7 @@ use crate::util::edit_distance; use crate::util::errors::{CargoResult, ManifestError}; use crate::util::interning::InternedString; 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 cargo_util::paths; 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 /// anywhere - pub fn rust_version(&self) -> Option { + pub fn rust_version(&self) -> Option { self.members().filter_map(|pkg| pkg.rust_version()).min() } diff --git a/src/cargo/ops/cargo_add/mod.rs b/src/cargo/ops/cargo_add/mod.rs index cdfe58812..c91f50aa0 100644 --- a/src/cargo/ops/cargo_add/mod.rs +++ b/src/cargo/ops/cargo_add/mod.rs @@ -32,7 +32,7 @@ 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::util::PartialVersion; +use crate::util::RustVersion; use crate::CargoResult; use crate::Config; use crate_spec::CrateSpec; @@ -564,7 +564,7 @@ fn get_latest_dependency( })?; 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)) } @@ -624,7 +624,7 @@ fn get_latest_dependency( fn rust_version_incompat_error( dep: &str, - rust_version: PartialVersion, + rust_version: RustVersion, lowest_rust_version: Option<&Summary>, ) -> anyhow::Error { let mut error_msg = format!( diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 934eb3571..f3b8f8d9a 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -69,7 +69,7 @@ use crate::core::{GitReference, PackageId, PackageIdSpec, PackageSet, SourceId, use crate::ops; use crate::sources::PathSource; use crate::util::errors::CargoResult; -use crate::util::PartialVersion; +use crate::util::RustVersion; use crate::util::{profile, CanonicalUrl}; use anyhow::Context as _; use std::collections::{HashMap, HashSet}; @@ -133,7 +133,7 @@ pub fn resolve_ws_with_opts<'cfg>( specs: &[PackageIdSpec], has_dev_units: HasDevUnits, force_all_targets: ForceAllTargets, - max_rust_version: Option, + max_rust_version: Option, ) -> CargoResult> { let mut registry = PackageRegistry::new(ws.config())?; let mut add_patches = true; @@ -240,7 +240,7 @@ pub fn resolve_ws_with_opts<'cfg>( fn resolve_with_registry<'cfg>( ws: &Workspace<'cfg>, registry: &mut PackageRegistry<'cfg>, - max_rust_version: Option, + max_rust_version: Option, ) -> CargoResult { let prev = ops::load_pkg_lockfile(ws)?; let mut resolve = resolve_with_previous( @@ -285,7 +285,7 @@ pub fn resolve_with_previous<'cfg>( to_avoid: Option<&HashSet>, specs: &[PackageIdSpec], register_patches: bool, - max_rust_version: Option, + max_rust_version: Option, ) -> CargoResult { // We only want one Cargo at a time resolving a crate graph since this can // involve a lot of frobbing of the global caches. diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index 4b6d5048b..dc176fd80 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -91,7 +91,7 @@ use crate::core::{PackageId, SourceId, Summary}; use crate::sources::registry::{LoadResponse, RegistryData}; use crate::util::interning::InternedString; 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 cargo_util::{paths, registry::make_dep_path}; use semver::Version; @@ -358,7 +358,7 @@ pub struct IndexPackage<'a> { /// /// Added in 2023 (see ), /// can be `None` if published before then or if not set in the manifest. - rust_version: Option, + rust_version: Option, /// The schema version for this entry. /// /// If this is None, it defaults to version `1`. Entries with unknown diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index d74351cd0..cb9a518ed 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -22,7 +22,7 @@ pub use self::progress::{Progress, ProgressStyle}; pub use self::queue::Queue; pub use self::restricted_names::validate_package_name; 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::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo}; pub use self::workspace::{ diff --git a/src/cargo/util/semver_ext.rs b/src/cargo/util/semver_ext.rs index cddaa97c9..44cfc0c11 100644 --- a/src/cargo/util/semver_ext.rs +++ b/src/cargo/util/semver_ext.rs @@ -110,13 +110,13 @@ impl From for OptVersionReq { } #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone, Debug)] -pub struct PartialVersion { +pub struct RustVersion { pub major: u64, pub minor: Option, pub patch: Option, } -impl PartialVersion { +impl RustVersion { pub fn caret_req(&self) -> VersionReq { VersionReq { 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; fn from_str(value: &str) -> Result { - // 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 // other features. if is_req(value) { @@ -163,7 +163,7 @@ impl std::str::FromStr for PartialVersion { semver::Prerelease::EMPTY, "guarenteed by character check" ); - Ok(PartialVersion { + Ok(RustVersion { major: comp.major, minor: comp.minor, 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 { let major = self.major; write!(f, "{major}")?; @@ -185,7 +185,7 @@ impl Display for PartialVersion { } } -impl serde::Serialize for PartialVersion { +impl serde::Serialize for RustVersion { fn serialize(&self, serializer: S) -> Result where 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(deserializer: D) -> Result where D: serde::Deserializer<'de>, diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 34161542f..9a8f1aa05 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -30,7 +30,7 @@ use crate::util::errors::{CargoResult, ManifestError}; use crate::util::interning::InternedString; use crate::util::{ self, config::ConfigRelativePath, validate_package_name, Config, IntoUrl, OptVersionReq, - PartialVersion, + RustVersion, }; pub mod embedded; @@ -1182,8 +1182,8 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspaceString { } } -type MaybeWorkspacePartialVersion = MaybeWorkspace; -impl<'de> de::Deserialize<'de> for MaybeWorkspacePartialVersion { +type MaybeWorkspaceRustVersion = MaybeWorkspace; +impl<'de> de::Deserialize<'de> for MaybeWorkspaceRustVersion { fn deserialize(d: D) -> Result where D: de::Deserializer<'de>, @@ -1191,7 +1191,7 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspacePartialVersion { struct 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> { f.write_str("a semver or workspace") @@ -1201,8 +1201,8 @@ impl<'de> de::Deserialize<'de> for MaybeWorkspacePartialVersion { where E: de::Error, { - let value = value.parse::().map_err(|e| E::custom(e))?; - Ok(MaybeWorkspacePartialVersion::Defined(value)) + let value = value.parse::().map_err(|e| E::custom(e))?; + Ok(MaybeWorkspaceRustVersion::Defined(value)) } fn visit_map(self, map: V) -> Result @@ -1400,7 +1400,7 @@ impl WorkspaceInherit for TomlWorkspaceField { #[serde(rename_all = "kebab-case")] pub struct TomlPackage { edition: Option, - rust_version: Option, + rust_version: Option, name: InternedString, #[serde(deserialize_with = "version_trim_whitespace")] version: MaybeWorkspaceSemverVersion, @@ -1490,7 +1490,7 @@ pub struct InheritableFields { exclude: Option>, include: Option>, #[serde(rename = "rust-version")] - rust_version: Option, + rust_version: Option, // We use skip here since it will never be present when deserializing // and we don't want it present when serializing #[serde(skip)] @@ -1530,7 +1530,7 @@ impl InheritableFields { ("package.license", license -> String), ("package.publish", publish -> VecStringOrBool), ("package.repository", repository -> String), - ("package.rust-version", rust_version -> PartialVersion), + ("package.rust-version", rust_version -> RustVersion), ("package.version", version -> semver::Version), }