about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/emitter.rs
AgeCommit message (Collapse)AuthorLines
2022-09-12A SubstitutionPart is not a deletion if it replaces nothing with nothingMichael Goulet-1/+1
2022-09-10rustc_error, rustc_private, rustc_ast: Switch to stable hash containersNiklas Jonsson-2/+2
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-15errors: move translation logic into moduleDavid Wood-110/+18
Just moving code around so that triagebot can ping relevant parties when translation logic is modified. Signed-off-by: David Wood <david.wood@huawei.com>
2022-08-10errors: don't fail on broken primary translationsDavid Wood-31/+49
If a primary bundle doesn't contain a message then the fallback bundle is used. However, if the primary bundle's message is broken (e.g. it refers to a interpolated variable that the compiler isn't providing) then this would just result in a compiler panic. While there aren't any primary bundles right now, this is the type of issue that could come up once translation is further along. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-19Mention first and last macro in backtraceMichael Goulet-6/+18
2022-07-06session: `output-width` -> `diagnostic-width`David Wood-8/+8
Rename the `--output-width` flag to `--diagnostic-width` as this appears to be the preferred name within the compiler team. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-06session: `terminal-width` -> `output-width`David Wood-8/+8
Rename the `--terminal-width` flag to `--output-width` as the behaviour doesn't just apply to terminals (and so is slightly less accurate). Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-28Migrate some rustc_borrowck diagnostics to SessionDiagnosticMichael Goulet-2/+12
2022-06-20remove MAX_SUGGESTION_HIGHLIGHT_LINESMaybe Waffle-5/+0
2022-06-17Auto merge of #97892 - klensy:fix-spaces, r=oli-obkbors-4/+8
diagnostics: remove trailing spaces Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
2022-06-16Add back MAX_SUGGESTION_HIGHLIGHT_LINES so clippy is happy & buildableMaybe Waffle-0/+5
2022-06-16Try to clean up code...Maybe Waffle-93/+150
I'm not sure if I succeeded
2022-06-16Improve suggestions when its parts are far from each otherMaybe Waffle-68/+99
Previously we only show at most 6 lines of suggestions and, if the suggestions are more than 6 lines apart, we've just showed ... at the end. This is probably fine, but quite confusing in my opinion. This commit is an attempt to show ... in places where there is nothing to suggest instead, for example: Before: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | 5 | 6 | 7 | 8 | ... ``` After: ```text help: consider enclosing expression in a block | 3 ~ 'l: { match () { () => break 'l, 4 | ... 31| 32~ } }; | ```
2022-06-16drive by fix needless allocation of const string numberklensy-2/+6
2022-06-16 fix one more case of trailing spaceklensy-1/+1
2022-06-16diagnostics: fix trailing spaceklensy-1/+1
2022-06-01Mention filename in suggestion when it differs from primary spanEsteban Küber-4/+33
2022-05-29Ensure source file present when calculating max line numberYuki Okushi-2/+9
Co-authored-by: Ross MacArthur <ross@macarthur.io>
2022-04-27Plumb through rustc_lint_defs::Level as enum rather than string.Jeremy Fitzhardinge-1/+6
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-9/+10
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05macros: translatable struct attrs and warningsDavid Wood-2/+8
Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-1/+8
Extend loading of Fluent bundles so that bundles can be loaded from the sysroot based on the language requested by the user, or using a nightly flag. Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-21/+135
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-5/+5
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: introduce `DiagnosticMessage`David Wood-9/+11
Introduce a `DiagnosticMessage` type that will enable diagnostic messages to be simple strings or Fluent identifiers. `DiagnosticMessage` is now used in the implementation of the standard `DiagnosticBuilder` APIs. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-20Take &mut Diagnostic in emit_diagnostic.Camille GILLOT-1/+1
Taking a Diagnostic by move would break the usual pattern `diag.label(..).emit()`.
2022-03-09Account for suggestions for complete removal of linesEsteban Kuber-0/+25
Fix #94192.
2022-02-27Only create a single expansion for each inline integration.Camille GILLOT-2/+2
2022-02-19Adopt let else in more placesest31-6/+4
2022-01-24rustc_errors: remove `allow_suggestions` from `DiagnosticBuilder`.Eduard-Mihai Burtescu-3/+4
2021-11-30Rollup merge of #91358 - kd-collective:fix_typo, r=cjgillotYuki Okushi-1/+1
Fix small typo Fix a typo in code commenting! `accross` -> `across`
2021-11-30Fix small typokijima-1/+1
2021-11-27Refactor EmitterWriter::emit_suggestion_defaultLucas Kent-14/+25
2021-11-23`replace_tabs` -> `normalize_whitespace`Esteban Kuber-6/+6
2021-11-23Replace ZWJ with nothing in terminal outputEsteban Kuber-0/+1
2021-11-20Align multiline messages to their label (add left margin)Esteban Kuber-1/+16
2021-10-31Lint against RTL unicode codepoints in literals and commentsEsteban Küber-1/+19
Address CVE-2021-42574.
2021-10-23Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726Matthias Krüger-4/+17
Report fatal lexer errors in `--cfg` command line arguments Fixes #89358. The erroneous behavior was apparently introduced by `@Mark-Simulacrum` in https://github.com/rust-lang/rust/commit/a678e3191197f145451c97c6cc884e15cae38186; the idea is to silence individual parser errors and instead emit one catch-all error message after parsing. However, for the example in #89358, a fatal lexer error is created here: https://github.com/rust-lang/rust/blob/edebf77e0090195bf80c0d8cda821e1bf9d03053/compiler/rustc_parse/src/lexer/mod.rs#L340-L349 This fatal error aborts the compilation, and so the call to `new_parser_from_source_str()` never returns and the catch-all error message is never emitted. I have therefore changed the `SilentEmitter` to silence only non-fatal errors; with my changes, for the rustc invocation described in #89358: ```sh rustc --cfg "abc\"" ``` I get the following output: ``` error[E0765]: unterminated double quote string | = note: this error occurred on the command line: `--cfg=abc"` ```
2021-10-16Adopt let_else across the compilerest31-5/+1
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-07use structured fields in some existing warningsEliza Weisman-1/+1
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-02Report fatal lexer errors in `--cfg` command line argumentsFabian Wolff-4/+17
2021-08-27Path remapping: Make behavior of diagnostics output dependent on presence of ↵Michael Woerister-4/+4
--remap-path-prefix.
2021-08-23Fixes to span locationsEsteban Kuber-9/+8
2021-08-23wipEsteban Kuber-19/+11
2021-08-23Account for tabs when highlighting multiline code suggestionsEsteban Kuber-19/+29
2021-08-11Modify structured suggestion outputEsteban Küber-18/+102
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-2/+5
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-8/+19
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-11Simplify future incompatible reporting.Eric Huss-2/+1