Skip to content

Commit dd03e40

Browse files
committed
Use a more compact way to compare versions
1 parent 09374c5 commit dd03e40

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

src/cargo/core/compiler/job_queue.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -1248,21 +1248,8 @@ impl<'cfg> DrainState<'cfg> {
12481248
}
12491249

12501250
fn back_compat_notice(&self, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> {
1251-
fn is_broken_diesel(version: &Version) -> bool {
1252-
use semver::{Comparator, Op, Prerelease};
1253-
1254-
Comparator {
1255-
op: Op::Less,
1256-
major: 1,
1257-
minor: Some(4),
1258-
patch: Some(8),
1259-
pre: Prerelease::EMPTY,
1260-
}
1261-
.matches(version)
1262-
}
1263-
12641251
if unit.pkg.name() != "diesel"
1265-
|| !is_broken_diesel(unit.pkg.version())
1252+
|| unit.pkg.version() >= &Version::new(1, 4, 8)
12661253
|| cx.bcx.ws.resolve_behavior() == ResolveBehavior::V1
12671254
|| !unit.pkg.package_id().source_id().is_registry()
12681255
|| !unit.features.is_empty()

src/cargo/ops/fix.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuild
5050
use log::{debug, trace, warn};
5151
use rustfix::diagnostics::Diagnostic;
5252
use rustfix::{self, CodeFix};
53-
use semver::{Comparator, Op, Prerelease};
53+
use semver::Version;
5454

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

324324
fn report_maybe_diesel(config: &Config, resolve: &Resolve) -> CargoResult<()> {
325325
fn is_broken_diesel(pid: PackageId) -> bool {
326-
if pid.name() != "diesel" {
327-
return false;
328-
}
329-
Comparator {
330-
op: Op::Less,
331-
major: 1,
332-
minor: Some(4),
333-
patch: Some(8),
334-
pre: Prerelease::EMPTY,
335-
}
336-
.matches(pid.version())
326+
pid.name() == "diesel" && pid.version() < &Version::new(1, 4, 8)
337327
}
338328

339329
fn is_broken_diesel_migration(pid: PackageId) -> bool {

0 commit comments

Comments
 (0)