about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/diagnostic.rs
AgeCommit message (Collapse)AuthorLines
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-5/+8
`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-2/+2
So that lint iteration order becomes predicitable. Discovered with `rustc::potential_query_instability`.
2023-12-23Remove `SubDiagnostic::render_span`.Nicholas Nethercote-3/+1
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-12/+12
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-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-2/+2
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-1/+1
2023-12-16Simplify lint decorator derive tooMichael Goulet-4/+1
2023-12-09Rollup merge of #118057 - bvanjoi:fix-118048, r=cjgillotGuillaume Gomez-4/+5
dedup for duplicate suggestions Fixes #118048 An easy fix.
2023-12-04Remove some unused code, and downgrade some `pub`s.Nicholas Nethercote-37/+6
2023-12-04dedup for duplicate suggestionsbohan-4/+5
2023-11-19Remove unnecessary .collect()Esteban Küber-7/+7
2023-11-19Don't sort `span_suggestions`, leave that to callerEsteban Küber-6/+1
2023-11-19When encountering struct fn call literal with private fields, suggest all ↵Esteban Küber-4/+7
builders When encountering code like `Box(42)`, suggest `Box::new(42)` and *all* other associated functions that return `-> Box<T>`.
2023-09-22give FutureIncompatibilityReason variants more explicit namesRalf Jung-1/+7
2023-09-04Add OnceHelp lint level (same as OnceNote, except for help)Urgau-0/+8
2023-07-24Optimize format usageYuri Astrakhan-5/+5
Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-2/+2
2023-05-29Use `Cow` in `{D,Subd}iagnosticMessage`.Nicholas Nethercote-14/+10
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.
2023-04-11Auto merge of #110092 - clubby789:builtin-macros-translatable, r=compiler-errorsbors-0/+1
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-0/+1
Co-authored-by: Joe ST <joe@fbstj.net> Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-09Fix some clippy::complexityNilstrieb-1/+1
2023-02-01Make "use latest edition" subdiagnostic translatableXiretza-37/+0
2023-02-01Use AddToDiagnostic for "use latest edition" helpXiretza-12/+36
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-0/+2
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-20add debug assertion for suggestions with overlapping partsLukas Markeffsky-27/+44
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-3/+3
2023-01-01Merge multiple mutable borrows of immutable binding errorsEsteban Küber-2/+2
Fix #53466.
2022-12-13Rollup merge of #105625 - matthiaskrgr:clippy_dec12, r=compiler-errorsMatthias Krüger-1/+1
minor code cleanups r? `@compiler-errors`
2022-12-12minor code cleanupsMatthias Krüger-1/+1
2022-12-11Point at method call when it is the source of the bound errorEsteban Küber-1/+5
2022-12-01Remove useless borrows and derefsMaybe Waffle-1/+1
2022-11-18Fix compilation issue after rebaseCharles Lew-0/+3
2022-11-18Migrate diagnostics list output to use icu list formatter.Charles Lew-0/+3
2022-11-14Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-2/+1
Bump bootstrap compiler to 1.66 This PR: - Bumps version placeholders to release - Bumps to latest beta - cfg-steps code r? `@pietroalbini`
2022-11-09Rollup merge of #102763 - compiler-errors:nits, r=cjgillotMichael Goulet-5/+5
Some diagnostic-related nits 1. Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` 2. Make `diag.span_suggestions` take an `IntoIterator` instead of `Iterator`, just to remove some `.into_iter` calls on the caller. idk if I should add a lint to make sure people use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` in cases where we're just, e.g., adding subdiagnostics to the diagnostic... maybe a followup.
2022-11-09rebase conflictMichael Goulet-2/+2
2022-11-09Make span_suggestions take IntoIteratorMichael Goulet-3/+3
2022-11-09Add missing `emitted_at` to the `Diagnostic`SLASHLogin-0/+1
2022-11-09Add constructor for `Diagnostic` that takes `Vec<(DiagnosticMessage, Style)>`SLASHLogin-0/+15
2022-11-09FormattingSLASHLogin-1/+4
2022-11-09Add `replace_args` method for `rustc_errors::diagnostic::Diagnostic`SLASHLogin-0/+4
2022-11-09Delay diagnostic translation in `rustc_codegen_ssa`SLASHLogin-0/+9
2022-11-06cfg-step codeMark Rousskov-2/+1
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+29
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
2022-10-23Allow specifying multiple alternative suggestionsXiretza-3/+23
This allows porting uses of span_suggestions() to diagnostic structs. Doesn't work for multipart_suggestions() because the rank would be reversed - the struct would specify multiple spans, each of which has multiple possible replacements, while multipart_suggestions() creates multiple possible replacements, each with multiple spans.
2022-10-20Implement assertions and fixes to not emit empty spans without suggestionsKevin Per-0/+25
2022-10-19Implement -Ztrack-diagnosticsmejrs-0/+29
2022-10-12UPDATE - Move IntoDiagnosticArg implementations to diagnostic_impls fileJhonny Bill Mena-149/+2