about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src/errors.rs
AgeCommit message (Collapse)AuthorLines
2025-05-06error early when mixing deref patterns with normal constructorsdianne-1/+13
Without adding proper support for mixed exhaustiveness, mixing deref patterns with normal constructors would either violate `ConstructorSet::split`'s invariant 4 or 7. We'd either be ignoring rows with normal constructors or we'd have problems in unspecialization from non-disjoint constructors. Checking mixed exhaustivenss similarly to how unions are currently checked should work, but the diagnostics for unions are confusing. Since mixing deref patterns with normal constructors is pretty niche (currently it only makes sense for `Cow`), emitting an error lets us avoid committing to supporting mixed exhaustiveness without a good answer for the diagnostics.
2025-04-16Move eager translation to a method on `Diag`Jake Goulding-11/+3
This will allow us to eagerly translate messages on a top-level diagnostic, such as a `LintDiagnostic`. As a bonus, we can remove the awkward closure passed into Subdiagnostic and make better use of `Into`.
2024-07-29Encapsulate the printing of `WitnessPat`Zalathar-9/+3
This hides the fact that we print `WitnessPat` by converting it to `thir::Pat` and then printing that.
2024-07-28Don't store `thir::Pat` in error structsZalathar-27/+26
In several cases this avoids the need to clone the underlying pattern, and then print the clone later.
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-2/+2
2024-03-13Rename `RustcMatchCheckCtxt` -> `RustcPatCtxt`Nadrieril-2/+2
2024-03-11Rename `AddToDiagnostic` as `Subdiagnostic`.Nicholas Nethercote-5/+5
To match `derive(Subdiagnostic)`. Also rename `add_to_diagnostic{,_with}` as `add_to_diag{,_with}`.
2024-03-09Lint small gaps between rangesNadrieril-0/+51
2024-03-05Rename `SubdiagnosticMessageOp` as `SubdiagMessageOp`.Nicholas Nethercote-2/+2
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-2/+2
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-20Reduce capabilities of `Diagnostic`.Nicholas Nethercote-2/+6
Currently many diagnostic modifier methods are available on both `Diagnostic` and `DiagnosticBuilder`. This commit removes most of them from `Diagnostic`. To minimize the diff size, it keeps them within `diagnostic.rs` but changes the surrounding `impl Diagnostic` block to `impl DiagnosticBuilder`. (I intend to move things around later, to give a more sensible code layout.) `Diagnostic` keeps a few methods that it still needs, like `sub`, `arg`, and `replace_args`. The `forward!` macro, which defined two additional methods per call (e.g. `note` and `with_note`), is replaced by the `with_fn!` macro, which defines one additional method per call (e.g. `with_note`). It's now also only used when necessary -- not all modifier methods currently need a `with_*` form. (New ones can be easily added as necessary.) All this also requires changing `trait AddToDiagnostic` so its methods take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`. There are three subdiagnostics -- `DelayedAtWithoutNewline`, `DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` -- that are created within the diagnostics machinery and appended to external diagnostics. These are handled at the `Diagnostic` level, which means it's now hard to construct them via `derive(Diagnostic)`, so instead we construct them by hand. This has no effect on what they look like when printed. There are lots of new `allow` markers for `untranslatable_diagnostics` and `diagnostics_outside_of_impl`. This is because `#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic` modifier methods, but missing from the `DiagnosticBuilder` modifier methods. They're now present.
2024-02-08Rollup merge of #120734 - nnethercote:SubdiagnosticMessageOp, r=compiler-errorsMatthias Krüger-5/+2
Add `SubdiagnosticMessageOp` as a trait alias. It avoids a lot of repetition. r? matthewjasper
2024-02-08Add `SubdiagnosticMessageOp` as a trait alias.Nicholas Nethercote-5/+2
It avoids a lot of repetition.
2024-01-31Remove `pattern_arena` from `RustcMatchCheckCtxt`Nadrieril-1/+4
2023-12-15s/RustcCtxt/RustcMatchCheckCtxt/Nadrieril-2/+2
2023-12-15Name rustc-specific things "rustc"Nadrieril-2/+2
2023-12-15Abstract `MatchCheckCtxt` into a traitNadrieril-3/+3
2023-12-11Gather rustc-specific functions around `MatchCheckCtxt`Nadrieril-4/+4
2023-12-11Extract exhaustiveness into its own crateNadrieril-0/+95