-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
diagnostics: port more diagnostics to derive + support for ()
fields
#96853
diagnostics: port more diagnostics to derive + support for ()
fields
#96853
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
cc @Mark-Simulacrum for compiletest changes |
This comment was marked as resolved.
This comment was marked as resolved.
4664552
to
ecde2d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with manual diagnostic trait impl documented
#[help] | ||
pub is_nightly_build: Option<()>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it could be useful to require the field name in the fluent file for spanless helps. Or generally for optional fields. It could be surprising to see some of them if you look at the entire fluent spec for an error, because you'd see all fields and they'd look "equal".
But considering I have zero fluent experience, that's just me guessing from the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, I don't think it's worth changing this right now but it should be fairly easy to change down the line if we want to.
Type attributes could previously be used to support spanless subdiagnostics but these couldn't easily be made optional in the same way that spanned subdiagnostics could by using a field attribute on a field with an `Option<Span>` type. Spanless subdiagnostics can now be specified on fields with `()` type or `Option<()>` type. Signed-off-by: David Wood <david.wood@huawei.com>
Using new support for spanless subdiagnostics from `()` fields in the diagnostic derive, simplify the "explicit generic args with impl trait" diagnostic's struct. Signed-off-by: David Wood <david.wood@huawei.com>
When testing macros from `rustc_macros` in `ui-fulldeps` tests, sometimes paths from the compiler source tree can be shown in error messages - these need to be normalized. Signed-off-by: David Wood <david.wood@huawei.com>
Manual implementors of translatable diagnostics will need to call `set_arg`, not just the derive, so make this function a bit more ergonomic by taking `IntoDiagnosticArg` rather than `DiagnosticArgValue`. Signed-off-by: David Wood <david.wood@huawei.com>
Port the "the type parameter `T` must be explicitly specified" diagnostic to using a diagnostic struct. Signed-off-by: David Wood <david.wood@huawei.com>
Port the "manual implementations of `X` are experimental" diagnostic to use the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
Port "could not resolve substs on overridden impl" diagnostic to use the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
ecde2d9
to
4758247
Compare
@bors r+ |
📌 Commit 4758247 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (18bd2dd): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
help
/note
) can be applied via attributes to fields of type()
(currently spanless subdiagnostics are applied via attributes on the diagnostic struct itself). A consequence of this is thatOption<()>
fields can be used to represent optional spanless subdiagnostics, which are sometimes useful (e.g. for ahelp
that should only show on nightly builds).Vec
fields #96760) using support forOption<()>
spanless subdiagnostics.DiagnosticBuilder::set_arg
, used to provide context for Fluent messages, so that it takes anything that implementsIntoDiagnosticArg
, rather thanDiagnosticArgValue
- this improves the ergonomics of manual implementations ofSessionDiagnostic
which are translatable.T
must be explicitly specified", "manual implementations ofX
are experimental", "could not resolve substs on overridden impl" diagnostics to diagnostic structs.rustc_macros
inui-fulldeps
tests, sometimes paths from the compiler source tree can be shown in error messages - these need to be normalized incompiletest
.r? @oli-obk
cc @pvdrz