about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/errors.rs
AgeCommit message (Collapse)AuthorLines
2023-03-30Rename doc(primitive) into rustc_doc_primitiveGuillaume Gomez-4/+0
2023-03-14Simplify proc macro signature validity checkMichael Goulet-43/+2
2023-02-26Merge the two diagnostics.Camille GILLOT-11/+5
2023-02-22Add check for invalid \`#[macro_export]\` argumentsblyxyas-2/+10
2023-02-22errors: generate typed identifiers in each crateDavid Wood-47/+45
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-01Auto merge of #107257 - inquisitivecrystal:ffi-attr, r=davidtwcobors-0/+28
Strengthen validation of FFI attributes Previously, `codegen_attrs` validated the attributes `#[ffi_pure]`, `#[ffi_const]`, and `#[ffi_returns_twice]` to make sure that they were only used on foreign functions. However, this validation was insufficient in two ways: 1. `codegen_attrs` only sees items for which code must be generated, so it was unable to raise errors when the attribute was incorrectly applied to macros and the like. 2. the validation code only checked that the item with the attr was foreign, but not that it was a foreign function, allowing these attributes to be applied to foreign statics as well. This PR moves the validation to `check_attr`, which sees all items. It additionally changes the validation to ensure that the attribute's target is `Target::ForeignFunction`, only allowing the attributes on foreign functions and not foreign statics. Because these attributes are unstable, there is no risk for backwards compatibility. The changes also ending up making the code much easier to read. This PR is best reviewed commit by commit. Additionally, I was considering moving the tests to the `attribute` subdirectory, to get them out of the general UI directory. I could do that as part of this PR or a follow-up, as the reviewer prefers. CC: #58328, #58329
2023-01-30session: diagnostic migration lint on more fnsDavid Wood-0/+7
Apply the diagnostic migration lint to more functions on `Session`. Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-26Rollup merge of #106407 - mejrs:attr_check, r=compiler-errorsMatthias Krüger-0/+50
Improve proc macro attribute diagnostics Closes https://github.com/rust-lang/rust/issues/102923
2023-01-24Move FFI attribute validation to `check_attr`inquisitivecrystal-0/+28
2023-01-12[RFC 2397] Deny incorrect locationsCaio-0/+7
2023-01-12Improve proc macro attribute diagnosticsmejrs-0/+50
2022-11-11Print all labels, even if they have no span. Fall back to main item's span.Oli Scherer-0/+3
2022-11-05Specify that `break` cannot be used outside of loop *or* labeled blockclubby789-0/+1
2022-11-04Rollup merge of #103397 - crlf0710:port_dead_code_lint, r=davidtwcoMatthias Krüger-1/+59
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-04Use `derive(Subdiagnostic)` for `ChangeFieldsToBeOfUnitType`.Charles Lew-23/+3
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-1/+1
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+5
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-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-8/+0
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-31Add more track_callermejrs-0/+5
2022-10-26Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]Xiretza-1/+1
Using the following command: find compiler/ -type f -name '*.rs' -exec perl -i -gpe \ 's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \ '{}' +
2022-10-24Port `dead_code` lints to be translatable.Charles Lew-1/+79
2022-10-23Migrate all diagnosticsNilstrieb-201/+200
2022-10-14Add missing checks for `doc(cfg_hide(...))` attributeGuillaume Gomez-0/+4
2022-10-07avoid string dispatch in fluentNathan Stocks-7/+36
2022-10-07avoid string dispatch in fluentNathan Stocks-7/+15
2022-10-07Remove code that was removed in master, and the corresponding diagnosticNathan Stocks-9/+0
2022-10-07First batch of review feedback changes from #102110Nathan Stocks-9/+1
2022-10-07migrate stability.rs to translateable diagnosticsNathan Stocks-0/+113
2022-10-07migrate the rest of check_attr.rs to translateable diagnosticsNathan Stocks-0/+41
2022-10-07migrate dead.rs to translateable diagnosticsNathan Stocks-1/+8
2022-10-07migrate lang_items.rs to translateable diagnosticsNathan Stocks-0/+74
2022-10-07migrate entry.rs to translateable diagnosticsNathan Stocks-2/+130
2022-10-07migrate naked_functions.rs to translateable diagnosticsNathan Stocks-0/+76
2022-10-07migrate loops.rs to translateable diagnosticsNathan Stocks-2/+119
2022-10-07migrate check_const.rs to translateable diagnosticsNathan Stocks-0/+18
2022-10-07migrate lib_features.rs to translateable diagnosticsNathan Stocks-0/+20
2022-10-07migrate layout_test.rs to translateable diagnosticsNathan Stocks-0/+57
2022-10-07migrate diagnostic_items.rs to translateable diagnosticsNathan Stocks-0/+20
2022-10-07use cherry-picked commit from #100754 to emit note without errorNathan Stocks-1/+4
2022-10-07migrate the rest of weak_lang_items.rs to translateable diagnosticsNathan Stocks-7/+8
2022-10-07resolve merge conflict from cherry-picking ↵Diego de Oliveira-0/+7
6a47326a0452cc8d5cb57676508b5469d648c67f
2022-10-07Migrate InvalidAttrAtCrateLevelrdvdev2-1/+31
Co-authored-by: Nathan Stocks <cleancut@github.com> Co-authored-by: rdvdev2 <rdvdev2@gmail.com>
2022-10-07Migrate derivable diagnostics in check_attr.rsrdvdev2-0/+11
2022-10-07Migrate derivable diagnostics in lang_items.rsrdvdev2-0/+21
2022-10-07Migrate weak_lang_items.rsrdvdev2-0/+17
2022-09-26Rollup merge of #101851 - Xiretza:diagnostic-derive-cleanups, r=davidtwcofee1-dead-2/+2
Clean up (sub)diagnostic derives The biggest chunk of this is unifying the parsing of subdiagnostic attributes (`#[error]`, `#[suggestion(...)]`, `#[label(...)]`, etc) between `Subdiagnostic` and `Diagnostic` type attributes as well as `Diagnostic` field attributes. It also improves a number of proc macro diagnostics. Waiting for #101558.
2022-09-23Rollup merge of #101815 - diegooliveira:master, r=davidtwcoMatthias Krüger-0/+7
Migrated the rustc_passes annotation without effect diagnostic infrastructure Small change to move the validation for annotations to the new diagnostic infrastructure.
2022-09-22Add missing code="" attributes to suggestion subdiagnosticsXiretza-2/+2
2022-09-21FIX - adopt new Diagnostic naming in newly migrated modulesJhonny Bill Mena-1/+1
FIX - ambiguous Diagnostic link in docs UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic [Gardening] FIX - formatting via `x fmt` FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way DELETE - unneeded allow attributes in Handler method FIX - broken test FIX - Rebase conflict UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
2022-09-21UPDATE - rename SessionSubdiagnostic macro to SubdiagnosticJhonny Bill Mena-2/+2
Also renames: - sym::AddSubdiagnostic to sym:: Subdiagnostic - rustc_diagnostic_item = "AddSubdiagnostic" to rustc_diagnostic_item = "Subdiagnostic"