about summary refs log tree commit diff
path: root/compiler/rustc_macros/src/diagnostics
AgeCommit message (Collapse)AuthorLines
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-2/+7
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-19Streamline `Diagnostic` proc macro.Nicholas Nethercote-83/+45
First, it is parameterized by the name of the diagnostic and the DiagCtxt. These are given to `session_diagnostic_derive` and `lint_diagnostic_derive`. But the names are hard-wired as "diag" and "handler" (should be "dcx"), and there's no clear reason for the parameterization. So this commit removes the parameterization and hard-wires the names internally. Once that is done `DiagnosticDeriveBuilder` is reduced to a trivial wrapper around `DiagnosticDeriveKind`, and can be removed. Also, `DiagnosticDerive` and `LintDiagnosticDerive` don't need the `builder` field, because it has been reduced to a kind, and they know their own kind. This avoids the need for some `let`/`else`/`unreachable!` kind checks And `DiagnosticDeriveVariantBuilder` no longer needs a lifetime, because the `parent` field is changed to `kind`, which is now a trivial copy type.
2023-12-19Remove unnecessary `use` items in derived `IntoDiagnostic` impls.Nicholas Nethercote-3/+0
Presumably these are a hangover from an earlier time when they were necessary.
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-2/+2
2023-12-18Rename `__diagnostic_handler_sess` as `_sess`.Nicholas Nethercote-4/+5
2023-12-18Rename `DiagnosticDeriveKind::Diagnostic::handler` as ↵Nicholas Nethercote-10/+10
`DiagnosticDeriveKind::Diagnostic::dcx`.
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-1/+1
2023-12-16Simplify lint decorator derive tooMichael Goulet-2/+2
2023-11-10Minor cleanups.Nicholas Nethercote-9/+10
- Reduce some function exposure. - Fix some comment formatting.
2023-10-13Format all the let chains in compilerMichael Goulet-19/+23
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-5/+13
2023-06-28Auto merge of #111269 - clubby789:validate-fluent-variables, r=davidtwcobors-4/+57
Validate fluent variable references in tests Closes #101109 Under `cfg(test)`, the `fluent_messages` macro will emit a list of variables referenced by each message and its attributes. The derive attribute will now emit a `#[test]` that checks that each referenced variable exists in the structure it's applied to.
2023-06-23avoid `&format` in error message codeTakayuki Maeda-8/+6
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-23/+43
2023-05-26Fix diagnostics with errorsclubby789-13/+6
2023-05-26Validate fluent variable references with `debug_assertions`clubby789-4/+64
2023-05-09Rollup merge of #111120 - chenyukang:yukang-suggest-let, r=NilstriebDylan DPC-1/+1
Suggest let for possible binding with ty Origin from https://github.com/rust-lang/rust/pull/109128#discussion_r1179866137 r? `@Nilstrieb`
2023-05-08Make spans a bit betterMichael Goulet-13/+23
2023-05-08Diagnostic args are still args if they're documentedMichael Goulet-8/+7
2023-05-08Suggest let for possible binding with tyyukang-1/+1
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-338/+0
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-11Auto merge of #110092 - clubby789:builtin-macros-translatable, r=compiler-errorsbors-2/+4
Migrate most of `rustc_builtin_macros` to diagnostic impls cc #100717 This is a couple of days work, but I decided to stop for now before the PR becomes too big. There's around 50 unresolved failures when `rustc::untranslatable_diagnostic` is denied, which I'll finish addressing once this PR goes thtough A couple of outputs have changed, but in all instances I think the changes are an improvement/are more consistent with other diagnostics (although I'm happy to revert any which seem worse)
2023-04-10Migrate most of `rustc_builtin_macros` to diagnostic implsclubby789-2/+4
Co-authored-by: Joe ST <joe@fbstj.net> Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09Inline format_argsNilstrieb-1/+1
Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09Fix some clippy::complexityNilstrieb-2/+2
2023-04-09Some simple `clippy::perf` fixesNilstrieb-1/+1
2023-04-06address commentsDeadbeef-44/+49
2023-04-06fix errorsDeadbeef-1/+2
2023-04-06fix and bless ui tests 1/2Deadbeef-1/+19
2023-04-06migrate rustc_macros to syn 2.0Deadbeef-275/+196
2023-03-31Don't emit the OS error in a noteest31-3/+6
This makes it possible to make the normalization of the error message more precise, allowing us to not normalize all notes away.
2023-03-31Use std::fs::read_to_file in fluent_messages macroest31-11/+3
2023-03-29Check for escape sequences in Fluent resourcesclubby789-0/+12
2023-02-27Allow using `bool` for optional diagnosticsclubby789-5/+18
2023-02-22errors: generate typed identifiers in each crateDavid Wood-235/+228
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-01Forbid #[suggestion_*(...)] on VecsXiretza-43/+66
It is ambiguous whether this should produce several `.span_suggestions()` calls or one `.multipart_suggestions()` call.
2023-01-27Detect references to non-existant messages in Fluent resourcesclubby789-2/+32
2023-01-11Support eager subdiagnostics againmejrs-4/+20
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-18/+13
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-2/+2
2022-12-18use &str / String literals instead of format!()Matthias Krüger-8/+4
2022-12-15more clippy::complexity fixesMatthias Krüger-1/+1
2022-12-14Auto merge of #105233 - mejrs:always_eager, r=estebankbors-36/+11
Always evaluate vecs of subdiagnostics eagerly See https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20lists!/near/310186705 for context
2022-12-04Always evaluate vecs of subdiagnostics eagerlymejrs-36/+11
2022-12-01Remove useless borrows and derefsMaybe Waffle-32/+32
2022-11-21Improve slug name errormejrs-53/+44
2022-11-21Fix testsmejrs-31/+39
2022-11-21Match crate and slug namesmejrs-1/+53
2022-11-18couple of clippy::perf fixesMatthias Krüger-1/+1
2022-11-07Modify comment syntax errorwanghaha-dev-2/+2