Skip to content

Remove EarlyDiagCtxt::early_{note,help} - #162671

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
nnethercote:rm-EarlyDiagCtxt-note-help
Sep 13, 2026
Merged

Remove EarlyDiagCtxt::early_{note,help}#162671
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
nnethercote:rm-EarlyDiagCtxt-note-help

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

We have some top-level help and note diagnostics emittable at startup. These are weird. This PR eliminates them. Details in individual commits.

r? @estebank

A command like `rustc -optimize a.rs` currently gives this:
```
warning: option `-o` has no space between flag name and value, which can be confusing

note: output filename `-o ptimize` is applied instead of a flag named `optimize`

help: insert a space between `-o` and `ptimize` if this is intentional: `-o ptimize`
```

A top-level warning, then a top-level note, then a top-level help.
Weird!

This commit converts the note and the help into children of the warning,
which looks better and matches how things are normally done, giving
this:
```
warning: option `-o` has no space between flag name and value, which can be confusing
  |
  = note: output filename `-o ptimize` is applied instead of a flag named `optimize`
  = help: insert a space between `-o` and `ptimize` if this is intentional: `-o ptimize`
```
Much better.
Currently the command `rustc -Zunstable-options -j3 --jobs-backend=1
a.rs`, when run on stable rustc, gives this:
```
error: the option `Z` is only accepted on the nightly compiler

error: the option `jobs` is only accepted on the nightly compiler

error: the option `jobs-backend` is only accepted on the nightly compiler

help: consider switching to a nightly toolchain: `rustup default nightly`

note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>

note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>

error: 3 nightly options were parsed
```

The errors are fine, but top-level help and notes are weird.

This commit changes it to this, which is more normal:
```
error: the option `Z` is only accepted on the nightly compiler

error: the option `jobs` is only accepted on the nightly compiler

error: the option `jobs-backend` is only accepted on the nightly compiler

error: 3 nightly options were parsed
  |
  = help: consider switching to a nightly toolchain: `rustup default nightly`
  = note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>
  = note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>
```

It's a slightly different order but that seems fine.

The commit also makes two other small improvements:
- An unnecessary `match opt.stability` is removed. (There's another
  `opt.stability` check a few lines above.)
- It fixes "1 nightly option were parsed" to "1 nightly option was
  parsed".
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs 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 Sep 12, 2026
@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@nnethercote would you like to take the lead on landing #151345? It is morally the same thing you're doing on this PR (merging multiple linker errors/notes into one per mistake instead of loose unrelated messages). I think things have already diverged enough that it's not a plain rebase, but the hard part is still just coming up with the tests for them.

@rust-bors

rust-bors Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 396d603 has been approved by estebank

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Sep 12, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 13, 2026
Rollup of 4 pull requests

Successful merges:

 - #157947 (Improve into_slice_range inlining and add #[track_caller])
 - #161520 (Stabilize `core::mem::DropGuard`)
 - #162671 (Remove `EarlyDiagCtxt::early_{note,help}`)
 - #161385 (riscv: stabilize 'd' and 'f' target features)
@rust-bors
rust-bors Bot merged commit d9b3213 into rust-lang:main Sep 13, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 13, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 13, 2026
Rollup merge of #162671 - nnethercote:rm-EarlyDiagCtxt-note-help, r=estebank

Remove `EarlyDiagCtxt::early_{note,help}`

We have some top-level `help` and `note` diagnostics emittable at startup. These are weird. This PR eliminates them. Details in individual commits.

r? @estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

3 participants