Skip to content

Commit ab09b6a

Browse files
committed
Use the new RUSTC_OVERRIDE_VERSION_STRING env var
Add a flag for pretending to be a stable compiler when bisecting.
1 parent 11502b1 commit ab09b6a

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

src/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ struct Opts {
153153
)]
154154
command_args: Vec<OsString>,
155155

156+
#[arg(
157+
long,
158+
help = "Pretend to be a stable compiler (disable features, \
159+
report a version that looks like a stable version)"
160+
)]
161+
pretend_to_be_stable: bool,
162+
156163
#[arg(
157164
long,
158165
help = "Left bound for search (*without* regression). You can use \

src/toolchains.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,29 @@ impl Toolchain {
317317
}
318318

319319
fn set_cargo_args_and_envs(&self, cmd: &mut Command, cfg: &Config) {
320-
cmd.arg(&format!("+{}", self.rustup_name()));
320+
let rustup_name = format!("+{}", self.rustup_name());
321+
cmd.arg(&rustup_name);
321322
if cfg.args.command_args.is_empty() {
322323
cmd.arg("build");
323324
} else {
324325
cmd.args(&cfg.args.command_args);
325326
}
327+
if cfg.args.pretend_to_be_stable && self.is_current_nightly() {
328+
// Forbid using features
329+
cmd.env(
330+
"RUSTFLAGS",
331+
format!(
332+
"{} -Zallow-features=",
333+
std::env::var("RUSTFLAGS").unwrap_or_default()
334+
),
335+
);
336+
// Make rustc report a stable version string derived from the current nightly's version string.
337+
let version = rustc_version::version_meta().unwrap().semver;
338+
cmd.env(
339+
"RUSTC_OVERRIDE_VERSION_STRING",
340+
format!("{}.{}.{}", version.major, version.minor, version.patch),
341+
);
342+
}
326343
}
327344

328345
pub(crate) fn test(&self, cfg: &Config) -> TestOutcome {

tests/cmd/h.stdout

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Options:
1919
--install <INSTALL> Install the given artifact
2020
--preserve Preserve the downloaded artifacts
2121
--preserve-target Preserve the target directory used for builds
22+
--pretend-to-be-stable Pretend to be a stable compiler (disable features, report a version
23+
that looks like a stable version)
2224
--prompt Manually evaluate for regression with prompts
2325
--regress <REGRESS> Custom regression definition [default: error] [possible values:
2426
error, success, ice, non-ice, non-error]

tests/cmd/help.stdout

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ Options:
4646
--preserve-target
4747
Preserve the target directory used for builds
4848

49+
--pretend-to-be-stable
50+
Pretend to be a stable compiler (disable features, report a version that looks like a
51+
stable version)
52+
4953
--prompt
5054
Manually evaluate for regression with prompts
5155

0 commit comments

Comments
 (0)