Skip to content

Commit 23d91e2

Browse files
authored
Rollup merge of rust-lang#60805 - euclio:filetime-dep, r=Mark-Simulacrum
remove compiletest's dependency on `filetime`
2 parents a925973 + 01bc58c commit 23d91e2

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ version = "0.0.0"
475475
dependencies = [
476476
"diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
477477
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
478-
"filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
479478
"getopts 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
480479
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
481480
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",

src/tools/compiletest/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2018"
77
[dependencies]
88
diff = "0.1.10"
99
env_logger = { version = "0.5", default-features = false }
10-
filetime = "0.2"
1110
getopts = "0.2"
1211
log = "0.4"
1312
regex = "1.0"

src/tools/compiletest/src/main.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use crate::common::CompareMode;
99
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
1010
use crate::common::{Config, TestPaths};
1111
use crate::common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
12-
use filetime::FileTime;
1312
use getopts::Options;
1413
use std::env;
1514
use std::ffi::OsString;
1615
use std::fs;
1716
use std::io::{self, ErrorKind};
1817
use std::path::{Path, PathBuf};
1918
use std::process::Command;
19+
use std::time::SystemTime;
2020
use test::ColorConfig;
2121
use crate::util::logv;
2222
use walkdir::WalkDir;
@@ -752,31 +752,36 @@ fn up_to_date(
752752

753753
#[derive(Debug, PartialEq, PartialOrd, Ord, Eq)]
754754
struct Stamp {
755-
time: FileTime,
755+
time: SystemTime,
756756
file: PathBuf,
757757
}
758758

759759
impl Stamp {
760760
fn from_path(p: &Path) -> Self {
761+
let time = fs::metadata(p)
762+
.and_then(|metadata| metadata.modified())
763+
.unwrap_or(SystemTime::UNIX_EPOCH);
764+
761765
Stamp {
762-
time: mtime(&p),
766+
time,
763767
file: p.into(),
764768
}
765769
}
766770

767-
fn from_dir(path: &Path) -> impl Iterator<Item=Stamp> {
771+
fn from_dir(path: &Path) -> impl Iterator<Item = Stamp> {
768772
WalkDir::new(path)
769773
.into_iter()
770774
.map(|entry| entry.unwrap())
771775
.filter(|entry| entry.file_type().is_file())
772-
.map(|entry| Stamp::from_path(entry.path()))
773-
}
774-
}
776+
.map(|entry| {
777+
let time = (|| -> io::Result<_> { entry.metadata()?.modified() })();
775778

776-
fn mtime(path: &Path) -> FileTime {
777-
fs::metadata(path)
778-
.map(|f| FileTime::from_last_modification_time(&f))
779-
.unwrap_or_else(|_| FileTime::zero())
779+
Stamp {
780+
time: time.unwrap_or(SystemTime::UNIX_EPOCH),
781+
file: entry.path().into(),
782+
}
783+
})
784+
}
780785
}
781786

782787
fn make_test_name(

src/tools/compiletest/src/runtest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::common::{Config, TestPaths};
99
use crate::common::{Incremental, MirOpt, RunMake, Ui, JsDocTest, Assembly};
1010
use diff;
1111
use crate::errors::{self, Error, ErrorKind};
12-
use filetime::FileTime;
1312
use crate::header::TestProps;
1413
use crate::json;
1514
use regex::{Captures, Regex};
@@ -3029,7 +3028,7 @@ impl<'test> TestCx<'test> {
30293028
}
30303029

30313030
fn check_mir_test_timestamp(&self, test_name: &str, output_file: &Path) {
3032-
let t = |file| FileTime::from_last_modification_time(&fs::metadata(file).unwrap());
3031+
let t = |file| fs::metadata(file).unwrap().modified().unwrap();
30333032
let source_file = &self.testpaths.file;
30343033
let output_time = t(output_file);
30353034
let source_time = t(source_file);

0 commit comments

Comments
 (0)