about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
AgeCommit message (Collapse)AuthorLines
2024-01-05Remove outdated references to `librustc_middle`.Alona Enraght-Moony-1/+2
2024-01-05Rollup merge of #119601 - nnethercote:Emitter-cleanups, r=oli-obkMichael Goulet-19/+21
`Emitter` cleanups Some improvements I found while looking at this code. r? `@oli-obk`
2024-01-05Rollup merge of #119567 - nnethercote:rm-Zreport-delayed-bugs, r=oli-obkMichael Goulet-13/+3
Remove `-Zreport-delayed-bugs`. It's not used within the repository in any way (e.g. in tests), and doesn't seem useful. It was added in #52568. r? ````@oli-obk````
2024-01-05Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errorsMichael Goulet-107/+69
Cleanup error handlers: round 5 More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171. r? ````@compiler-errors````
2024-01-05Add some comments to `Emitter`.Nicholas Nethercote-3/+5
There are three functions only used for the JSON format.
2024-01-05Rename `AnnotateSnippetEmitterWriter` as `AnnotateSnippetEmitter`.Nicholas Nethercote-4/+4
For consistency with other `Emitter` impls.
2024-01-05Rename `EmitterWriter` as `HumanEmitter`.Nicholas Nethercote-12/+12
For consistency with other `Emitter` impls, such as `JsonEmitter`, `SilentEmitter`, `SharedEmitter`, etc.
2024-01-04Remove `-Zreport-delayed-bugs`.Nicholas Nethercote-13/+3
It's not used within the repository in any way (e.g. in tests), and doesn't seem useful.
2024-01-04Remove `is_lint` field from `Level::Error`.Nicholas Nethercote-22/+14
Because it's redundant w.r.t. `Diagnostic::is_lint`, which is present for every diagnostic level. `struct_lint_level_impl` was the only place that set the `Error` field to `true`, and it's also the only place that calls `Diagnostic::is_lint()` to set the `is_lint` field.
2024-01-04compiler: fix typosvuittont60-1/+1
librustdoc: fix typos
2024-01-04Remove unused `DiagnosticBuilder::struct_almost_fatal`.Nicholas Nethercote-10/+0
`create_almost_fatal` and `emit_almost_fatal` are always used instead.
2024-01-03Fix `forward!` so it doesn't require trailing commas in some cases.Nicholas Nethercote-4/+4
2024-01-03Fix up `forward!` decls.Nicholas Nethercote-32/+16
- Move comments onto corresponding `Diagnostic` methods. - Make formatting more consistent.
2024-01-03Remove forward for `downgrade_to_delayed_bug`.Nicholas Nethercote-8/+1
It's not used, and doesn't quite fit the general pattern. Also, `Diagnostic::downgrade_to_delayed_bug` doesn't need to return `&mut Self` for the same reason.
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-32/+35
`Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods.
2023-12-31rustc_lint: Make `LintLevelsProvider::current_specs()` return `&FxIndexMap`Martin Nordholts-4/+4
So that lint iteration order becomes predicitable. Discovered with `rustc::potential_query_instability`.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-4/+16
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-24Remove `ParseSess` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+12
Also add missing `#[track_caller]` attributes to `DiagCtxt` methods as necessary to keep tests working.
2023-12-23Remove `DiagnosticBuilder::forget_guarantee`.Nicholas Nethercote-52/+24
It's unused. And this means `DiagnosticBuilderInner` no longer needs to be separate from `DiagnosticBuilder`.
2023-12-23Fix a comment.Nicholas Nethercote-1/+1
There are quite a few hand-written `IntoDiagnostic` impls.
2023-12-23Use `pub(crate)` in a couple of places.Nicholas Nethercote-2/+2
2023-12-23Take full advantage of a `use Level::*;`.Nicholas Nethercote-35/+33
Some of the `Level::` qualifiers in this file are omitted. This commit removes the remainder.
2023-12-23Remove `LabelKind`.Nicholas Nethercote-15/+2
It has three variants, but only `LabelKind::Label` is ever used. This means `SingleLabelManySpans::kind` can also be removed.
2023-12-23Remove `SubDiagnostic::render_span`.Nicholas Nethercote-10/+3
It's only ever set to `None`.
2023-12-23Remove `render_span` args from `Diagnostic::{sub,sub_with_highlight}`.Nicholas Nethercote-21/+14
They're always `None`.
2023-12-23Improve some names.Nicholas Nethercote-33/+33
Lots of vectors of messages called `message` or `msg`. This commit pluralizes them. Note that `emit_message_default` and `emit_messages_default` both already existed, and both process a vector, so I renamed the former `emit_messages_default_inner` because it's called by the latter.
2023-12-23Remove `Diagnostic::new_with_code`.Nicholas Nethercote-21/+1
Its single use can be replaced with `Diagnostic::new_with_messages`.
2023-12-23Remove `DiagCtxtInner::span_bug`.Nicholas Nethercote-13/+5
`DiagCtxt::span_bug` is different to the other `DiagCtxt::span_*` methods. This commit makes it the same, which requires changing `DiagCtxt::span_delayed_bug` to not do everything within the `inner.borrow_mut()`.
2023-12-23Introduce `DiagCtxt::treat_next_err_as_bug`.Nicholas Nethercote-7/+8
To fix a FIXME.
2023-12-23Remove unnecessary line breaks from two string literals.Nicholas Nethercote-4/+2
2023-12-23Tweak `flush_delayed`.Nicholas Nethercote-10/+11
- Take a `Vec` instead of an iterator, because that's all that is needed. - Do an early return for the "no bugs" case. - Use `enumerate` and an `i == 0` test to identify the first bug. Those changes mean the `no_bug` variable can be removed, which I found hard to read.
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-14/+8
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-23Fix a couple of left-over references to `Handler`.Nicholas Nethercote-2/+2
2023-12-23Improve `use` items in `compiler/rustc_errors/src/lib.rs`.Nicholas Nethercote-30/+27
There are a bunch of them about 400 lines down, which is weird and annoying. This commit moves them up and puts them in a more sensible order.
2023-12-23Streamline `struct_lint_level`.Nicholas Nethercote-53/+0
We can just get the error level in the `match` and then use `DiagnosticBuilder::new`. This then means a number of `DiagCtxt` functions are no longer needed, because this was the one place that used them. Note: the commit changes the treatment of spans for `Expect`, which was different to all the other cases, but this has no apparent effect.
2023-12-23Add comments to `Level`.Nicholas Nethercote-5/+59
There is room for improvement on some of these, but something is better than nothing.
2023-12-19Remove unused `DiagCtxt::span_bug_no_panic`.Nicholas Nethercote-7/+0
2023-12-19De-weirdify `fatally_break_rust`.Nicholas Nethercote-0/+13
The easter egg ICE on `break rust` is weird: it's the one ICE in the entire compiler that doesn't immediately abort, which makes it annoyingly inconsistent. This commit changes it to abort. As part of this, the extra notes are now appended onto the bug dignostic, rather than being printed as individual note diagnostics, which changes the output format a bit. These changes don't interferes with the joke, but they do help with my ongoing cleanups to error handling.
2023-12-19Introduce `DiagCtxt::struct_bug`.Nicholas Nethercote-1/+9
This makes `DiagCtxt::bug` look like the other similar functions.
2023-12-19Factor out common `emit_producing_guarantee` code.Nicholas Nethercote-43/+21
2023-12-19Add `EmitResult` associated type to `EmissionGuarantee`.Nicholas Nethercote-54/+46
This lets different error levels share the same return type from `emit_*`. - A lot of inconsistencies in the `DiagCtxt` API are removed. - `Noted` is removed. - `FatalAbort` is introduced for fatal errors (abort via `raise`), replacing the `EmissionGuarantee` impl for `!`. - `Bug` is renamed `BugAbort` (to avoid clashing with `Level::Bug` and to mirror `FatalAbort`), and modified to work in the new way with bug errors (abort via panic). - Various diagnostic creators and emitters updated to the new, better signatures. Note that `DiagCtxt::bug` no longer needs to call `panic_any`, because `emit` handles that. Also shorten the obnoxiously long `diagnostic_builder_emit_producing_guarantee` name.
2023-12-19Remove `struct_diagnostic` and `G::make_diagnostic_builder`.Nicholas Nethercote-65/+0
`EmissionGuarantee` no longer determines the error level, the `create_*` functions do.
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-37/+42
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-18Use `.into_diagnostic()` less.Nicholas Nethercote-0/+1
This commit replaces this pattern: ``` err.into_diagnostic(dcx) ``` with this pattern: ``` dcx.create_err(err) ``` in a lot of places. It's a little shorter, makes the error level explicit, avoids some `IntoDiagnostic` imports, and is a necessary prerequisite for the next commit which will add a `level` arg to `into_diagnostic`. This requires adding `track_caller` on `create_err` to avoid mucking up the output of `tests/ui/track-diagnostics/track4.rs`. It probably should have been there already.
2023-12-18Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.Nicholas Nethercote-23/+23
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-30/+30
2023-12-18Rename `SilentEmitter::fatal_handler` as `SilentEmitter::fatal_dcx`.Nicholas Nethercote-3/+3
2023-12-18Rename `DiagnosticBuilder::handler` as `DiagnosticBuilder::dcx`.Nicholas Nethercote-1/+1
2023-12-18Rename `HandlerFlags` as `DiagCtxtFlags`.Nicholas Nethercote-5/+5
2023-12-18Rename `HandlerInner` as `DiagCtxtInner`.Nicholas Nethercote-9/+9