Skip to content

Add new RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags mode for testing stable compiler behavior in UI tests - #163664

Merged
rust-bors[bot] merged 10 commits into
rust-lang:mainfrom
Kobzol:bootstrap-but-this-time-for-real-2
Oct 21, 2026
Merged

rust-bors[bot] merged 10 commits into
rust-lang:mainfrom
Kobzol:bootstrap-but-this-time-for-real-2

Conversation

@Kobzol

@Kobzol Kobzol commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

View all comments

Right now, it is not possible to test how the compiler behaves on the stable toolchain in UI tests. Even though #132993 added a mechanism to emulate stable rustc on the nightly channel, using the RUSTC_BOOTSTRAP=-1 environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable -Z flags that are load-bearing for the testing infra itself to work (notably -Zui-testing and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as run-make tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added #163444 as a way of centralizing the logic of testing a stable rustc in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For #162848, I would also like to have a way of passing -Zthreads=1 to all run-make tests, even if they are testing stable rustc, but that's not easily possible, because those tests are using RUSTC_BOOTSTRAP=-1.

This PR proposes to add a new mode to RUSTC_BOOTSTRAP, with the value of -allow-unstable-compiler-flags=<flags>. This can be used to emulate the behavior of stable rustc, while still allowing passing specific unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:

  • Are we an unstable/nightly build?
  • Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, act-as-stable. That can be used in a UI test to emulate stable rustc. Some tests before used only-stable to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing RUSTC_BOOTSTRAP=1 to all executed tests. act-as-stable fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of rust-lang/rust, but if you don't want that, I can gate it behind -Zui-testing.

r? jieyouxu

@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

The rustc-dev-guide subtree was changed. If your future PRs only touch the subtree, consider submitting them directly to rust-lang/rustc-dev-guide, which is where the document is primarily maintained (and has faster CI).

cc @BoxyUwU, @tshepang

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 2, 2026
@rust-log-analyzer

This comment has been minimized.

@bjorn3

bjorn3 commented Oct 2, 2026

Copy link
Copy Markdown
Member

You can probably remove

rm -r tests/run-make/missing-unstable-trait-bound # This disables support for unstable features, but running cg_clif needs some unstable features
rm -r tests/run-make/const-trait-stable-toolchain # same
rm -r tests/run-make/print-request-help-stable-unstable # same
rm -r tests/run-make/issue-149402-suggest-unresolve # same
rm -r tests/run-make/const-destruct-stable-toolchain # same
rm -r tests/run-make/unstable-target-feature # same

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@Kobzol
Kobzol force-pushed the bootstrap-but-this-time-for-real-2 branch from 9565273 to a36b6f8 Compare October 4, 2026 11:59
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Kobzol
Kobzol force-pushed the bootstrap-but-this-time-for-real-2 branch from a36b6f8 to 8e072e8 Compare October 4, 2026 17:58
@rust-bors

This comment has been minimized.

@Kobzol
Kobzol force-pushed the bootstrap-but-this-time-for-real-2 branch from 8e072e8 to 0c3b3be Compare October 12, 2026 06:54
@rustbot

rustbot commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@petrochenkov petrochenkov self-assigned this Oct 12, 2026

@jieyouxu jieyouxu left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General idea makes sense to me. Some discussions

View changes since this review

Comment thread compiler/rustc_feature/src/lib.rs Outdated
Comment thread compiler/rustc_feature/src/tests.rs Outdated
Comment thread src/doc/rustc-dev-guide/src/tests/misc.md Outdated
Comment thread src/tools/compiletest/src/directives/directive_names.rs
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
…-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though rust-lang#132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added rust-lang#163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For rust-lang#162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #163575 (core: Add examples and assembly tests for `abort_immediate`)
 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163338 (MIR move elimination [4/6]: MoveElimination)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
…-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though rust-lang#132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added rust-lang#163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For rust-lang#162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #163575 (core: Add examples and assembly tests for `abort_immediate`)
 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163338 (MIR move elimination [4/6]: MoveElimination)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164578 (Don't ignore unknown LLVM diagnostics)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
…-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though rust-lang#132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added rust-lang#163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For rust-lang#162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163338 (MIR move elimination [4/6]: MoveElimination)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164578 (Don't ignore unknown LLVM diagnostics)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163338 (MIR move elimination [4/6]: MoveElimination)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164578 (Don't ignore unknown LLVM diagnostics)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
…-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though rust-lang#132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added rust-lang#163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For rust-lang#162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163338 (MIR move elimination [4/6]: MoveElimination)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
…-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though rust-lang#132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added rust-lang#163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For rust-lang#162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 20, 2026
…-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though rust-lang#132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added rust-lang#163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For rust-lang#162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
rust-bors Bot pushed a commit that referenced this pull request Oct 20, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - #160404 (fd-views: AsRef<File>&Co. for BorrowedFd)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164641 (Stabilize `slice_split_once`)
 - #164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup of 20 pull requests

Successful merges:

 - #163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - #163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - #163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - #163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - #163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - #164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - #164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - #164611 (Improve bit permutation codegen)
 - #164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - #148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - #162668 (document that `!` does bitwise and logical negation)
 - #164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - #164509 (layout invariant: turn delayed bug back into proper assertion)
 - #164540 (Minor optimizations around macro parsing)
 - #164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - #164595 (Allow attributes in function trait parameters)
 - #164616 (Add test for VecDeque with a custom allocator)
 - #164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - #164641 (Stabilize `slice_split_once`)
 - #164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
rust-bors Bot pushed a commit that referenced this pull request Oct 21, 2026
Rollup merge of #163664 - Kobzol:bootstrap-but-this-time-for-real-2, r=jieyouxu

Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests

Right now, it is [not possible](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707) to test how the compiler behaves on the stable toolchain in UI tests. Even though #132993 added a mechanism to emulate stable rustc on the nightly channel, using the `RUSTC_BOOTSTRAP=-1` environment variable, this mechanism is not currently usable within compiletest and UI tests directly, because compiletest unconditionally passes several unstable `-Z` flags that are load-bearing for the testing infra itself to work (notably `-Zui-testing` and friends).

That is quite annoying, because we do in fact want to test stable behavior in a couple of tests, but today we have to write those as `run-make` tests (latest example: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Testing.20stable.20vs.20nightly.20behavior.20in.20UI.20tests/with/628206707), even if the tested situation is very simple. Those are harder to read, write and maintain than UI tests and they do not support blessing outputs as well as UI tests. Recently, I at least added #163444 as a way of centralizing the logic of testing a stable `rustc` in a run-make test, but that does not really help with the fact that we still have to use run-make tests for it, even when a normal UI test would do.

For #162848, I would also like to have a way of passing `-Zthreads=1` to all run-make tests, even if they are testing stable `rustc`, but that's not easily possible, because those tests are using `RUSTC_BOOTSTRAP=-1`.

This PR proposes to add a new mode to `RUSTC_BOOTSTRAP`, with the value of `-allow-unstable-compiler-flags=<flags>`. This can be used to emulate the behavior of stable rustc, while still allowing passing *specific* unstable flags to the compiler.

The stability check in the compiler is thus now separated into two questions:
- Are we an unstable/nightly build?
- Can we accept specific unstable compiler flags?

The latter is checked only at a few places, so the necessary change to the compiler is rather small (IMO).

To demonstrate how this would be used, I also implemented a new directive into compiletest in this PR, `act-as-stable`. That can be used in a UI test to emulate stable rustc. Some tests before used `only-stable` to "achieve" this, which is very misleading, because it doesn't work at all 😆, due to compiletest unconditionally passing `RUSTC_BOOTSTRAP=1` to all executed tests. `act-as-stable` fixes that.

The last two commits demonstrate how we could replace run-make tests that tested different output on stable/nightly with UI tests.

I suppose that this mode might be interesting for other people outside of `rust-lang/rust`, but if you don't want that, I can gate it behind `-Zui-testing`.

r? jieyouxu
@rust-bors
rust-bors Bot merged commit 5232c49 into rust-lang:main Oct 21, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 21, 2026
@Kobzol
Kobzol deleted the bootstrap-but-this-time-for-real-2 branch October 21, 2026 07:34
github-actions Bot pushed a commit to rust-lang/stdarch that referenced this pull request Oct 22, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - rust-lang/rust#163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - rust-lang/rust#163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - rust-lang/rust#163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - rust-lang/rust#163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - rust-lang/rust#164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - rust-lang/rust#164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - rust-lang/rust#164611 (Improve bit permutation codegen)
 - rust-lang/rust#164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - rust-lang/rust#148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - rust-lang/rust#162668 (document that `!` does bitwise and logical negation)
 - rust-lang/rust#164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - rust-lang/rust#164509 (layout invariant: turn delayed bug back into proper assertion)
 - rust-lang/rust#164540 (Minor optimizations around macro parsing)
 - rust-lang/rust#164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - rust-lang/rust#164595 (Allow attributes in function trait parameters)
 - rust-lang/rust#164616 (Add test for VecDeque with a custom allocator)
 - rust-lang/rust#164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - rust-lang/rust#164641 (Stabilize `slice_split_once`)
 - rust-lang/rust#164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
jieyouxu pushed a commit to jieyouxu/rustfmt that referenced this pull request Oct 22, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - rust-lang/rust#163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - rust-lang/rust#163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - rust-lang/rust#163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - rust-lang/rust#163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - rust-lang/rust#164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - rust-lang/rust#164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - rust-lang/rust#164611 (Improve bit permutation codegen)
 - rust-lang/rust#164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - rust-lang/rust#148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - rust-lang/rust#162668 (document that `!` does bitwise and logical negation)
 - rust-lang/rust#164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - rust-lang/rust#164509 (layout invariant: turn delayed bug back into proper assertion)
 - rust-lang/rust#164540 (Minor optimizations around macro parsing)
 - rust-lang/rust#164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - rust-lang/rust#164595 (Allow attributes in function trait parameters)
 - rust-lang/rust#164616 (Add test for VecDeque with a custom allocator)
 - rust-lang/rust#164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - rust-lang/rust#164641 (Stabilize `slice_split_once`)
 - rust-lang/rust#164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
programskillforverification pushed a commit to programskillforverification/miri that referenced this pull request Oct 22, 2026
Rollup of 20 pull requests

Successful merges:

 - rust-lang/rust#163664 (Add new `RUSTC_BOOTSTRAP=-allow-unstable-compiler-flags` mode for testing stable compiler behavior in UI tests)
 - rust-lang/rust#163668 (Remap syntax contexts and expansion ids for det. metadata encoding)
 - rust-lang/rust#163104 ([debuginfo] Emit `usize` and `isize` as typedefs)
 - rust-lang/rust#163317 (Stop useless caching of post-LTO artifact caching for fat LTO)
 - rust-lang/rust#163701 (add ReadDir::dir to get the directory handle of the underlying directory)
 - rust-lang/rust#164488 (Don't try to skip anything in `Skip::advance_by(0)`)
 - rust-lang/rust#164507 (Encode HashMap and HashSet in deterministic order when an encoder requires determinism)
 - rust-lang/rust#164611 (Improve bit permutation codegen)
 - rust-lang/rust#164612 (std: Combine `is_powerpc64_feature_detected` into `is_powerpc_feature_detected`)
 - rust-lang/rust#148842 (Avoid incorrect lifetime suggestion involving `sym::anon`)
 - rust-lang/rust#162668 (document that `!` does bitwise and logical negation)
 - rust-lang/rust#164264 (lint: suggest `fXX::is_nan` for unsuffixed NaN comparisons)
 - rust-lang/rust#164509 (layout invariant: turn delayed bug back into proper assertion)
 - rust-lang/rust#164540 (Minor optimizations around macro parsing)
 - rust-lang/rust#164594 (rustdoc: Correctly handle inner `deprecated` attribute on modules)
 - rust-lang/rust#164595 (Allow attributes in function trait parameters)
 - rust-lang/rust#164616 (Add test for VecDeque with a custom allocator)
 - rust-lang/rust#164629 (arch::breakpoint: avoid confusing 'equivalent' terminology)
 - rust-lang/rust#164641 (Stabilize `slice_split_once`)
 - rust-lang/rust#164646 (Adjust rustfmt subtree sync docs to not use `--allow-noop` for now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-rustc-dev-guide Area: rustc-dev-guide A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants