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

Emitter cleanups #119601

Merged
merged 5 commits into from
Jan 5, 2024
Merged

Emitter cleanups #119601

merged 5 commits into from
Jan 5, 2024

Commits on Jan 4, 2024

  1. Rename EmitterWriter as HumanEmitter.

    For consistency with other `Emitter` impls, such as `JsonEmitter`,
    `SilentEmitter`, `SharedEmitter`, etc.
    nnethercote committed Jan 4, 2024
    Configuration menu
    Copy the full SHA
    cb9abca View commit details
    Browse the repository at this point in the history
  2. Rename AnnotateSnippetEmitterWriter as AnnotateSnippetEmitter.

    For consistency with other `Emitter` impls.
    nnethercote committed Jan 4, 2024
    Configuration menu
    Copy the full SHA
    c4d63c7 View commit details
    Browse the repository at this point in the history
  3. Add some comments to Emitter.

    There are three functions only used for the JSON format.
    nnethercote committed Jan 4, 2024
    Configuration menu
    Copy the full SHA
    453ffac View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2024

  1. Unbreak tests/ui/lint/use_suggestion_json.rs.

    PR rust-lang#82639 changed UI tests so `-Z unstable-options` aren't passed to UI
    tests by default. This completely broke `use_suggestion_json.rs`, which
    uses the unstable `--error-format=pretty-json` option. The expected
    output went from 400 lines of pretty JSON error messages to a single
    JSON error saying "`--error-format=pretty-json` is unstable"!
    
    This commit adds `-Z unstable-options` back and reinstates the old
    expected output, with some minor changes to account for shifted spans
    and slightly JSON output changes since then.
    nnethercote committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    f5a09a9 View commit details
    Browse the repository at this point in the history
  2. Change printing of "--error-format is unstable" errors.

    Currently for these two errors we go to the effort of switching to a
    standard JSON emitter, for no obvious reason, and unlike any other
    errors. This behaviour was added for `pretty-json` in rust-lang#45737, and then
    `human-annotate-rs` copied it some time later when it was added.
    
    This commit changes things to just using the requested emitter, which is
    simpler and consistent with other errors.
    
    Old output:
    ```
    $ rustc --error-format pretty-json
    {"$message_type":"diagnostic","message":"`--error-format=pretty-json` is unstable","code":null,"level":"error","spans":[],"children":[],"rendered":"error: `--error-format=pretty-json` is unstable\n\n"}
    
    $ rustc --error-format human-annotate-rs
    {"$message_type":"diagnostic","message":"`--error-format=human-annotate-rs` is unstable","code":null,"level":"error","spans":[],"children":[],"rendered":"error: `--error-format=human-annotate-rs` is unstable\n\n"}
    ```
    
    New output:
    ```
    $ rustc --error-format pretty-json
    {
      "$message_type": "diagnostic",
      "message": "`--error-format=pretty-json` is unstable",
      "code": null,
      "level": "error",
      "spans": [],
      "children": [],
      "rendered": "error: `--error-format=pretty-json` is unstable\n\n"
    }
    
    $ rustc --error-format human-annotate-rs
    error: `--error-format=human-annotate-rs` is unstable
    ```
    nnethercote committed Jan 5, 2024
    Configuration menu
    Copy the full SHA
    8843223 View commit details
    Browse the repository at this point in the history