Skip to content

Commit

Permalink
Use a more compact way to compare versions
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Sep 21, 2021
1 parent 09374c5 commit dd03e40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
15 changes: 1 addition & 14 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,21 +1248,8 @@ impl<'cfg> DrainState<'cfg> {
}

fn back_compat_notice(&self, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> {
fn is_broken_diesel(version: &Version) -> bool {
use semver::{Comparator, Op, Prerelease};

Comparator {
op: Op::Less,
major: 1,
minor: Some(4),
patch: Some(8),
pre: Prerelease::EMPTY,
}
.matches(version)
}

if unit.pkg.name() != "diesel"
|| !is_broken_diesel(unit.pkg.version())
|| unit.pkg.version() >= &Version::new(1, 4, 8)
|| cx.bcx.ws.resolve_behavior() == ResolveBehavior::V1
|| !unit.pkg.package_id().source_id().is_registry()
|| !unit.features.is_empty()
Expand Down
14 changes: 2 additions & 12 deletions src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuild
use log::{debug, trace, warn};
use rustfix::diagnostics::Diagnostic;
use rustfix::{self, CodeFix};
use semver::{Comparator, Op, Prerelease};
use semver::Version;

use crate::core::compiler::{CompileKind, RustcTargetData, TargetInfo};
use crate::core::resolver::features::{DiffMap, FeatureOpts, FeatureResolver};
Expand Down Expand Up @@ -323,17 +323,7 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(

fn report_maybe_diesel(config: &Config, resolve: &Resolve) -> CargoResult<()> {
fn is_broken_diesel(pid: PackageId) -> bool {
if pid.name() != "diesel" {
return false;
}
Comparator {
op: Op::Less,
major: 1,
minor: Some(4),
patch: Some(8),
pre: Prerelease::EMPTY,
}
.matches(pid.version())
pid.name() == "diesel" && pid.version() < &Version::new(1, 4, 8)
}

fn is_broken_diesel_migration(pid: PackageId) -> bool {
Expand Down

0 comments on commit dd03e40

Please sign in to comment.