-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
macros: subdiagnostic derive #96468
macros: subdiagnostic derive #96468
Conversation
Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
This comment was marked as resolved.
This comment was marked as resolved.
26e0289
to
4874fa3
Compare
One thing I noticed is that you might not be supporting |
This comment was marked as resolved.
This comment was marked as resolved.
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
Move existing test for session diagnostic derive to a subdirectory. Signed-off-by: David Wood <david.wood@huawei.com>
Add a new derive, `#[derive(SessionSubdiagnostic)]`, which enables deriving structs for labels, notes, helps and suggestions. Signed-off-by: David Wood <david.wood@huawei.com>
Split `SessionDiagnostic` and `SessionSubdiagnostic` derives and the various helper functions into multiple modules. Signed-off-by: David Wood <david.wood@huawei.com>
Remove some duplicated code between both diagnostic derives by introducing helper functions for reporting an error in case of a invalid attribute. Signed-off-by: David Wood <david.wood@huawei.com>
`SetOnce` trait was introduced in the subdiagnostic derive to simplify the code a little bit, re-use it in the diagnostic derive too. Signed-off-by: David Wood <david.wood@huawei.com>
Documentation comments are always good. Signed-off-by: David Wood <david.wood@huawei.com>
In the initial implementation of the `SessionSubdiagnostic`, the `Applicability` of a suggestion can be set both as a field and as part of the attribute, this commit adds the same support to the original `SessionDiagnostic` derive. Signed-off-by: David Wood <david.wood@huawei.com>
Add `#[subdiagnostic]` field attribute to the diagnostic derive which is applied to fields that have types which use the subdiagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
4874fa3
to
dca8861
Compare
@bors r+ |
📌 Commit dca8861 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (683c582): comparison url. Summary:
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
Add a new macro,
#[derive(SessionSubdiagnostic)]
, which can be applied to structs that represent subdiagnostics, such as labels, notes, helps or suggestions.#[derive(SessionSubdiagnostic)]
can be used with the existing#[derive(SessionDiagnostic)]
. All diagnostics implemented using either derive are translatable, and this new derive should make it easier to port existing diagnostics to using these derives.For example, consider the following subdiagnostic types...
...and the corresponding Fluent messages:
These can be emitted using the new
subdiagnostic
function onDiagnostic
......or as part of a larger
#[derive(SessionDiagnostic)]
:r? @oli-obk
cc @pvdrz