about summary refs log tree commit diff
path: root/compiler/rustc_errors
AgeCommit message (Collapse)AuthorLines
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-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
2022-09-06Report number of delayed bugs properly with -Ztreat-err-as-bugMichael Goulet-17/+22
2022-09-03Rollup merge of #100928 - CleanCut:rustc_metadata_diagnostics, r=davidtwcoDylan DPC-2/+10
Migrate rustc_metadata to SessionDiagnostics Migrate rustc_metadata to SessionDiagnostics. Part of https://github.com/rust-lang/rust/issues/100717
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-2/+0
by module
2022-08-31Rollup merge of #101165 - ldm0:drain_to_iter, r=cjgillotMatthias Krüger-3/+3
Use more `into_iter` rather than `drain(..)` Clearer semantic.
2022-08-31respond to review feedback: mainly eliminate as many conversions as possible...Nathan Stocks-2/+10
- ... when creating diagnostics in rustc_metadata - use the error_code! macro - pass macro output to diag.code() - use fluent from within manual implementation of SessionDiagnostic - emit the untested errors in case they occur in the wild - stop panicking in the probably-not-dead code, add fixme to write test
2022-08-31Rollup merge of #101100 - compiler-errors:generalize-call-suggestions, ↵Matthias Krüger-4/+15
r=petrochenkov Make call suggestions more general and more accurate Cleans up some suggestions that have to do with adding `()` to make typeck happy. 1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr` 1. Autoderef until we get to a callable type in `suggest_fn_call`. 1. Don't erroneously suggest calling constructor when a method/field does not exist on it. 1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`) 1. Extend call suggestions to type parameters, fn pointers, trait objects where possible 1. Suggest calling in operators too (fixes #101054) 1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
2022-08-31Rollup merge of #100970 - Xiretza:derive-multipart-suggestion, r=davidtwcoMatthias Krüger-12/+5
Allow deriving multipart suggestions This turned into a bit more of a rewrite than I was initially hoping for... Still, I think the `SessionSubdiagnostic` derive is a little cleaner overall now, and closer to the `SessionDiagnostic` derive to make future code sharing easier. r? ``@davidtwco``
2022-08-30Code deduplication in tool_only_multipart_suggestionXiretza-12/+5
2022-08-30Use more `into_iter` rather than `drain(..)`Donough Liu-3/+3
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.