about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-04-12Rollup merge of #110135 - compiler-errors:revert-108031, r=davidtwcoMatthias Krüger-2/+0
Revert "Don't recover lifetimes/labels containing emojis as character literals" Reverts PR #108031 per https://github.com/rust-lang/rust/pull/109754#issuecomment-1490452045 Fixes (doesnt close until beta backported) #109746 This reverts commit e3f9db5fc319c6d8eee5d47d216ea6a426070c41. This reverts commit 98b82aedba3f3f581e89df54352914b27f42c6f7. This reverts commit 380fa264132ad481e73cbbf0f3a0feefd99a1d78.
2023-04-10Migrate most of `rustc_builtin_macros` to diagnostic implsclubby789-1/+3
Co-authored-by: Joe ST <joe@fbstj.net> Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-10Stabilize IsTerminalJosh Triplett-1/+0
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-10Revert "Don't recover lifetimes/labels containing emojis as character literals"Michael Goulet-2/+0
Reverts PR #108031 Fixes (doesnt close until beta backported) #109746 This reverts commit e3f9db5fc319c6d8eee5d47d216ea6a426070c41. This reverts commit 98b82aedba3f3f581e89df54352914b27f42c6f7. This reverts commit 380fa264132ad481e73cbbf0f3a0feefd99a1d78.
2023-03-21Avoid ICE of attempt to add with overflow in emitteryukang-1/+1
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-04Properly colorize multi-part suggestions in the same lineEsteban Küber-1/+1
Fix #108547.
2023-02-26Rollup merge of #108482 - Ezrashaw:force-error-docs, r=GuillaumeGomezMatthias Krüger-3/+1
statically guarantee that current error codes are documented Closes #61137 (that's right!) Pretty simple refactor (often just a change from `Result<Option<&str>>` to `Result<&str>`) r? `@GuillaumeGomez` (could you specially look at 53044158eff0d64673a6100f701c57b484232aca? I believe you wrote that in the first place, just want to make sure you're happy with the change)
2023-02-26refactor: statically guarantee that current error codes are documentedEzra Shaw-3/+1
2023-02-25Add ErrorGuaranteed to HIR TyKind::ErrMichael Goulet-15/+1
2023-02-22errors: generate typed identifiers in each crateDavid Wood-2/+4
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-18Rollup merge of #108031 - jieyouxu:issue-108019, r=estebankMatthias Krüger-0/+2
Don't recover lifetimes/labels containing emojis as character literals Fixes #108019. Note that at the time of this commit, `unic-emoji-char` seems to have data tables only up to Unicode 5.0, but Unicode is already newer than this. A newer emoji such as `🥺` will not be recognized as an emoji but older emojis such as `🐱` will. This PR leaves a couple of FIXMEs where `unic_emoji_char::is_emoji` is used.
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-16/+13
2023-02-14Don't recover lifetimes/labels containing emojis as character literals许杰友 Jieyou Xu (Joe)-0/+2
Note that at the time of this commit, `unic-emoji-char` seems to have data tables only up to Unicode 5.0, but Unicode is already newer than this. A newer emoji such as `🥺` will not be recognized as an emoji but older emojis such as `🐱` will.
2023-02-09Introduce `-Zterminal-urls` to use OSC8 for error codesEsteban Küber-0/+8
Terminals supporting the OSC8 Hyperlink Extension can support inline anchors where the text is user defineable but clicking on it opens a browser to a specified URLs, just like `<a href="URL">` does in HTML. https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-9/+32
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30errors: add `emit_note`/`create_note` on `Handler`David Wood-0/+11
Support for emission of notes was added in f8ebc72 but `emit_note` and `create_note` functions weren't added to `Handler`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-20add debug assertion for suggestions with overlapping partsLukas Markeffsky-0/+1
2023-01-11Rollup merge of #106427 - mejrs:translation_errors, r=davidtwconils-1/+16
Improve fluent error messages These have been really frustrating me while migrating diagnostics.
2023-01-09Collect backtraces for delayed span-bugs tooMichael Goulet-23/+15
2023-01-08Make translate_message return result and add testsmejrs-1/+11
2023-01-07Rollup merge of #104543 - ↵Matthias Krüger-0/+14
JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs-pt3, r=davidtwco Migrate `codegen_ssa` to diagnostics structs - [Part 3] Completes migrating `codegen_ssa` module except 2 outstanding errors that depend on other crates: 1. [`rustc_middle::mir::interpret::InterpError`](https://github.com/rust-lang/rust/blob/b6097f2e1b2ca62e188ba53cf43bd66b06b36915/compiler/rustc_middle/src/mir/interpret/error.rs#L475): I saw `rustc_middle` is unassigned, I am open to take this work. 2. `codegen_llvm`'s use of `fn span_invalid_monomorphization_error`, which I started to replace in the [last commit](https://github.com/rust-lang/rust/commit/9a31b3cdda78a2c0891828254fe9886e0a1cfd16) of this PR, but would like to know the team's preference on how we should keep replacing the other macros: 2.1. Update macros to expect a `Diagnostic` 2.2. Remove macros and expand the code on each use. See [some examples of the different options in this experimental commit](https://github.com/JhonnyBillM/rust/commit/64aee83e80857dcfa450f0c6e31d5f29c6d577e6) _Part 2 - https://github.com/rust-lang/rust/pull/103792_ r? ``@davidtwco`` Cc ``@compiler-errors``
2023-01-06Rollup merge of #106287 - Nilstrieb:its-bugging-me-how-we-dont-have-docs, ↵Matthias Krüger-0/+2
r=jyn514 Add some docs to `bug`, `span_bug` and `delay_span_bug` cc `@mejrs` as you wanted me to do this, does this look good and understandable?
2023-01-05Improve fluent error messagesmejrs-0/+5
2023-01-02Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkovbors-50/+56
Encode spans relative to the enclosing item -- enable on nightly Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default. This PR seeks to remove one of the main shortcomings of incremental: the handling of spans. Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed. Within one file: all the spans in HIR change, so typechecking had to be re-done. Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span). The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query. Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent. In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode: - the parent when the `SyntaxContext` is 0; - the `SyntaxContext` when the parent is `None`. Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans. The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required. Possible future directions: - validate that all spans are marked in HIR validation; - mark macro-expanded spans relative to the def-site and not the use-site.
2022-12-31Only deduplicate stack traces for good path bugsMichael Goulet-12/+18
2022-12-30Add some docs to `bug`, `span_bug` and `delay_span_bug`Nilstrieb-0/+2
2022-12-27ADD - create and emit Bug support for DiagnosticsJhonny Bill Mena-0/+14
UPDATE - migrate constant span_bug to translatable diagnostic.
2022-12-25Ignore span references from diagnostics.Camille GILLOT-47/+51
The diagnostics are replayed at the correct place anyway.
2022-12-25Use absolute spans when trying to steal an AST diagnostic.Camille GILLOT-3/+5
2022-12-25fix more clippy::style findingsMatthias Krüger-2/+2
match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed
2022-12-15more clippy::complexity fixesMatthias Krüger-1/+1
2022-12-04Rollup merge of #101975 - chenyukang:fix-101749, r=compiler-errorsMatthias Krüger-0/+1
Suggest to use . instead of :: when accessing a method of an object Fixes #101749 Fixes #101542
2022-12-03fix #101749, use . instead of :: when accessing a method of an objectyukang-0/+1
2022-12-01Remove useless borrows and derefsMaybe Waffle-1/+1
2022-11-24make `error_reported` check for delayed bugsBoxy-3/+18
2022-11-20Rollup merge of #104504 - compiler-errors:fru-syntax-note, r=estebankMatthias Krüger-0/+3
Add a detailed note for missing comma typo w/ FRU syntax Thanks to `@pierwill` for working on this with me! Fixes #104373, perhaps `@alice-i-cecile` can comment on the new error for the example provided on that issue -- feedback is welcome. ``` error[E0063]: missing field `defaulted` in initializer of `Outer` --> $DIR/multi-line-fru-suggestion.rs:14:5 | LL | Outer { | ^^^^^ missing `defaulted` | note: this expression may have been misinterpreted as a `..` range expression --> $DIR/multi-line-fru-suggestion.rs:16:16 | LL | inner: Inner { | ________________^ LL | | a: 1, LL | | b: 2, LL | | } | |_________^ this expression does not end in a comma... LL | ..Default::default() | ^^^^^^^^^^^^^^^^^^^^ ... so this is interpreted as a `..` range expression, instead of functional record update syntax help: to set the remaining fields from `Default::default()`, separate the last named field with a comma | LL | }, | + error: aborting due to previous error For more information about this error, try `rustc --explain E0063`. ```
2022-11-19Rollup merge of #103117 - joshtriplett:use-is-terminal, r=eholkMatthias Krüger-0/+1
Use `IsTerminal` in place of `atty` In any crate that can use nightly features, use `IsTerminal` rather than `atty`: - Use `IsTerminal` in `rustc_errors` - Use `IsTerminal` in `rustc_driver` - Use `IsTerminal` in `rustc_log` - Use `IsTerminal` in `librustdoc`
2022-11-18Add a detailed note for missing comma in FRU syntax typoMichael Goulet-0/+3
2022-11-17Edit docs for `rustc_errors::Handler::stash_diagnostic`pierwill-2/+3
Clarify that the diagnostic can be retrieved with `steal_diagnostic`.
2022-11-10Don't print full paths in overlap errorsMichael Goulet-0/+4
2022-11-04Rollup merge of #103397 - crlf0710:port_dead_code_lint, r=davidtwcoMatthias Krüger-1/+1
Port `dead_code` lints to be translatable. This adds an additional comma to lists with three or more items, to be consistent with list formatters like `icu4x`. r? `@davidtwco`
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+32
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-31Add more track_callermejrs-2/+4
2022-10-24Port `dead_code` lints to be translatable.Charles Lew-1/+1
2022-10-23Rollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebankDylan DPC-0/+3
Recover when unclosed char literal is parsed as a lifetime in some positions Fixes #101278
2022-10-22Recover unclosed char literal being parsed as lifetimeMichael Goulet-0/+3
2022-10-19Implement -Ztrack-diagnosticsmejrs-0/+30
2022-10-16Use IsTerminal in rustc_errorsJosh Triplett-0/+1
2022-10-12UPDATE - Move IntoDiagnosticArg implementations to diagnostic_impls fileJhonny Bill Mena-2/+3