about summary refs log tree commit diff
path: root/compiler/rustc_error_messages
AgeCommit message (Collapse)AuthorLines
2022-11-04fix #102806, suggest use .. to fill in the rest of the fields of Structyukang-0/+3
2022-11-04Use `derive(Subdiagnostic)` for `ChangeFieldsToBeOfUnitType`.Charles Lew-2/+1
2022-11-03Stabilize default_alloc_error_handlerAmanieu d'Antras-6/+0
Closes #66741
2022-11-01Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3Dylan DPC-6/+16
Rewrite implementation of `#[alloc_error_handler]` The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-11-01Rollup merge of #103772 - compiler-errors:better-strict-coherence-err, ↵Yuki Okushi-0/+4
r=davidtwco better error for `rustc_strict_coherence` misuse Fixes #103753
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-6/+16
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-30better error for rustc_strict_coherence misuseMichael Goulet-0/+4
2022-10-29Use tcx.require_lang_itemCameron Steffen-3/+0
2022-10-29Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obkMatthias Krüger-1/+1
Note scope of TAIT more accurately This maybe explains why the person was confused in #101897, since we say "same module" but really should've said "same impl". r? ``@oli-obk``
2022-10-27tidy + move logic to fnBoxy-2/+2
2022-10-27use proper spansBoxy-1/+3
2022-10-27DoItBoxy-0/+2
2022-10-25Split diagnostic details out into a separate function and fluent filesOli Scherer-0/+9
2022-10-24Port `dead_code` lints to be translatable.Charles Lew-0/+34
2022-10-23Introduce dedicated `-Zdylib-lto` flag for enabling LTO on `dylib`sJakub Beránek-0/+2
2022-10-22Note scope of TAIT more accuratelyMichael Goulet-1/+1
2022-10-21Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errorsDylan DPC-1/+7
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-17Rollup merge of #102454 - chenyukang:fix-102396-missing-parentheses, r=lcnrMatthias Krüger-0/+4
Suggest parentheses for possible range method calling Fixes #102396
2022-10-17infer: use derive moreDavid Wood-1/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-17session: use derive moreDavid Wood-0/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-17trivial fix for comments feedbackyukang-1/+1
2022-10-14Add missing checks for `doc(cfg_hide(...))` attributeGuillaume Gomez-0/+3
2022-10-14Auto merge of #102684 - ↵bors-14/+14
JhonnyBillM:delete-target-data-layout-errors-wrapper, r=davidtwco Move `IntoDiagnostic` conformance for `TargetDataLayoutErrors` into `rustc_errors` Addressed this suggestion https://github.com/rust-lang/rust/pull/101558#issuecomment-1243830009. 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-13Add suggestion to the "missing native library" errorWesley Wiser-0/+2
If we fail to locate a native library that we are linking with, it could be the case the user entered a complete file name like `foo.lib` or `libfoo.a` when we expect them to simply provide `foo`. In this situation, we now detect that case and suggest the user only provide the library name itself.
2022-10-12ADD - IntoDiagnostic conformance for TargetDataLayoutErrors in rustc_errorsJhonny Bill Mena-14/+14
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 #102719 - Nilstrieb:tidy-alphabetical, r=jackh726Dylan DPC-0/+2
Enforce alphabetical sorting with tidy We have many places where things are supposed to be sorted alphabetically. For the smaller and more recent size assertions, this is mostly upheld, but in other more... alive places it's very messy. This introduces a new tidy directive to check that a section of code is sorted alphabetically and fixes all places where sorting has gone wrong.
2022-10-12Rollup merge of #102623 - davidtwco:translation-eager, r=compiler-errorsDylan DPC-1/+30
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-12Use `tidy-alphabetical` in the compilerNilstrieb-0/+2
2022-10-12Rollup merge of #102110 - CleanCut:migrate_rustc_passes_diagnostics, r=davidtwcoDylan DPC-81/+487
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-11Rollup merge of #102893 - TaKO8Ki:fix-102878, r=davidtwcoMatthias Krüger-13/+0
Fix ICE #102878 Fixes #102878
2022-10-11fix #102878Takayuki Maeda-13/+0
2022-10-10query_system: finish migrationDavid Wood-0/+2
Using eager translation, migrate the remaining repeated cycle stack diagnostic. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10errors: `DiagnosticMessage::Eager`David Wood-1/+28
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>
2022-10-07avoid string dispatch in fluentNathan Stocks-17/+19
2022-10-07avoid string dispatch in fluentNathan Stocks-5/+21
2022-10-07First batch of review feedback changes from #102110Nathan Stocks-1/+10
2022-10-07migrate stability.rs to translateable diagnosticsNathan Stocks-0/+50
2022-10-07migrate the rest of check_attr.rs to translateable diagnosticsNathan Stocks-0/+36
2022-10-07migrate dead.rs to translateable diagnosticsNathan Stocks-0/+6
2022-10-07migrate lang_items.rs to translateable diagnosticsNathan Stocks-3/+27
2022-10-07migrate entry.rs to translateable diagnosticsNathan Stocks-0/+39
2022-10-07migrate naked_functions.rs to translateable diagnosticsNathan Stocks-0/+28
2022-10-07migrate loops.rs to translateable diagnosticsNathan Stocks-0/+34
2022-10-07migrate check_const.rs to translateable diagnosticsNathan Stocks-0/+7
2022-10-07migrate lib_features.rs to translateable diagnosticsNathan Stocks-0/+6
2022-10-07migrate layout_test.rs to translateable diagnosticsNathan Stocks-0/+21
2022-10-07migrate diagnostic_items.rs to translateable diagnosticsNathan Stocks-1/+11
2022-10-07use cherry-picked commit from #100754 to emit note without errorNathan Stocks-2/+4
2022-10-07migrate the rest of weak_lang_items.rs to translateable diagnosticsNathan Stocks-3/+3
2022-10-07resolve merge conflict from cherry-picking ↵Diego de Oliveira-0/+3
6a47326a0452cc8d5cb57676508b5469d648c67f