Skip to content

Commit 52b9e6d

Browse files
authored
Merge pull request #3194 from ehuss/chrono-deprecated
Fix chrono deprecation warnings
2 parents b842e57 + 6372b33 commit 52b9e6d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/dist/dist.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::Path;
77
use std::str::FromStr;
88

99
use anyhow::{anyhow, bail, Context, Result};
10-
use chrono::{Date, NaiveDate, TimeZone, Utc};
10+
use chrono::NaiveDate;
1111
use lazy_static::lazy_static;
1212
use regex::Regex;
1313
use thiserror::Error as ThisError;
@@ -734,9 +734,9 @@ fn update_from_dist_<'a>(
734734
//
735735
// We could arguably use the date of the first rustup release here, but that would break a
736736
// bunch of the tests, which (inexplicably) use 2015-01-01 as their manifest dates.
737-
let first_manifest = Utc.from_utc_date(&NaiveDate::from_ymd(2014, 12, 20));
737+
let first_manifest = date_from_manifest_date("2014-12-20").unwrap();
738738
let old_manifest = old_date
739-
.and_then(utc_from_manifest_date)
739+
.and_then(date_from_manifest_date)
740740
.unwrap_or(first_manifest);
741741
let last_manifest = if allow_downgrade {
742742
first_manifest
@@ -808,9 +808,10 @@ fn update_from_dist_<'a>(
808808
// nightlies in reverse chronological order until we find a nightly that does,
809809
// starting at one date earlier than the current manifest's date.
810810
let toolchain_date = toolchain.date.as_ref().unwrap_or(&fetched);
811-
let try_next = utc_from_manifest_date(toolchain_date)
811+
let try_next = date_from_manifest_date(toolchain_date)
812812
.unwrap_or_else(|| panic!("Malformed manifest date: {toolchain_date:?}"))
813-
.pred();
813+
.pred_opt()
814+
.unwrap();
814815

815816
if try_next < last_manifest {
816817
// Wouldn't be an update if we go further back than the user's current nightly.
@@ -1071,10 +1072,8 @@ fn dl_v1_manifest(download: DownloadCfg<'_>, toolchain: &ToolchainDesc) -> Resul
10711072
Ok(urls)
10721073
}
10731074

1074-
fn utc_from_manifest_date(date_str: &str) -> Option<Date<Utc>> {
1075-
NaiveDate::parse_from_str(date_str, "%Y-%m-%d")
1076-
.ok()
1077-
.map(|date| Utc.from_utc_date(&date))
1075+
fn date_from_manifest_date(date_str: &str) -> Option<NaiveDate> {
1076+
NaiveDate::parse_from_str(date_str, "%Y-%m-%d").ok()
10781077
}
10791078

10801079
#[cfg(test)]

0 commit comments

Comments
 (0)