Skip to content

Commit 1616881

Browse files
committed
refactor: Clarify some variable names
1 parent 46584a4 commit 1616881

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

src/cargo/ops/cargo_add/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,11 +702,16 @@ ignoring {dependency}@{latest_version} (which requires rustc {latest_rust_versio
702702
/// - `msrvs` is sorted by version
703703
fn latest_compatible<'s>(
704704
msrvs: &[(&'s Summary, Option<&RustVersion>)],
705-
req_msrv: &RustVersion,
705+
pkg_msrv: &RustVersion,
706706
) -> Option<&'s Summary> {
707707
msrvs
708708
.iter()
709-
.filter(|(_, v)| v.as_ref().map(|msrv| req_msrv >= *msrv).unwrap_or(true))
709+
.filter(|(_, dep_msrv)| {
710+
dep_msrv
711+
.as_ref()
712+
.map(|dep_msrv| pkg_msrv >= *dep_msrv)
713+
.unwrap_or(true)
714+
})
710715
.map(|(s, _)| s)
711716
.last()
712717
.copied()

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,34 +481,34 @@ pub fn create_bcx<'a, 'gctx>(
481481

482482
if honor_rust_version {
483483
// Remove any pre-release identifiers for easier comparison
484-
let current_version = &target_data.rustc.version;
485-
let untagged_version = semver::Version::new(
486-
current_version.major,
487-
current_version.minor,
488-
current_version.patch,
484+
let rustc_version = &target_data.rustc.version;
485+
let rustc_version_untagged = semver::Version::new(
486+
rustc_version.major,
487+
rustc_version.minor,
488+
rustc_version.patch,
489489
);
490490

491491
let mut incompatible = Vec::new();
492492
let mut local_incompatible = false;
493493
for unit in unit_graph.keys() {
494-
let Some(version) = unit.pkg.rust_version() else {
494+
let Some(pkg_msrv) = unit.pkg.rust_version() else {
495495
continue;
496496
};
497497

498-
let req = version.to_caret_req();
499-
if req.matches(&untagged_version) {
498+
let pkg_msrv_req = pkg_msrv.to_caret_req();
499+
if pkg_msrv_req.matches(&rustc_version_untagged) {
500500
continue;
501501
}
502502

503503
local_incompatible |= unit.is_local();
504-
incompatible.push((unit, version));
504+
incompatible.push((unit, pkg_msrv));
505505
}
506506
if !incompatible.is_empty() {
507507
use std::fmt::Write as _;
508508

509509
let plural = if incompatible.len() == 1 { "" } else { "s" };
510510
let mut message = format!(
511-
"rustc {current_version} is not supported by the following package{plural}:\n"
511+
"rustc {rustc_version} is not supported by the following package{plural}:\n"
512512
);
513513
incompatible.sort_by_key(|(unit, _)| (unit.pkg.name(), unit.pkg.version()));
514514
for (unit, msrv) in incompatible {
@@ -529,7 +529,7 @@ pub fn create_bcx<'a, 'gctx>(
529529
&mut message,
530530
"Either upgrade rustc or select compatible dependency versions with
531531
`cargo update <name>@<current-ver> --precise <compatible-ver>`
532-
where `<compatible-ver>` is the latest version supporting rustc {current_version}",
532+
where `<compatible-ver>` is the latest version supporting rustc {rustc_version}",
533533
)
534534
.unwrap();
535535
}

src/cargo/util/toml/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -580,32 +580,32 @@ pub fn to_real_manifest(
580580
.parse()
581581
.with_context(|| "failed to parse the `edition` key")?;
582582
package.edition = Some(manifest::InheritableField::Value(edition.to_string()));
583-
if let Some(rust_version) = &rust_version {
584-
let req = rust_version.to_caret_req();
585-
if let Some(first_version) = edition.first_version() {
583+
if let Some(pkg_msrv) = &rust_version {
584+
let pkg_msrv_req = pkg_msrv.to_caret_req();
585+
if let Some(edition_msrv) = edition.first_version() {
586586
let unsupported =
587-
semver::Version::new(first_version.major, first_version.minor - 1, 9999);
588-
if req.matches(&unsupported) {
587+
semver::Version::new(edition_msrv.major, edition_msrv.minor - 1, 9999);
588+
if pkg_msrv_req.matches(&unsupported) {
589589
bail!(
590590
"rust-version {} is older than first version ({}) required by \
591591
the specified edition ({})",
592-
rust_version,
593-
first_version,
592+
pkg_msrv,
593+
edition_msrv,
594594
edition,
595595
)
596596
}
597597
}
598598
}
599599
edition
600600
} else {
601-
let msrv_edition = if let Some(rust_version) = &rust_version {
601+
let msrv_edition = if let Some(pkg_msrv) = &rust_version {
602602
Edition::ALL
603603
.iter()
604604
.filter(|e| {
605605
e.first_version()
606-
.map(|e| {
607-
let e = PartialVersion::from(e);
608-
e <= **rust_version
606+
.map(|edition_msrv| {
607+
let edition_msrv = PartialVersion::from(edition_msrv);
608+
edition_msrv <= **pkg_msrv
609609
})
610610
.unwrap_or_default()
611611
})

0 commit comments

Comments
 (0)