Skip to content

Commit 400221e

Browse files
committed
Auto merge of #7411 - Eh2406:mtime, r=alexcrichton
set -Zmtime_on_use from config or ENV This lets you set the `-Zmtime_on_use` in config, it worked for me with ```toml [unstable] mtime_on_use=true ``` I did not find the ENV that would allow work. Suggestions? Does this need tests? Closes: #6978
2 parents aa6b7e0 + 473f999 commit 400221e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/cargo/core/features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ impl CliUnstable {
386386
"advanced-env" => self.advanced_env = true,
387387
"config-profile" => self.config_profile = true,
388388
"dual-proc-macros" => self.dual_proc_macros = true,
389+
// can also be set in .cargo/config or with and ENV
389390
"mtime-on-use" => self.mtime_on_use = true,
390391
"install-upgrade" => self.install_upgrade = true,
391392
"cache-messages" => self.cache_messages = true,

src/cargo/util/config.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use url::Url;
2323
use self::ConfigValue as CV;
2424
use crate::core::profiles::ConfigProfiles;
2525
use crate::core::shell::Verbosity;
26-
use crate::core::{CliUnstable, Shell, SourceId, Workspace};
26+
use crate::core::{nightly_features_allowed, CliUnstable, Shell, SourceId, Workspace};
2727
use crate::ops;
2828
use crate::util::errors::{self, internal, CargoResult, CargoResultExt};
2929
use crate::util::toml as cargo_toml;
@@ -626,6 +626,12 @@ impl Config {
626626
self.target_dir = cli_target_dir;
627627
self.cli_flags.parse(unstable_flags)?;
628628

629+
if nightly_features_allowed() {
630+
if let Some(val) = self.get::<Option<bool>>("unstable.mtime_on_use")? {
631+
self.cli_flags.mtime_on_use |= val;
632+
}
633+
}
634+
629635
Ok(())
630636
}
631637

src/doc/src/reference/unstable.md

+11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ the registry index. This is intended for tools such as Crater that issue many
1919
Cargo commands, and you want to avoid the network latency for updating the
2020
index each time.
2121

22+
### mtime-on-use
23+
* Original Issue: [#6477](https://github.com/rust-lang/cargo/pull/6477)
24+
* Cache usage meta tracking issue: [#7150](https://github.com/rust-lang/cargo/issues/7150)
25+
26+
The `-Z mtime-on-use` flag is an experiment to have Cargo update the mtime of
27+
used files to make it easier for tools like cargo-sweep to detect which files
28+
are stale. For many workflows this needs to be set on *all* invocations of cargo.
29+
To make this more practical setting the `unstable.mtime_on_use` flag in `.cargo/config`
30+
or the corresponding ENV variable will apply the `-Z mtime-on-use` to all
31+
invocations of nightly cargo. (the config flag is ignored by stable)
32+
2233
### avoid-dev-deps
2334
* Original Issue: [#4988](https://github.com/rust-lang/cargo/issues/4988)
2435
* Stabilization Issue: [#5133](https://github.com/rust-lang/cargo/issues/5133)

0 commit comments

Comments
 (0)