rust/tests/ui/consts/const_in_pattern
Esteban Küber d136b3108d Add more context to fall-through "const pattern of non-structural type" error
Point at types that need to be marked with `#[derive(PartialEq)]`.

We use a visitor to look at a type that isn't structural, looking for all ADTs that don't derive `PartialEq`. These can either be manual `impl PartialEq`s or no `impl` at all, so we differentiate between those two cases to provide more context to the user. We also only point at types and impls from the local crate, otherwise show only a note.

```
error: constant of non-structural type `&[B]` in a pattern
  --> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9
   |
LL | struct B(i32);
   | -------- must be annotated with `#[derive(PartialEq)]` to be usable in patterns
LL |
LL | const A: &[B] = &[];
   | ------------- constant defined here
...
LL |         A => (),
   |         ^ constant of non-structural type
   |
   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
```
2024-12-04 20:29:36 +00:00
..
auxiliary Move /src/test to /tests 2023-01-11 09:32:08 +00:00
accept_structural.rs remove IndirectStructuralMatch lint, emit the usual hard error instead 2024-05-03 15:56:59 +02:00
cross-crate-fail.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cross-crate-fail.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cross-crate-pass.rs remove IndirectStructuralMatch lint, emit the usual hard error instead 2024-05-03 15:56:59 +02:00
custom-eq-branch-pass.rs const_to_pat: cleanup leftovers from when we had to deal with non-structural constants 2024-07-18 11:58:16 +02:00
f16-f128-const-reassign.rs Change a fixed crash test to a standard test 2024-06-23 04:28:42 -05:00
incomplete-slice.rs remove StructuralEq trait 2024-01-24 07:56:23 +01:00
incomplete-slice.stderr Unify expanded constants and named constants in PatKind 2024-11-17 23:40:00 +00:00
issue-34784-match-on-non-int-raw-ptr.rs turn pointer_structural_match into a hard error 2024-05-03 15:56:59 +02:00
issue-34784-match-on-non-int-raw-ptr.stderr Tweak ptr in pattern error 2024-12-04 20:29:36 +00:00
issue-44333.rs turn pointer_structural_match into a hard error 2024-05-03 15:56:59 +02:00
issue-44333.stderr Tweak ptr in pattern error 2024-12-04 20:29:36 +00:00
issue-53708.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-62614.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-65466.rs Reword message for non-structural type constant in pattern 2024-12-04 20:29:36 +00:00
issue-65466.stderr Add more context to fall-through "const pattern of non-structural type" error 2024-12-04 20:29:36 +00:00
issue-73431.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
no-eq-branch-fail.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
no-eq-branch-fail.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
null-raw-ptr-issue-119270.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
reject_non_partial_eq.rs Reword message for non-structural type constant in pattern 2024-12-04 20:29:36 +00:00
reject_non_partial_eq.stderr Add more context to fall-through "const pattern of non-structural type" error 2024-12-04 20:29:36 +00:00
reject_non_structural.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
reject_non_structural.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00