Skip to content

Commit

Permalink
Small nits
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Sep 12, 2023
1 parent dcde7eb commit 50f1455
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
10 changes: 2 additions & 8 deletions src/cargo/core/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/resolver/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 50f1455

Please sign in to comment.