Skip to content

Commit

Permalink
refactor: Remove VersionExt
Browse files Browse the repository at this point in the history
This came out of my work on rust-lang#12801.
I was looking at what might be appropriate to put in a `cargo-util-semver` crate and realized we have the `VersionExt` trait that exists but doesn't do much, so I dropped it.
  • Loading branch information
epage committed Nov 6, 2023
1 parent a9f6393 commit e7614d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
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, OptVersionReq, VersionExt};
use crate::util::{Config, OptVersionReq};
use anyhow::Error;

use super::context::Context;
Expand Down Expand Up @@ -275,7 +275,7 @@ pub(super) fn activation_error(
msg.push_str(&describe_path_in_context(cx, &parent.package_id()));

// If we have a pre-release candidate, then that may be what our user is looking for
if let Some(pre) = candidates.iter().find(|c| c.version().is_prerelease()) {
if let Some(pre) = candidates.iter().find(|c| !c.version().pre.is_empty()) {
msg.push_str("\nif you are looking for the prerelease package it needs to be specified explicitly");
msg.push_str(&format!(
"\n {} = {{ version = \"{}\" }}",
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, RustVersion, VersionExt, VersionReqExt};
pub use self::semver_ext::{OptVersionReq, PartialVersion, RustVersion, VersionReqExt};
pub use self::to_semver::ToSemver;
pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo};
pub use self::workspace::{
Expand Down
10 changes: 0 additions & 10 deletions src/cargo/util/semver_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,10 @@ pub enum OptVersionReq {
UpdatePrecise(Version, VersionReq),
}

pub trait VersionExt {
fn is_prerelease(&self) -> bool;
}

pub trait VersionReqExt {
fn exact(version: &Version) -> Self;
}

impl VersionExt for Version {
fn is_prerelease(&self) -> bool {
!self.pre.is_empty()
}
}

impl VersionReqExt for VersionReq {
fn exact(version: &Version) -> Self {
VersionReq {
Expand Down

0 comments on commit e7614d0

Please sign in to comment.