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 #121783

Merged
merged 14 commits into from
Feb 29, 2024
Merged

Emitter cleanups #121783

merged 14 commits into from
Feb 29, 2024

Conversation

nnethercote
Copy link
Contributor

Some cleanups I made when reading emitter code. In particular, HumanEmitter and JsonEmitter have gone from three constructors to one.

r? @oli-obk

In practice, 'a and 'b and 'c are always the same. This change makes
`UnusedExterns` more like `ArtifactNotification`, which uses a single
lifetime 'a in multiple ways.
This `HumanEmitter` is only created to test if it supports colour. The
diagnostic width isn't relevant.
It only has two call sites, and one of those doesn't set the source map.
Because it's now the only constructor.
They have the same signature, and the former just calls the latter.
And likewise with `ColorConfig::suggests_using_colors`. They both have a
single call site. And note that `BufWriter::supports_color()` always
returns false, which enables a small bit of constant folding along the
way.
Because `HumanEmitter::new` is enough, in conjunction with the (renamed)
`stderr_destination` function.
They are so similar to `JsonEmitter::new` it's not worth having separate
functions, it makes the code harder to read.
Use `derive(Setters)` to derive setters, and then change
`JsonEmitter::new` to only have the arguments that are always used.
It took me a while to work this out.
@rustbot rustbot added 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 29, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 29, 2024

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

just a nit

Thanks for continueing to work on this. I totally forgot about it after my last refactors

compiler/rustc_errors/src/json.rs Outdated Show resolved Hide resolved
@nnethercote
Copy link
Contributor Author

I avoided the color local variable.

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Feb 29, 2024

📌 Commit 607bf65 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors 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 Feb 29, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 29, 2024
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#119748 (Increase visibility of `join_path` and `split_paths`)
 - rust-lang#120820 (Enable CMPXCHG16B, SSE3, SAHF/LAHF and 128-bit Atomics (in nightly) in Windows x64)
 - rust-lang#121000 (pattern_analysis: rework how we hide empty private fields)
 - rust-lang#121376 (Skip unnecessary comparison with half-open range patterns)
 - rust-lang#121596 (Use volatile access instead of `#[used]` for `on_tls_callback`)
 - rust-lang#121669 (Count stashed errors again)
 - rust-lang#121783 (Emitter cleanups)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0e9f02d into rust-lang:master Feb 29, 2024
11 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 29, 2024
Rollup merge of rust-lang#121783 - nnethercote:emitter-cleanups, r=oli-obk

Emitter cleanups

Some cleanups I made when reading emitter code. In particular, `HumanEmitter` and `JsonEmitter` have gone from three constructors to one.

r? `@oli-obk`
@rustbot rustbot added this to the 1.78.0 milestone Feb 29, 2024
@nnethercote nnethercote deleted the emitter-cleanups branch February 29, 2024 21:05
adpaco-aws added a commit to model-checking/kani that referenced this pull request Mar 4, 2024
Upgrades the Rust toolchain to `nightly-2024-03-01`. The Rust compiler
PRs that triggered changes in this upgrades are:
 * rust-lang/rust#121516
 * rust-lang/rust#121598
 * rust-lang/rust#121489
 * rust-lang/rust#121783
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 7, 2024
…i-obk

Emitter cleanups

Some cleanups I made when reading emitter code. In particular, `HumanEmitter` and `JsonEmitter` have gone from three constructors to one.

r? `@oli-obk`
calebcartwright pushed a commit to calebcartwright/rust that referenced this pull request Jun 22, 2024
…i-obk

Emitter cleanups

Some cleanups I made when reading emitter code. In particular, `HumanEmitter` and `JsonEmitter` have gone from three constructors to one.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants