Skip to content

Commit 2107a43

Browse files
committed
refactor(update): Clarify what each checks intention is
1 parent 9d5c149 commit 2107a43

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/cargo/ops/cargo_update.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
774774
let version_req = package_id.version().to_caret_req();
775775
let required_rust_version = change.required_rust_version.as_ref();
776776

777-
if let Some(summary) = possibilities
777+
let compat_ver_compat_msrv_summary = possibilities
778778
.iter()
779779
.map(|s| s.as_summary())
780780
.filter(|s| {
@@ -787,15 +787,15 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
787787
}
788788
})
789789
.filter(|s| package_id.version() != s.version() && version_req.matches(s.version()))
790-
.max_by_key(|s| s.version())
791-
{
790+
.max_by_key(|s| s.version());
791+
if let Some(summary) = compat_ver_compat_msrv_summary {
792792
let warn = style::WARN;
793793
let version = summary.version();
794794
let report = format!(" {warn}(available: v{version}){warn:#}");
795795
return Some(report);
796796
}
797797

798-
if let Some(summary) = possibilities
798+
let incompat_ver_compat_msrv_summary = possibilities
799799
.iter()
800800
.map(|s| s.as_summary())
801801
.filter(|s| {
@@ -808,8 +808,8 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
808808
}
809809
})
810810
.filter(|s| is_latest(s.version(), package_id.version()))
811-
.max_by_key(|s| s.version())
812-
{
811+
.max_by_key(|s| s.version());
812+
if let Some(summary) = incompat_ver_compat_msrv_summary {
813813
let warn = if change.is_transitive.unwrap_or(true) {
814814
Default::default()
815815
} else {
@@ -820,12 +820,12 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
820820
return Some(report);
821821
}
822822

823-
if let Some(summary) = possibilities
823+
let compat_ver_summary = possibilities
824824
.iter()
825825
.map(|s| s.as_summary())
826826
.filter(|s| package_id.version() != s.version() && version_req.matches(s.version()))
827-
.max_by_key(|s| s.version())
828-
{
827+
.max_by_key(|s| s.version());
828+
if let Some(summary) = compat_ver_summary {
829829
let msrv_note = summary
830830
.rust_version()
831831
.map(|rv| format!(", requires Rust {rv}"))
@@ -836,12 +836,12 @@ fn report_latest(possibilities: &[IndexSummary], change: &PackageChange) -> Opti
836836
return Some(report);
837837
}
838838

839-
if let Some(summary) = possibilities
839+
let incompat_ver_summary = possibilities
840840
.iter()
841841
.map(|s| s.as_summary())
842842
.filter(|s| is_latest(s.version(), package_id.version()))
843-
.max_by_key(|s| s.version())
844-
{
843+
.max_by_key(|s| s.version());
844+
if let Some(summary) = incompat_ver_summary {
845845
let msrv_note = summary
846846
.rust_version()
847847
.map(|rv| format!(", requires Rust {rv}"))

0 commit comments

Comments
 (0)