about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/diagnostic.rs
AgeCommit message (Collapse)AuthorLines
2025-07-19rename `emit_unless` to `emit_unless_delay`xizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-10Make `Diag::multipart_suggestions` always verboseEsteban Küber-1/+1
2025-07-03refactor: Make -Ztrack-diagnostics emit like a noteScott Schafer-0/+9
2025-06-30linkify CodeSuggestion in doc commentsDan Johnson-2/+2
2025-06-25Add runtime check to avoid overwrite arg easily in diag and store and ↵xizheyin-1/+31
restore snapshot when set subdiag arg Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-05-27Remove an unnecessary use of `Box::into_inner`.Nicholas Nethercote-1/+1
2025-04-16Move eager translation to a method on `Diag`Jake Goulding-20/+13
This will allow us to eagerly translate messages on a top-level diagnostic, such as a `LintDiagnostic`. As a bonus, we can remove the awkward closure passed into Subdiagnostic and make better use of `Into`.
2025-04-08Remove unnecessary dyn Display in favor of strMichael Goulet-4/+4
2025-04-03Split ExpectationLintId off LevelOli Scherer-4/+17
2025-03-07compiler: Use size_of from the prelude instead of importedThalia Archibald-1/+1
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-02-25add doc comment detailEsteban Küber-0/+6
2025-02-25Teach structured errors to display short `Ty`Esteban Küber-3/+3
Make it so that every structured error annotated with `#[derive(Diagnostic)]` that has a field of type `Ty<'_>`, the printing of that value into a `String` will look at the thread-local storage `TyCtxt` in order to shorten to a length appropriate with the terminal width. When this happen, the resulting error will have a note with the file where the full type name was written to. ``` error[E0618]: expected function, found `((..., ..., ..., ...), ..., ..., ...)`` --> long.rs:7:5 | 6 | fn foo(x: D) { //~ `x` has type `(... | - `x` has type `((..., ..., ..., ...), ..., ..., ...)` 7 | x(); //~ ERROR expected function, found `(... | ^-- | | | call expression requires function | = note: the full name for the type has been written to 'long.long-type-14182675702747116984.txt' = note: consider using `--verbose` to print the full type name to the console ```
2025-02-02Rollup merge of #136415 - estebank:highlight-clarification, r=compiler-errorsMatthias Krüger-5/+15
Highlight clarifying information in "expected/found" error When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output. Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful. ![Screenshot of the rustc highlighted output on the terminal](https://github.com/user-attachments/assets/aa4b9433-5332-4941-b2c2-1a43e5cadff7)
2025-02-02Highlight clarifying information in "expected/found" errorEsteban Küber-5/+15
When the expected and found types have the same textual representation, we add clarifying in parentheses. We now visually highlight it in the output. Detect a corner case where the clarifying information would be the same for both types and skip it, as it doesn't add anything useful.
2025-01-31Rework "long type names" printing logicEsteban Küber-0/+31
Make it so more type-system types can be printed in a shortened version (like `Predicate`s). Centralize printing the information about the "full type name path". Make the "long type path" for the file where long types are written part of `Diag`, so that it becomes easier to keep track of it, and ensure it will always will be printed out last in the diagnostic by making its addition to the output implicit. Tweak the shortening of types in "expected/found" labels. Remove dead file `note.rs`.
2025-01-11fix `it's` -> `its` in doc commentYotam Ofek-1/+1
2024-12-31Convert some Into impls into From implsMichael Goulet-3/+3
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-12Implement a Method to Seal `DiagInner`'s SuggestionsVeera-12/+24
2024-09-11clippy::useless_conversionMichael Goulet-2/+2
2024-09-06Check AttrId for expectations.Camille GILLOT-22/+2
2024-09-02Rollup merge of #129875 - Sajjon:sajjon_fix_typos_batch_1, ↵Matthias Krüger-1/+1
r=compiler-errors,jieyouxu chore: Fix typos in 'compiler' (batch 1) Batch 1/3: Fixes typos in `compiler` (See [issue](https://github.com/rust-lang/rust/issues/129874) tracking all PRs with typos fixes)
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-1/+1
2024-08-31Remove attr_id from stable lint ids.Camille GILLOT-1/+1
2024-08-31Use AttrId key for unstable<->stable expectation map.Camille GILLOT-12/+7
2024-08-27Add `warn(unreachable_pub)` to `rustc_errors`.Nicholas Nethercote-1/+1
2024-08-09use stable sort to sort multipart diagnosticsFolkert-2/+2
2024-08-06Maintain highlighting in `note` and `help` even when they have a spanEsteban Küber-0/+21
2024-07-29Reformat `use` declarations.Nicholas Nethercote-13/+14
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-26Automatically taint InferCtxt when errors are emittedOli Scherer-1/+1
2024-06-26Restrict diagnostic context lifetime of InferCtxt to itself instead of TyCtxtOli Scherer-0/+5
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-5/+2
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-9/+10
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-2/+0
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-15Fix the dedup error because of spans from suggestionyukang-1/+1
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-0/+1
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-0/+1
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-3/+3
2024-04-20Print note with closure signature on type mismatchDaniel Sedlak-1/+1
2024-03-14Make `SubdiagMessageOp` well-formedMichael Goulet-1/+2
2024-03-11Rename `DecorateLint` as `LintDiagnostic`.Nicholas Nethercote-2/+2
To match `derive(LintDiagnostic)`.
2024-03-11Rename `AddToDiagnostic` as `Subdiagnostic`.Nicholas Nethercote-7/+7
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-14/+14
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-11Rename `IntoDiagnosticArg` as `IntoDiagArg`.Nicholas Nethercote-8/+8
Also rename `into_diagnostic_arg` as `into_diag_arg`, and `NotIntoDiagnosticArg` as `NotInotDiagArg`.
2024-03-06Add missing `#[rustc_lint_diagnostics]` attributes.Nicholas Nethercote-0/+31
Prior to the previous commit, `#[rust_lint_diagnostics]` attributes could only be used on methods with an `impl Into<{D,Subd}iagMessage>` parameter. But there are many other nearby diagnostic methods (e.g. `Diag::span`) that don't take such a parameter and should have the attribute. This commit adds the missing attribute to these `Diag` methods. This requires adding some missing `#[allow(rustc::diagnostic_outside_of_impl)]` markers at call sites to these methods.
2024-03-05Adjust `Diag::new` signature.Nicholas Nethercote-1/+1
Make it use `impl Into<DiagMessage>` like all the other methods nearby.
2024-03-05Rename `SubdiagnosticMessageOp` as `SubdiagMessageOp`.Nicholas Nethercote-2/+2
2024-03-05Rename `SubdiagnosticMessage` as `SubdiagMessage`.Nicholas Nethercote-31/+30
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-14/+14