Skip to content

Commit 5144b2e

Browse files
committed
Simplify code for picking previous date
1 parent 8c3f6c5 commit 5144b2e

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/dist/dist.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -646,29 +646,18 @@ fn update_from_dist_<'a>(
646646
// try is _older_ than the current nightly, since we know that the user's current
647647
// nightlys supports the components they have installed, and thus would always
648648
// terminate the search.
649-
if let Some(ref mut date) = toolchain.date {
650-
// recurse
651-
toolchain.date = Some(
652-
Utc.from_utc_date(
653-
&NaiveDate::parse_from_str(date, "%Y-%m-%d")
654-
.expect("we constructed this date string below"),
649+
toolchain.date = Some(
650+
Utc.from_utc_date(
651+
&NaiveDate::parse_from_str(
652+
toolchain.date.as_ref().unwrap_or(&fetched),
653+
"%Y-%m-%d",
655654
)
656-
.pred()
657-
.format("%Y-%m-%d")
658-
.to_string(),
659-
);
660-
} else {
661-
// Pick a nightly that is one day older than the latest.
662-
toolchain.date = Some(
663-
Utc.from_utc_date(
664-
&NaiveDate::parse_from_str(&fetched, "%Y-%m-%d")
665-
.expect("manifest carries invalid date"),
666-
)
667-
.pred()
668-
.format("%Y-%m-%d")
669-
.to_string(),
670-
);
671-
}
655+
.expect("Malformed manifest date"),
656+
)
657+
.pred()
658+
.format("%Y-%m-%d")
659+
.to_string(),
660+
);
672661
}
673662
}
674663
}

0 commit comments

Comments
 (0)