Skip to content

Clarify -Z help output and note rustc flags#17150

Open
di3go04 wants to merge 6 commits into
rust-lang:masterfrom
di3go04:fix-z-help-output
Open

Clarify -Z help output and note rustc flags#17150
di3go04 wants to merge 6 commits into
rust-lang:masterfrom
di3go04:fix-z-help-output

Conversation

@di3go04

@di3go04 di3go04 commented Jun 30, 2026

Copy link
Copy Markdown

Updates the -Z help output per the design @epage proposed in #17145.

  • Clarifies these are cargo flags (header now says "cargo flags")
  • Reformats the stable-channel warning to the warn:/help: diagnostic style
  • Adds a note pointing users to rustc -Zhelp for rustc unstable flags

Closes #17145

Updates the -Z help output per the design proposed in rust-lang#17145: clarifies these are cargo flags, reformats the channel warning to rustc diagnostic style, and adds a note pointing to rustc -Zhelp for rustc flags.
@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2026
@rustbot

rustbot commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @ehuss (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@epage

epage commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

If we move forward with this, please use annotate snippets for the notes/warns, rather than attempting to imitate at.

@ehuss ehuss added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2026
di3go04 added 5 commits July 8, 2026 06:24
Per @epage's feedback, use annotate-snippets (Level::WARNING with
Level::HELP elements via print_report, and shell().note() for the
rustc note) instead of manually imitating the warn:/help:/note:
diagnostic style with drop_println!.

Changes:
- Warning + help messages now use Level::WARNING.secondary_title()
  with Level::HELP.message() elements via print_report (stderr)
- The rustc -Zhelp note now uses shell().note() which internally
  uses annotate-snippets Level::NOTE (stderr)
- The 'See https://...' line stays on stdout via drop_println!
- Updated stdout.term.svg to remove the note (now on stderr)
- Added stderr.term.svg with the expected note rendering
- Updated the test to check stderr against the new SVG
Align the print_report call with the existing style used elsewhere
in cli.rs (e.g. the alias shadowing warnings): secondary_title and
element calls chained on the same line, without trailing commas
inside element().
- Use str! with [NOTE] placeholder for stderr instead of SVG file
  (simpler and matches the snapbox pattern used elsewhere)
- Fix compilation: print_zhelp returns () so use 'let _ =' for
  print_report/note calls instead of ? operator
Per @epage's feedback, use annotate-snippets (Level::WARNING with
Level::HELP elements via print_report) for the warn:/help: messages
instead of manually imitating the diagnostic style.

The note about rustc -Zhelp stays as plain text on stdout via
drop_println! since it's an informational pointer, not a diagnostic.
This also restores the original stdout.term.svg and test expectations.
Comment thread src/bin/cargo/cli.rs

@epage epage Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: apply rustfmt to print_zhelp

While we prefer small commits, what is more important is for the commits to be atomic, reflecting how the code should be reviewed and merged and not how it was developed.

If you decide to go for multiple commits, that could look like

  • a commit for just adding "cargo"
  • a commit for each re-arrangement of text, if needed
  • a commit for changing direct text to annotate snippets
  • any new parts of annotate snippets added

View changes since the review

Comment thread src/bin/cargo/cli.rs
}
drop_println!(
gctx,
"\nSee https://doc.rust-lang.org/nightly/cargo/reference/unstable.html \

@epage epage Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At least at #17145 (comment), I was suggesting moving the "See" above the use of annotate-snippets. Is there a reason it was kept here?

View changes since the review

Comment thread src/bin/cargo/cli.rs
"\nSee https://doc.rust-lang.org/nightly/cargo/reference/unstable.html \
for more information about these flags."
for more information about these flags.\n\n\
note: to see rustc unstable features, run `rustc -Zhelp`"

@epage epage Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would expect this note to either be moved to gctx.shell().note or annotate snippets

View changes since the review

Comment thread tests/testsuite/cargo/z_help/stdout.term.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area: Command-line interface, option parsing, etc. S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Indicate/warn cargo +nightly rustc -Zhelp does not show rustc +nightly -Zhelp experimental options

4 participants