Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make rustc consider itself a stable compiler when RUSTC_BOOTSTRAP=-1 #132993

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Nov 13, 2024

Addresses #123404 to allow test writers to specify //@ rustc-env:RUSTC_BOOTSTRAP=-1 to have a given rustc consider itself a stable rustc. This is only intended for testing usages.

I did not use RUSTC_BOOTSTRAP=0 because that can be confusing, i.e. one might think that means "not bootstrapping", but "forcing a given rustc to consider itself a stable compiler" is a different use case.

I also added a specific test to check RUSTC_BOOTSTRAP's various values and how that interacts with rustc's stability story w.r.t. features and cli flags.

Noticed when trying to write a test for enabling ICE file dumping on stable.

Dunno if this needs a compiler FCP or MCP, but I can file an MCP or ask someone to start an FCP if needed. Note that RUSTC_BOOTSTRAP is a perma-unstable env var and has no stability guarantees (heh) whatsoever. This does not affect bootstrapping because bootstrap never sets RUSTC_BOOTSTRAP=-1. If someone does set that when bootstrapping, it is considered PEBKAC.

Accompanying dev-guide PR: rust-lang/rustc-dev-guide#2136

cc @estebank and @rust-lang/wg-diagnostics for FYI

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 13, 2024
@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc A-test-infra Area: test infrastructure (may span bootstrap/compiletest/more) labels Nov 13, 2024
@Zalathar
Copy link
Contributor

I was thinking about doing this myself recently, because we have some code paths for adjusting --help and other compiler option diagnostics based on whether the compiler is stable or nightly, and all of that is more-or-less untested. So I'm happy to see this PR.

@jieyouxu jieyouxu force-pushed the i_am_very_stable branch 3 times, most recently from 7d8d712 to 151d885 Compare November 13, 2024 12:44
// also affected by `RUSTC_BOOTSTRAP`.
//@[force_stable] rustc-env:RUSTC_BOOTSTRAP=-1
//@[force_stable] compile-flags: -Z unstable-options
//@[force_stable] regex-error-pattern: error: the option `Z` is only accepted on the nightly compiler
Copy link
Member Author

Choose a reason for hiding this comment

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

N.B.: this doesn't check in a snapshot because the exact error message will be different between beta/stable/dev depending on channel info.

@jieyouxu
Copy link
Member Author

jieyouxu commented Nov 17, 2024

Rebased and fixed a comment in order for sentence to sentence, no functional changes.

@chenyukang
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 18, 2024

📌 Commit c130501 has been approved by chenyukang

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 18, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 18, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#132795 (Check `use<..>` in RPITIT for refinement)
 - rust-lang#132944 (add parentheses when unboxing suggestion needed)
 - rust-lang#132993 (Make rustc consider itself a stable compiler when `RUSTC_BOOTSTRAP=-1`)
 - rust-lang#133130 (`suggest_borrow_generic_arg`: instantiate clauses properly)
 - rust-lang#133133 (rustdoc-search: add standalone trailing `::` test)
 - rust-lang#133143 (Diagnostics for let mut in item context)
 - rust-lang#133147 (Fixup some test directives)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c68fef9 into rust-lang:master Nov 18, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 18, 2024
Rollup merge of rust-lang#132993 - jieyouxu:i_am_very_stable, r=chenyukang

Make rustc consider itself a stable compiler when `RUSTC_BOOTSTRAP=-1`

Addresses rust-lang#123404 to allow test writers to specify `//@ rustc-env:RUSTC_BOOTSTRAP=-1` to have a given rustc consider itself a stable rustc. This is only intended for testing usages.

I did not use `RUSTC_BOOTSTRAP=0` because that can be confusing, i.e. one might think that means "not bootstrapping", but "forcing a given rustc to consider itself a stable compiler" is a different use case.

I also added a specific test to check `RUSTC_BOOTSTRAP`'s various values and how that interacts with rustc's stability story w.r.t. features and cli flags.

Noticed when trying to write a test for enabling ICE file dumping on stable.

Dunno if this needs a compiler FCP or MCP, but I can file an MCP or ask someone to start an FCP if needed. Note that `RUSTC_BOOTSTRAP` is a perma-unstable env var and has no stability guarantees (heh) whatsoever. This does not affect bootstrapping because bootstrap never sets `RUSTC_BOOTSTRAP=-1`. If someone does set that when bootstrapping, it is considered PEBKAC.

Accompanying dev-guide PR: rust-lang/rustc-dev-guide#2136

cc `@estebank` and `@rust-lang/wg-diagnostics` for FYI
@jieyouxu jieyouxu deleted the i_am_very_stable branch November 18, 2024 08:17
@Kobzol
Copy link
Contributor

Kobzol commented Nov 18, 2024

Maybe we could replace the empty feature list in

.env("RUSTFLAGS", "-Zallow-features=")
with this? Not sure if it has the same behavior though.

@jieyouxu
Copy link
Member Author

Yeah, that is actually somewhat inaccurate if you really wanted to emulate a stable rustc AFAIK.

@jieyouxu

This comment was marked as resolved.