Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bf10cc2

Browse files
committedApr 25, 2024
Add a flag for pretending to be a stable compiler when bisecting.
1 parent 4facc9a commit bf10cc2

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
@@ -149,6 +149,13 @@ struct Opts {
149149
)]
150150
command_args: Vec<OsString>,
151151

152+
#[arg(
153+
long,
154+
help = "Pretend to be a stable compiler (disable features, \
155+
report a version that looks like a stable version)"
156+
)]
157+
pretend_to_be_stable: bool,
158+
152159
#[arg(
153160
long,
154161
help = "Left bound for search (*without* regression). You can use \

‎src/toolchains.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,29 @@ impl Toolchain {
313313
}
314314

315315
fn set_cargo_args_and_envs(&self, cmd: &mut Command, cfg: &Config) {
316-
cmd.arg(&format!("+{}", self.rustup_name()));
316+
let rustup_name = format!("+{}", self.rustup_name());
317+
cmd.arg(&rustup_name);
317318
if cfg.args.command_args.is_empty() {
318319
cmd.arg("build");
319320
} else {
320321
cmd.args(&cfg.args.command_args);
321322
}
323+
if cfg.args.pretend_to_be_stable && self.is_current_nightly() {
324+
// Forbid using features
325+
cmd.env(
326+
"RUSTFLAGS",
327+
format!(
328+
"{} -Zenable-features=",
329+
std::env::var("RUSTFLAGS").unwrap_or_default()
330+
),
331+
);
332+
// Make rustc report a stable version string derived from the current nightly's version string.
333+
let version = rustc_version::version_meta().unwrap().semver;
334+
cmd.env(
335+
"RUSTC_FORCE_RUSTC_VERSION",
336+
format!("{}.{}.{}", version.major, version.minor, version.patch),
337+
);
338+
}
322339
}
323340

324341
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)
Please sign in to comment.