about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-09Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxuMatthias Krüger-1/+0
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-07Rollup merge of #138111 - estebank:use-dfv, r=nnethercoteMatthias Krüger-0/+1
Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType` Wanted to see where `#![feature(default_field_values)]` could be used in the codebase. These three seemed like no-brainers. There are a bunch of more places where we could remove manual `Default` impls, but they `derive` other traits that rely on `syn`, which [doesn't yet support `default_field_values`](https://github.com/dtolnay/syn/issues/1774).
2025-03-06Rollup merge of #137303 - compiler-errors:maybe-forgor, r=cjgillotMichael Goulet-1/+0
Remove `MaybeForgetReturn` suggestion #115196 implemented a suggestion to add a missing `return` when there is an ambiguity error, when that ambiguity error could be constrained by the return type of the function. I initially reviewed it and thought it could be useful; however, looking back at that code now, I feel like it's a bit too much of a hack to be worth keeping around in typeck, especially given how rare it's expected to fire in practice. This is especially true because it depends on `StashKey::MaybeForgetReturn`, which is only stashed when we have *Sized* obligation ambiguity errors. Let's remove it for now. I'd like to note that it's basically impossible to get this suggestion to apply in its current state except for what I'd consider somewhat artificial examples, involving no generic trait bounds. For example, it's not triggered for: ```rust struct W<T>(T); fn bar<T: Default>() -> W<T> { todo!() } fn foo() -> W<i32> { if true { bar(); } W(0) } ``` Nor is it triggered for: ``` fn foo() -> i32 { if true { Default::default(); } 0 } ``` It's basically only triggered iff there's only one ambiguity error on the type, which is `Sized`. Generally, suggesting something that affects control flow is a pretty dramatic suggestion; therefore, both the accuracy and precision of this diagnostic should be pretty high. One other, somewhat unrelated observation is that this might be using stashed diagnostics incorrectly (or at least unnecessarily). Stashed diagnostics are used when error detection is fragmented over several major stages of the compiler, like a parse or resolver error which later can be recovered in typeck. However, this one is a bit different since it is fully handled within typeck -- perhaps that suggests that if this were to be reimplemented, it wouldn't need to be so complicated of an implementation.
2025-03-03Use default field values in `markdown::parse::Context`Esteban Küber-0/+1
2025-02-23stabilize extract_ifbendn-1/+0
2025-02-22Remove MaybeForgetReturn suggestionMichael Goulet-1/+0
2025-02-21Trim suggestion part before generating highlightsMichael Goulet-1/+6
2025-02-21More sophisticated span trimmingMichael Goulet-11/+34
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-1/+2
with rust-analyzer
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-0/+18
2025-02-14Consider add-prefix replacements tooMichael Goulet-3/+4
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-0/+11
2025-02-06Avoid manually producing FatalError in a couple of placesbjorn3-2/+2
2025-02-02Rollup merge of #136445 - bjorn3:diag_ctxt_cleanup, r=oli-obkMatthias Krüger-33/+20
Couple of cleanups to DiagCtxt and EarlyDiagCtxt
2025-02-02Replace ParseSess::set_dcx with DiagCtxt::set_emitterbjorn3-0/+4
Replacing the error emitter doesn't accidentally clear the error count.
2025-02-02Use fallback fluent bundle from inner emitter in SilentEmitterbjorn3-7/+1
2025-02-02Slightly simplify DiagCtxt::make_silentbjorn3-27/+16
2025-01-31Make comma separated lists of anything easier to make for errorsEsteban Küber-13/+1
Provide a new function `listify`, meant to be used in cases similar to `pluralize!`. When you have a slice of arbitrary elements that need to be presented to the user, `listify` allows you to turn that into a list of comma separated strings. This reduces a lot of redundant logic that happens often in diagnostics.
2025-01-19Manual cleanup of some `is_{or_none|some_and}` usagesYotam Ofek-1/+2
2025-01-19Run `clippy --fix` for `unnecessary_map_or` lintYotam Ofek-1/+1
2025-01-11Remove a bunch of diagnostic stashing that doesn't do anythingMichael Goulet-2/+0
2024-12-16update uses of extract_if in the compilerThe 8472-4/+4
2024-12-12Rollup merge of #134187 - nnethercote:rm-PErr, r=jieyouxuMatthias Krüger-2/+1
Remove `PErr`. It's just a synonym for `Diag` that adds no value and is only used in a few places. r? ``@spastorino``
2024-12-12Rollup merge of #134154 - dev-ardi:field-expr-generics, r=compiler-errorsMatthias Krüger-0/+4
suppress field expr with generics error message if it's a method Don't emit "field expressions may not have generic arguments" if it's a method call without `()` r? estebank Fixes #67680 Is this the best way to go? It's by far the simplest I could come up with.
2024-12-12Remove `PErr`.Nicholas Nethercote-2/+1
It's just a synonym for `Diag` that adds no value and is only used in a few places.
2024-12-11Don't emit "field expressions may not have generic arguments" if it's a ↵Orion Gonzalez-0/+4
method call without ()
2024-12-11document check_expr_fieldOrion Gonzalez-1/+1
2024-12-06Handle unwinding out of the closure argument of run_compiler with pending ↵bjorn3-3/+7
delayed bugs
2024-12-06Store a single copy of the error registry in DiagCtxtbjorn3-7/+17
And pass this to the individual emitters when necessary.
2024-11-12clarify `must_produce_diag` ICE for debuggingRémy Rakic-3/+16
2024-10-07Rollup merge of #131344 - nnethercote:ref-Lrc, r=compiler-errorsMatthias Krüger-3/+3
Avoid `&Lrc<T>` in various places Seeing `&Lrc<T>` is a bit suspicious, and `&T` or `Lrc<T>` is often better. r? `@oli-obk`
2024-10-07Convert `Option<&Lrc<T>>` return types to `Option<&T>`.Nicholas Nethercote-3/+3
It's simpler and more concise.
2024-10-07Remove `InferCtxt::err_count_on_creation`.Nicholas Nethercote-12/+0
It's no longer used meaningfully. This also means `DiagCtxtHandle::err_count_excluding_lint_errs` can be removed.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-8/+8
2024-09-18Add suggestions for expressions in patternsLieselotte-0/+2
2024-09-12Implement a Method to Seal `DiagInner`'s SuggestionsVeera-0/+35
2024-09-07Do not ICE on expect(warnings).Camille GILLOT-12/+5
2024-09-06Check AttrId for expectations.Camille GILLOT-86/+15
2024-09-02Rollup merge of #129875 - Sajjon:sajjon_fix_typos_batch_1, ↵Matthias Krüger-1/+1
r=compiler-errors,jieyouxu chore: Fix typos in 'compiler' (batch 1) Batch 1/3: Fixes typos in `compiler` (See [issue](https://github.com/rust-lang/rust/issues/129874) tracking all PRs with typos fixes)
2024-09-02chore: Fix typos in 'compiler' (batch 1)Alexander Cyon-1/+1
2024-08-31Remove attr_id from stable lint ids.Camille GILLOT-1/+1
2024-08-31Use AttrId key for unstable<->stable expectation map.Camille GILLOT-5/+5
2024-08-27Add `warn(unreachable_pub)` to `rustc_errors`.Nicholas Nethercote-2/+3
2024-08-14Add `|` to make the html doc of `Level` rendered correctlyJaic1-16/+16
2024-08-12Rollup merge of #128978 - compiler-errors:assert-matches, r=jieyouxuGuillaume Gomez-1/+3
Use `assert_matches` around the compiler more It's a useful assertion, especially since it actually prints out the LHS.
2024-08-11Use assert_matches around the compilerMichael Goulet-1/+3
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-5/+5