about summary refs log tree commit diff
path: root/compiler/rustc_errors
AgeCommit message (Collapse)AuthorLines
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>
2022-10-10errors: `AddToDiagnostic::add_to_diagnostic_with`David Wood-4/+15
`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. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-10errors: use `HashMap` to store diagnostic argsDavid Wood-21/+40
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`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-07migrate dead.rs to translateable diagnosticsNathan Stocks-5/+1
2022-10-07errors: add `emit_note`/`create_note`David Wood-2/+56
Add `Noted` marker struct that implements `EmissionGuarantee` so that `emit_note` and `create_note` can be implemented for struct diagnostics. Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-06Auto merge of #102726 - matthiaskrgr:rollup-2ghn38b, r=matthiaskrgrbors-0/+1
Rollup of 5 pull requests Successful merges: - #102672 (rustdoc: remove unused CSS class `in-band`) - #102693 (Revert "Use getentropy when possible on all Apple platforms") - #102694 (Suggest calling method if fn does not exist) - #102708 (Suggest `==` to wrong assign expr) - #102710 (Add test for issue 82633) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-10-06Auto merge of #99324 - reez12g:issue-99144, r=jyn514bors-1/+0
Enable doctests in compiler/ crates Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-05Delay function resolution error until typeckMichael Goulet-0/+1
2022-10-01Compute `lint_levels` by definitionDeadbeef-3/+4
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-28/+9
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01Remove `LintDiagnosticBuilder`Maybe Waffle-25/+1
2022-10-01Refactor rustc lint APIMaybe Waffle-3/+8
2022-09-30Rollup merge of #102493 - nnethercote:improve-size-assertions-some-more, r=lqdMatthias Krüger-1/+1
Group together more size assertions. Also add a few more assertions for some relevant token-related types. And fix an erroneous comment in `rustc_errors`. r? `@lqd`
2022-09-30Rollup merge of #102373 - Nilstrieb:cannot-get-layout-of-branch-error, ↵Matthias Krüger-0/+6
r=cjgillot Flush delayed bugs before codegen Sometimes it can happen that invalid code like a TyKind::Error makes its way through the compiler without triggering any errors (this is always a bug in rustc but bugs do happen sometimes :)). These ICEs will manifest in the backend like as cg_llvm not being able to get the layout of `[type error]`, which makes it hard to debug. By flushing before codegen, we display all the delayed bugs, making it easier to trace it to the root of the problem. I tried this on #102366 and it showed tons of of delayed bugs and no error in cg_llvm, so it seems to be working.
2022-10-01Group together more size assertions.Nicholas Nethercote-1/+1
Also add a few more assertions for some relevant token-related types. And fix an erroneous comment in `rustc_errors`.
2022-09-30Rollup merge of #101075 - ellishg:rustc_codegen_gcc_diagnostics, r=davidtwcoMatthias Krüger-0/+13
Migrate rustc_codegen_gcc to SessionDiagnostics As part of #100717 this pr migrates diagnostics to `SessionDiagnostics` for the `rustc_codegen_gcc` crate. ``@rustbot`` label +A-translation
2022-09-29Remove from compiler/ cratesreez12g-1/+0
2022-09-28Auto merge of #101619 - Xiretza:rustc_parse-session-diagnostics, r=davidtwcobors-0/+22
Migrate more of rustc_parse to SessionDiagnostic Still far from complete, but I thought I'd add a checkpoint here because rebasing was starting to get annoying.
2022-09-28Auto merge of #102302 - nnethercote:more-lexer-improvements, r=matkladbors-1/+2
More lexer improvements A follow-up to #99884. r? `@matklad`
2022-09-27Flush delayed bugs before codegenNilstrieb-0/+6
Sometimes it can happen that invalid code like a TyKind::Error makes its way through the compiler without triggering any errors (this is always a bug in rustc but bugs do happen sometimes :)). These ICEs will manifest in the backend like as cg_llvm not being able to get the layout of `[type error]`, which makes it hard to debug. By flushing before codegen, we display all the delayed bugs, making it easier to trace it to the root of the problem.
2022-09-27Implement IntoDiagnosticArg for rustc_ast::token::Token(Kind)Xiretza-0/+12
2022-09-27Implement IntoDiagnosticArg for rustc_ast::PathXiretza-0/+10
2022-09-26remove cfg(bootstrap)Pietro Albini-2/+1
2022-09-26Rearrange `TokenTreesReader::parse_token_tree`.Nicholas Nethercote-1/+2
`parse_token_tree` is basically a match with four arms: `Eof`, `OpenDelim`, `CloseDelim`, and "other". It has two call sites, and at each call site one of the arms is unreachable. It's also not inlined. This commit removes `parse_token_tree` by splitting it into four functions and inlining them. This avoids some repeated conditional tests and also some non-inlined function calls on the hot path.
2022-09-24rebase and update trait namesEllis Hoag-0/+13
2022-09-24remove IntoDiagnosticArg impl for OptionEllis Hoag-9/+0
2022-09-24Add RanlibFailureEllis Hoag-0/+9
2022-09-22Revert "Auto merge of #101620 - cjgillot:compute_lint_levels_by_def, r=oli-obk"Camille GILLOT-4/+3
This reverts commit 2cb9a65684dba47c52de8fa938febf97a73e70a9, reversing changes made to 750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c.
2022-09-21FIX - adopt new Diagnostic naming in newly migrated modulesJhonny Bill Mena-44/+4
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-4/+5
Also renames: - sym::AddSubdiagnostic to sym:: Subdiagnostic - rustc_diagnostic_item = "AddSubdiagnostic" to rustc_diagnostic_item = "Subdiagnostic"
2022-09-21UPDATE - rename DiagnosticHandler macro to DiagnosticJhonny Bill Mena-2/+2
2022-09-21UPDATE - rename AddSubdiagnostic trait to AddToDiagnosticJhonny Bill Mena-4/+4
2022-09-21UPDATE - rename DiagnosticHandler trait to IntoDiagnosticJhonny Bill Mena-5/+79
2022-09-21UPDATE - move SessionDiagnostic from rustc_session to rustc_errorsJhonny Bill Mena-0/+10
2022-09-17Rollup merge of #101790 - ↵Dylan DPC-0/+4
TaKO8Ki:do-not-suggest-placeholder-to-const-and-static-without-type, r=compiler-errors Do not suggest a placeholder to const and static without a type Fixes #101755
2022-09-16do not suggest a placeholder to const and static without a typeTakayuki Maeda-0/+4
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-14Compute `lint_levels` by definitionDeadbeef-3/+4
2022-09-13Rollup merge of #101266 - LuisCardosoOliveira:translation-rustcsession-pt3, ↵Matthias Krüger-1/+1
r=davidtwco translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Final # Description This is the final part of the rustc_session https://github.com/rust-lang/rust/issues/100717#issuecomment-1220279883. Please only review this [commit](https://github.com/rust-lang/rust/pull/101266/commits/a54534703774bfb9fc344f61d511760a7c43fe94). The other ones are from the PR https://github.com/rust-lang/rust/pull/101041# that is not yet merged. In this PR, we migrate the file `output.rs`
2022-09-13Don't render inline suggestions of only spacesMichael Goulet-4/+1
2022-09-12Don't trim substitution if it's only whitespaceMichael Goulet-9/+19
2022-09-12A SubstitutionPart is not a deletion if it replaces nothing with nothingMichael Goulet-11/+10
2022-09-10rustc_error, rustc_private, rustc_ast: Switch to stable hash containersNiklas Jonsson-5/+4
2022-09-10translations(rustc_session): migrate output.rsLuis Cardoso-1/+1
2022-09-08Rollup merge of #101545 - TaKO8Ki:remove-unnecessary-partialord-ord, r=oli-obkDylan DPC-1/+1
Remove unnecessary `PartialOrd` and `Ord`
2022-09-08translations(rustc_session): migrates two diagnostics in session.rsLuis Cardoso-1/+4
2022-09-08translations(rustc_session): migrate TargetDataLayout::parseLuis Cardoso-0/+2
2022-09-08remove unnecessary `PartialOrd` and `Ord`Takayuki Maeda-1/+1
2022-09-07Use niche-filling optimization even when multiple variants have data.Michael Benfield-2/+2
Fixes #46213