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

lints: mostly translatable diagnostics #98624

Merged
merged 54 commits into from
Jul 5, 2022

Conversation

davidtwco
Copy link
Member

As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway).

r? @compiler-errors

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 28, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 28, 2022
@rust-log-analyzer

This comment was marked as resolved.

@compiler-errors
Copy link
Member

I'll take a look at this sometime in the next few days, since it's quite large and my free time is somewhat scattered.

@bors

This comment was marked as resolved.

Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that
lints can be built with translatable diagnostic messages.

Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
Signed-off-by: David Wood <david.wood@huawei.com>
In the diagnostic derive test, a "the following other types implement
trait" diagnostic is output which lists rustc types that implement
`IntoDiagnosticArg`. As the output of this test can change due to new
internal compiler types like implementing `IntoDiagnosticArg`, it can
start failing without indicating a problem to be fixed - so normalize
that output away.

Signed-off-by: David Wood <david.wood@huawei.com>
@compiler-errors
Copy link
Member

Looks great!

@bors r+

@bors
Copy link
Contributor

bors commented Jul 4, 2022

📌 Commit 9ff6c77 has been approved by compiler-errors

@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 Jul 4, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 5, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#97712 (ptr::copy and ptr::swap are doing untyped copies)
 - rust-lang#98624 (lints: mostly translatable diagnostics)
 - rust-lang#98776 (rustdoc: improve click behavior of the source code mobile full-screen "sidebar")
 - rust-lang#98856 (Remove FIXME from rustdoc intra-doc test)
 - rust-lang#98913 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 291df97 into rust-lang:master Jul 5, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 5, 2022
@davidtwco davidtwco deleted the translation-on-lints branch July 5, 2022 14:59
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 6, 2022
…ve, r=oli-obk

macros: `LintDiagnostic` derive

- Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it.
- Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning).
- Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`).
- Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro  except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery.

~~At time of opening this pull request, ignore all of the commits from rust-lang#98624, it's just the last few commits that are new.~~

r? `@oli-obk`
@compiler-errors compiler-errors added the A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic label Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants