From 50f1455a64b23735f61609dbc851596481a4d18e Mon Sep 17 00:00:00 2001 From: Jacob Finkelman Date: Tue, 12 Sep 2023 15:05:33 +0000 Subject: [PATCH] Small nits --- src/cargo/core/dependency.rs | 10 ++-------- src/cargo/core/resolver/errors.rs | 4 ++-- src/cargo/util/toml/mod.rs | 7 +++---- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 11192a86417..f00bb05900d 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -318,14 +318,8 @@ impl Dependency { } /// Sets the version requirement for this dependency. - pub fn set_version_req(&mut self, req: VersionReq) -> &mut Dependency { - Rc::make_mut(&mut self.inner).req = OptVersionReq::Req(req); - self - } - - /// Sets the version requirement as any for this dependency. - pub fn set_version_req_as_any(&mut self) -> &mut Dependency { - Rc::make_mut(&mut self.inner).req = OptVersionReq::Any; + pub fn set_version_req(&mut self, req: OptVersionReq) -> &mut Dependency { + Rc::make_mut(&mut self.inner).req = req; self } diff --git a/src/cargo/core/resolver/errors.rs b/src/cargo/core/resolver/errors.rs index 9521c188460..b57a7c3ebf4 100644 --- a/src/cargo/core/resolver/errors.rs +++ b/src/cargo/core/resolver/errors.rs @@ -4,7 +4,7 @@ use std::task::Poll; use crate::core::{Dependency, PackageId, Registry, Summary}; use crate::sources::source::QueryKind; use crate::util::edit_distance::edit_distance; -use crate::util::{Config, VersionExt}; +use crate::util::{Config, OptVersionReq, VersionExt}; use anyhow::Error; use super::context::Context; @@ -225,7 +225,7 @@ pub(super) fn activation_error( // was meant. So we re-query the registry with `dep="*"` so we can // list a few versions that were actually found. let mut new_dep = dep.clone(); - new_dep.set_version_req_as_any(); + new_dep.set_version_req(OptVersionReq::Any); let mut candidates = loop { match registry.query_vec(&new_dep, QueryKind::Exact) { diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 4e2002f8f24..f9eda7d1318 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -10,7 +10,6 @@ use cargo_platform::Platform; use cargo_util::paths; use itertools::Itertools; use lazycell::LazyCell; -use semver::{self, VersionReq}; use serde::de::{self, IntoDeserializer as _, Unexpected}; use serde::ser; use serde::{Deserialize, Serialize}; @@ -30,8 +29,8 @@ use crate::sources::{CRATES_IO_INDEX, CRATES_IO_REGISTRY}; use crate::util::errors::{CargoResult, ManifestError}; use crate::util::interning::InternedString; use crate::util::{ - self, config::ConfigRelativePath, validate_package_name, Config, IntoUrl, PartialVersion, - VersionReqExt, + self, config::ConfigRelativePath, validate_package_name, Config, IntoUrl, OptVersionReq, + PartialVersion, }; pub mod embedded; @@ -2656,7 +2655,7 @@ impl TomlManifest { replacement.unused_keys(), &mut cx.warnings, ); - dep.set_version_req(VersionReq::exact(version)) + dep.set_version_req(OptVersionReq::exact(version)) .lock_version(version); replace.push((spec, dep)); }