Skip to content

Commit 7951bbb

Browse files
committed
Add -Zgc flag.
This adds the -Zgc flag in preparation to support garbage-collection. This also factors out the `fail_if_stable_opt_custom_z` function which will be used by the unstable gc checks.
1 parent 8a2a920 commit 7951bbb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/cargo/core/features.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ unstable_cli_options!(
734734
doctest_xcompile: bool = ("Compile and run doctests for non-host target using runner config"),
735735
dual_proc_macros: bool = ("Build proc-macros for both the host and the target"),
736736
features: Option<Vec<String>> = (HIDDEN),
737+
gc: bool = ("Track cache usage and \"garbage collect\" unused files"),
737738
gitoxide: Option<GitoxideFeatures> = ("Use gitoxide for the given git interactions, or all of them if no argument is given"),
738739
host_config: bool = ("Enable the [host] section in the .cargo/config.toml file"),
739740
lints: bool = ("Pass `[lints]` to the linting tools"),
@@ -1105,6 +1106,7 @@ impl CliUnstable {
11051106
"direct-minimal-versions" => self.direct_minimal_versions = parse_empty(k, v)?,
11061107
"doctest-xcompile" => self.doctest_xcompile = parse_empty(k, v)?,
11071108
"dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?,
1109+
"gc" => self.gc = parse_empty(k, v)?,
11081110
"gitoxide" => {
11091111
self.gitoxide = v.map_or_else(
11101112
|| Ok(Some(GitoxideFeatures::all())),
@@ -1139,7 +1141,17 @@ impl CliUnstable {
11391141
/// Generates an error if `-Z unstable-options` was not used for a new,
11401142
/// unstable command-line flag.
11411143
pub fn fail_if_stable_opt(&self, flag: &str, issue: u32) -> CargoResult<()> {
1142-
if !self.unstable_options {
1144+
self.fail_if_stable_opt_custom_z(flag, issue, "unstable-options", self.unstable_options)
1145+
}
1146+
1147+
pub fn fail_if_stable_opt_custom_z(
1148+
&self,
1149+
flag: &str,
1150+
issue: u32,
1151+
z_name: &str,
1152+
enabled: bool,
1153+
) -> CargoResult<()> {
1154+
if !enabled {
11431155
let see = format!(
11441156
"See https://github.com/rust-lang/cargo/issues/{issue} for more \
11451157
information about the `{flag}` flag."
@@ -1148,7 +1160,7 @@ impl CliUnstable {
11481160
let channel = channel();
11491161
if channel == "nightly" || channel == "dev" {
11501162
bail!(
1151-
"the `{flag}` flag is unstable, pass `-Z unstable-options` to enable it\n\
1163+
"the `{flag}` flag is unstable, pass `-Z {z_name}` to enable it\n\
11521164
{see}"
11531165
);
11541166
} else {

0 commit comments

Comments
 (0)