diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 4f1ad49c016..3738bcdd9ca 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -756,12 +756,7 @@ impl Fingerprint { /// dependencies up to this unit as well. This function assumes that the /// unit starts out as `FsStatus::Stale` and then it will optionally switch /// it to `UpToDate` if it can. - fn check_filesystem( - &mut self, - pkg_root: &Path, - target_root: &Path, - mtime_on_use: bool, - ) -> CargoResult<()> { + fn check_filesystem(&mut self, pkg_root: &Path, target_root: &Path) -> CargoResult<()> { assert!(!self.fs_status.up_to_date()); let mut mtimes = HashMap::new(); @@ -781,10 +776,6 @@ impl Fingerprint { return Ok(()); } }; - if mtime_on_use { - let t = FileTime::from_system_time(SystemTime::now()); - filetime::set_file_times(output, t, t)?; - } assert!(mtimes.insert(output.clone(), mtime).is_none()); } @@ -1024,8 +1015,7 @@ fn calculate<'a, 'cfg>( // After we built the initial `Fingerprint` be sure to update the // `fs_status` field of it. let target_root = target_root(cx, unit); - let mtime_on_use = cx.bcx.config.cli_unstable().mtime_on_use; - fingerprint.check_filesystem(unit.pkg.root(), &target_root, mtime_on_use)?; + fingerprint.check_filesystem(unit.pkg.root(), &target_root)?; let fingerprint = Arc::new(fingerprint); cx.fingerprints.insert(*unit, Arc::clone(&fingerprint)); diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 6d3de5d30f6..e87cc895e30 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1170,31 +1170,8 @@ fn changing_rustflags_is_cached() { .run(); } -fn simple_deps_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) { - // Cargo is experimenting with letting outside projects develop some - // limited forms of GC for target_dir. This is one of the forms. - // Specifically, Cargo is updating the mtime of files in - // target/profile/deps each time it uses the file. - // So a cleaner can remove files older then a time stamp without - // effecting any builds that happened since that time stamp. - let mut cleand = false; - dir.push("deps"); - for dep in fs::read_dir(&dir).unwrap() { - let dep = dep.unwrap(); - if filetime::FileTime::from_last_modification_time(&dep.metadata().unwrap()) <= timestamp { - fs::remove_file(dep.path()).unwrap(); - println!("remove: {:?}", dep.path()); - cleand = true; - } - } - assert!( - cleand, - "called simple_deps_cleaner, but there was nothing to remove" - ); -} - #[cargo_test] -fn simple_deps_cleaner_does_not_rebuild() { +fn update_dependency_mtime_does_not_rebuild() { let p = project() .file( "Cargo.toml", @@ -1212,9 +1189,6 @@ fn simple_deps_cleaner_does_not_rebuild() { .file("bar/src/lib.rs", "") .build(); - p.cargo("build -Z mtime-on-use") - .masquerade_as_nightly_cargo() - .run(); p.cargo("build -Z mtime-on-use") .masquerade_as_nightly_cargo() .env("RUSTFLAGS", "-C target-cpu=native") @@ -1225,36 +1199,18 @@ fn simple_deps_cleaner_does_not_rebuild() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", ) .run(); - if is_coarse_mtime() { - sleep_ms(1000); - } - let timestamp = filetime::FileTime::from_system_time(SystemTime::now()); - if is_coarse_mtime() { - sleep_ms(1000); - } - // This does not make new files, but it does update the mtime. - p.cargo("build -Z mtime-on-use") + // This does not make new files, but it does update the mtime of the dependency. + p.cargo("build -p bar -Z mtime-on-use") .masquerade_as_nightly_cargo() .env("RUSTFLAGS", "-C target-cpu=native") .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]") .run(); - simple_deps_cleaner(p.target_debug_dir(), timestamp); // This should not recompile! p.cargo("build -Z mtime-on-use") .masquerade_as_nightly_cargo() .env("RUSTFLAGS", "-C target-cpu=native") .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]") .run(); - // But this should be cleaned and so need a rebuild - p.cargo("build -Z mtime-on-use") - .masquerade_as_nightly_cargo() - .with_stderr( - "\ -[COMPILING] bar v0.0.1 ([..]) -[COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ) - .run(); } fn fingerprint_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) {