rust-lang / rust-lang/rust

rustc bad cli arg error messages doesn't respect `--error-format=json`

Open
#140,101 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-CLI A-compiletest A-diagnostics C-discussion T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Not surprising (and I don't really consider this a bug necessarily), but something like

$ rustc --error-format=json --emit
error: Argument to option 'emit' missing
       Usage:
           --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]
                               Comma separated list of types of output for the
                               compiler to emit

doesn't respect --error-format=json. I think that is entirely reasonable, since --error-format itself might be missing its value or get passed some invalid value 🤷

Just opening an issue to note this, because the implication for ui tests is that this obviously won't get picked up by compiletest for the //~? error annotations which are based on JSON diagnostic messages.

For test writers, the implication is simply that you can't use

//@ compile-flags: --emit

//~? ERROR: Argument to option 'emit' missing

and you'll need to use

//@ compile-flags: --emit
//@ error-pattern: Argument to option 'emit' missing

as an fallback.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the rustc --error-format=json --emit behavior and read the compiletest UI-test handling for //~? JSON diagnostics and //@ error-pattern. The issue does not define a requested change, so first establish whether malformed CLI argument errors should be represented in JSON and what tests should verify the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.