- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
          Emitter cleanups
          #119601
        
          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
          
     Merged
      
      
    
                
     Merged
            
            
  
    Emitter cleanups
  
  #119601
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    For consistency with other `Emitter` impls, such as `JsonEmitter`, `SilentEmitter`, `SharedEmitter`, etc.
For consistency with other `Emitter` impls.
There are three functions only used for the JSON format.
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.
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 ```
| Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt | 
| Best reviewed one commit at a time. cc @jyn514 for the "Unbreak tests/ui/lint/use_suggestion_json.rs" commit. | 
| @bors r+ rollup | 
    
  bors 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Jan 5, 2024 
    
    
      
  
    
      
    
  
…mpiler-errors Rollup of 10 pull requests Successful merges: - rust-lang#119034 (Allow coverage tests to ignore test modes, and to enable color in coverage reports) - rust-lang#119148 (Tweak suggestions for bare trait used as a type) - rust-lang#119538 (Cleanup error handlers: round 5) - rust-lang#119566 (Remove `-Zdump-mir-spanview`) - rust-lang#119567 (Remove `-Zreport-delayed-bugs`.) - rust-lang#119577 (Migrate memory overlap check from validator to lint) - rust-lang#119583 (Make `intrinsics::assume` const stable) - rust-lang#119586 ([rustdoc] Fix invalid handling for static method calls in jump to definition feature) - rust-lang#119588 (Move `i586-unknown-netbsd` from tier 2 to tier 3 platform support table) - rust-lang#119601 (`Emitter` cleanups) r? `@ghost` `@rustbot` modify labels: rollup
    
  rust-timer 
      added a commit
        to rust-lang-ci/rust
      that referenced
      this pull request
    
      Jan 5, 2024 
    
    
      
  
    
      
    
  
Rollup merge of rust-lang#119601 - nnethercote:Emitter-cleanups, r=oli-obk `Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
    
  zhassan-aws 
      added a commit
        to model-checking/kani
      that referenced
      this pull request
    
      Jan 8, 2024 
    
    
      
  
    
      
    
  
Relevant PRs: - rust-lang/rust#119601 - rust-lang/rust#119146 - rust-lang/rust#119174 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
    
  flip1995 
      pushed a commit
        to flip1995/rust
      that referenced
      this pull request
    
      Jan 11, 2024 
    
    
      
  
    
      
    
  
…i-obk `Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
    
  calebcartwright 
      pushed a commit
        to calebcartwright/rust
      that referenced
      this pull request
    
      Jun 22, 2024 
    
    
      
  
    
      
    
  
…i-obk `Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    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. 
  
    T-rustdoc
  Relevant to the rustdoc team, which will review and decide on the PR/issue. 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Some improvements I found while looking at this code.
r? @oli-obk