about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
AgeCommit message (Collapse)AuthorLines
2022-11-18Fix compilation issue after rebaseCharles Lew-0/+3
2022-11-18Migrate diagnostics list output to use icu list formatter.Charles Lew-18/+6
2022-11-18Add a detailed note for missing comma in FRU syntax typoMichael Goulet-0/+3
2022-11-18Rollup merge of #101162 - rajputrajat:master, r=davidtwcoMatthias Krüger-0/+6
Migrate rustc_resolve to use SessionDiagnostic, part # 1 crate a somewhat on larger size, so plz allow some time to get it finished.
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-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-1/+1
2022-11-14Rollup merge of #104229 - compiler-errors:overlap-full-path, r=davidtwcoMatthias Krüger-0/+4
Don't print full paths in overlap errors We don't print the full path in other diagnostics -- I don't think it particularly helps with the error message. I also delayed the printing until actually needing to render the error message. r? diagnostics
2022-11-14Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-4/+2
Bump bootstrap compiler to 1.66 This PR: - Bumps version placeholders to release - Bumps to latest beta - cfg-steps code r? `@pietroalbini`
2022-11-13migrating rustc_resolve to SessionDiagnostic. work in progress. startRajput, Rajat-0/+6
implement binding_shadows migrate till self-in-generic-param-default use braces in fluent message as suggested by @compiler-errors. to fix lock file issue reported by CI migrate 'unreachable label' error run formatter name the variables correctly in fluent file SessionDiagnostic -> Diagnostic test "pattern/pat-tuple-field-count-cross.rs" passed test "resolve/bad-env-capture2.rs" passed test "enum/enum-in-scope.rs" and other depended on "resolve_binding_shadows_something_unacceptable" should be passed now. fix crash errors while running test-suite. there might be more. then_some(..) suits better here. all tests passed convert TraitImpl and InvalidAsm. TraitImpl is buggy yet. will fix after receiving help from Zulip migrate "Ralative-2018" migrate "ancestor only" migrate "expected found" migrate "Indeterminate" migrate "module only" revert to the older implementation for now. since this is failing at the moment. follow the convension for fluent variable order the diag attribute as suggested in review comment fix merge error. migrate trait-impl-duplicate make the changes compatible with "Flatten diagnostic slug modules #103345" fix merge remove commented code merge issues fix review comments fix tests
2022-11-12Rollup merge of #103970 - oli-obk:unhide_unknown_spans, r=estebankDylan DPC-21/+40
Unhide unknown spans r? ```@estebank```
2022-11-11Rollup merge of #104217 - Nilstrieb:funny-dollar-syntax, r=TaKO8KiDylan DPC-9/+29
Display help message when fluent arg was referenced incorrectly The fluent argument syntax is a little special and easy to get wrong, so we emit a small help message when someone gets it wrong. Example: ``` parser_mismatched_closing_delimiter = mismatched closing delimiter: `${delimiter}` ``` panics with ``` thread 'rustc' panicked at 'Encountered errors while formatting message for `parser_mismatched_closing_delimiter` help: Argument `delimiter` exists but was not referenced correctly. Try using `{$delimiter}` instead attr: `None` args: `FluentArgs([("delimiter", String("}"))])` errors: `[ResolverError(Reference(Message { id: "delimiter", attribute: None }))]`', compiler/rustc_errors/src/translation.rs:123:21 ``` fixes #103539
2022-11-11Print all labels, even if they have no span. Fall back to main item's span.Oli Scherer-12/+35
2022-11-11Remove some redundant argumentsOli Scherer-9/+5
2022-11-09Rollup merge of #102763 - compiler-errors:nits, r=cjgillotMichael Goulet-7/+7
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-10Don't print full paths in overlap errorsMichael Goulet-0/+4
2022-11-09Display help message when fluent arg was referenced incorrectlyNilstrieb-9/+29
The fluent argument syntax is a little special and easy to get wrong, so we emit a small help message when someone gets it wrong. Example: ``` parser_mismatched_closing_delimiter = mismatched closing delimiter: `${delimiter}` ``` panics with ``` thread 'rustc' panicked at 'Encountered errors while formatting message for `parser_mismatched_closing_delimiter` help: Argument `delimiter` exists but was not referenced correctly. Try using `{$delimiter}` instead attr: `None` args: `FluentArgs([("delimiter", String("}"))])` errors: `[ResolverError(Reference(Message { id: "delimiter", attribute: None }))]`', compiler/rustc_errors/src/translation.rs:123:21 ```
2022-11-09rebase conflictMichael Goulet-2/+2
2022-11-09Make span_suggestions take IntoIteratorMichael Goulet-5/+5
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-09Port `DlltoolFailImportLibrary` and implement `IntoDiagnosticArg` for ↵SLASHLogin-0/+6
`Cow<'a, str>`
2022-11-08add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed'yukang-2/+2
2022-11-06cfg-step codeMark Rousskov-4/+2
2022-11-04Rollup merge of #103792 - ↵Matthias Krüger-1/+4
JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs-pt2, r=davidtwco Migrate `codegen_ssa` to diagnostics structs - [Part 2] Completes migrating `link.rs` in `codegen_ssa` module. _Part 1 - https://github.com/rust-lang/rust/pull/102612_ r? `@davidtwco`
2022-11-04Rollup merge of #103397 - crlf0710:port_dead_code_lint, r=davidtwcoMatthias Krüger-1/+33
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-04UPDATE - accept dyn error and make Box<dyn error> conform to IntoDiagnosticArgJhonny Bill Mena-0/+1
2022-11-04UPDATE - Complete link.rs migration to new diagnostics infraestructureJhonny Bill Mena-1/+3
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-5/+106
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-24Address some commentsmejrs-2/+2
2022-10-24Port `dead_code` lints to be translatable.Charles Lew-1/+33
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-23Auto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPCbors-0/+3
Rollup of 6 pull requests Successful merges: - #101293 (Recover when unclosed char literal is parsed as a lifetime in some positions) - #101908 (Suggest let for assignment, and some code refactor) - #103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`) - #103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis) - #103249 (resolve: Revert "Set effective visibilities for imports more precisely") - #103305 (Move some tests to more reasonable places) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
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-23Migrate all diagnosticsNilstrieb-7/+7
2022-10-22Recover unclosed char literal being parsed as lifetimeMichael Goulet-0/+3
2022-10-21Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errorsDylan DPC-3/+18
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use - Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing. - Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic. - Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc. cc #100717
2022-10-20Implement assertions and fixes to not emit empty spans without suggestionsKevin Per-0/+25
2022-10-19Implement -Ztrack-diagnosticsmejrs-5/+104
2022-10-17lint: use derive moreDavid Wood-3/+18
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-16Use IsTerminal in rustc_errorsJosh Triplett-3/+4
2022-10-12UPDATE - Move IntoDiagnosticArg implementations to diagnostic_impls fileJhonny Bill Mena-152/+160
2022-10-12ADD - IntoDiagnostic conformance for TargetDataLayoutErrors in rustc_errorsJhonny Bill Mena-0/+54
This way we comply with the Coherence rule given that IntoDiagnostic trait is defined in rustc_errors, and almost all other crates depend on it.
2022-10-12Rollup merge of #102623 - davidtwco:translation-eager, r=compiler-errorsDylan DPC-27/+87
translation: eager translation Part of #100717. See [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20lists!/near/295010720) for additional context. - **Store diagnostic arguments in a `HashMap`**: Eager translation will enable subdiagnostics to be translated multiple times with different arguments - this requires the ability to replace the value of one argument with a new value, which is better suited to a `HashMap` than the previous storage, a `Vec`. - **Add `AddToDiagnostic::add_to_diagnostic_with`**: `AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure. - **Add `DiagnosticMessage::Eager`**: Add variant of `DiagnosticMessage` for eagerly translated messages (messages in the target language which don't need translated by the emitter during emission). Also adds `eager_subdiagnostic` function which is intended to be invoked by the diagnostic derive for subdiagnostic fields which are marked as needing eager translation. - **Support `#[subdiagnostic(eager)]`**: Add support for `eager` argument to the `subdiagnostic` attribute which generates a call to `eager_subdiagnostic`. - **Finish migrating `rustc_query_system`**: Using eager translation, migrate the remaining repeated cycle stack diagnostic. - **Split formatting initialization and use in diagnostic derives**: Diagnostic derives have previously had to take special care when ordering the generated code so that fields were not used after a move. This is unlikely for most fields because a field is either annotated with a subdiagnostic attribute and is thus likely a `Span` and copiable, or is a argument, in which case it is only used once by `set_arg` anyway. However, format strings for code in suggestions can result in fields being used after being moved if not ordered carefully. As a result, the derive currently puts `set_arg` calls last (just before emission), such as: let diag = { /* create diagnostic */ }; diag.span_suggestion_with_style( span, fluent::crate::slug, format!("{}", __binding_0), Applicability::Unknown, SuggestionStyle::ShowAlways ); /* + other subdiagnostic additions */ diag.set_arg("foo", __binding_0); /* + other `set_arg` calls */ diag.emit(); For eager translation, this doesn't work, as the message being translated eagerly can assume that all arguments are available - so arguments _must_ be set first. Format strings for suggestion code are now separated into two parts - an initialization line that performs the formatting into a variable, and a usage in the subdiagnostic addition. By separating these parts, the initialization can happen before arguments are set, preserving the desired order so that code compiles, while still enabling arguments to be set before subdiagnostics are added. let diag = { /* create diagnostic */ }; let __code_0 = format!("{}", __binding_0); /* + other formatting */ diag.set_arg("foo", __binding_0); /* + other `set_arg` calls */ diag.span_suggestion_with_style( span, fluent::crate::slug, __code_0, Applicability::Unknown, SuggestionStyle::ShowAlways ); /* + other subdiagnostic additions */ diag.emit(); - **Remove field ordering logic in diagnostic derive:** Following the approach taken in earlier commits to separate formatting initialization from use in the subdiagnostic derive, simplify the diagnostic derive by removing the field-ordering logic that previously solved this problem. r? ```@compiler-errors```
2022-10-12Rollup merge of #102110 - CleanCut:migrate_rustc_passes_diagnostics, r=davidtwcoDylan DPC-1/+51
Migrate rustc_passes diagnostics Picks up abandoned work from https://github.com/rust-lang/rust/pull/100870 I would like to do this collaboratively, as there is a lot of work! Here's the process: - Comment below that you are willing to help and I will add you as a collaborator to my `rust` fork (that gives you write access) - Indicate which file/task you would like to work on (so we don't duplicate work) from the list below - Do the work, push up a commit, comment that you're done with that file/task - Repeat until done 😄 ### Files to Migrate (in `compiler/rustc_passes/src/`) - [x] check_attr.rs ``@CleanCut`` - [x] check_const.rs ``@CleanCut`` - [x] dead.rs ``@CleanCut`` - [x] debugger_visualizer.rs ``@CleanCut`` - [x] diagnostic_items.rs ``@CleanCut`` - [x] entry.rs ``@CleanCut`` - [x] lang_items.rs ``@CleanCut`` - [x] layout_test.rs ``@CleanCut`` - [x] lib_features.rs ``@CleanCut`` - [x] ~liveness.rs~ ``@CleanCut`` Nothing to do - [x] loops.rs ``@CleanCut`` - [x] naked_functions.rs ``@CleanCut`` - [x] stability.rs ``@CleanCut`` - [x] weak_lang_items.rs ``@CleanCut`` ### Tasks - [x] Rebase on current `master` ``@CleanCut`` - [x] Review work from [the earlier PR](https://github.com/rust-lang/rust/pull/100870) and make sure it all looks good - [x] compiler/rustc_error_messages/locales/en-US/passes.ftl ``@CleanCut`` - [x] compiler/rustc_passes/src/check_attr.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/errors.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/lang_items.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/lib.rs ``@CleanCut`` - [x] compiler/rustc_passes/src/weak_lang_items.rs ``@CleanCut``
2022-10-10Fix doc lint errorGuillaume Gomez-1/+1
2022-10-10errors: `DiagnosticMessage::Eager`David Wood-2/+32
Add variant of `DiagnosticMessage` for eagerly translated messages (messages in the target language which don't need translated by the emitter during emission). Also adds `eager_subdiagnostic` function which is intended to be invoked by the diagnostic derive for subdiagnostic fields which are marked as needing eager translation. Signed-off-by: David Wood <david.wood@huawei.com>