granite-rust/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns
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
..
rfc1445 [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
allow-use-behind-cousin-variant.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cant-hide-behind-direct-struct-embedded.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-direct-struct-embedded.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-direct-struct-param.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-direct-struct-param.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-doubly-indirect-embedded.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-doubly-indirect-embedded.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-doubly-indirect-param.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-doubly-indirect-param.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-indirect-struct-embedded.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-indirect-struct-embedded.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-indirect-struct-param.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
cant-hide-behind-indirect-struct-param.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
feature-gate.no_gate.stderr use backticks instead of single quotes when reporting "use of unstable library feature" 2024-11-03 13:55:52 -08:00
feature-gate.rs use backticks instead of single quotes when reporting "use of unstable library feature" 2024-11-03 13:55:52 -08:00
feature-gate.with_gate.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
fn-ptr-is-not-structurally-matchable.rs turn pointer_structural_match into a hard error 2024-05-03 15:56:59 +02:00
fn-ptr-is-not-structurally-matchable.stderr Tweak ptr in pattern error 2024-12-04 20:29:36 +00:00
issue-6804-nan-match.rs const_to_pat: cleanup leftovers from when we had to deal with non-structural constants 2024-07-18 11:58:16 +02:00
issue-6804-nan-match.stderr Tweak output of some const pattern errors 2024-12-04 20:29:36 +00:00
issue-61188-match-slice-forbidden-without-eq.rs Reword message for non-structural type constant in pattern 2024-12-04 20:29:36 +00:00
issue-61188-match-slice-forbidden-without-eq.stderr Add more context to fall-through "const pattern of non-structural type" error 2024-12-04 20:29:36 +00:00
issue-62307-match-ref-ref-forbidden-without-eq.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
issue-62307-match-ref-ref-forbidden-without-eq.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
issue-63479-match-fnptr.rs turn pointer_structural_match into a hard error 2024-05-03 15:56:59 +02:00
issue-63479-match-fnptr.stderr Tweak ptr in pattern error 2024-12-04 20:29:36 +00:00
match-empty-array-allowed-without-eq-issue-62336.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
match-requires-both-partialeq-and-eq.rs Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
match-requires-both-partialeq-and-eq.stderr Add additional context for non-sructural type constant used in pattern 2024-12-04 20:29:36 +00:00
phantom-data-is-structurally-matchable.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00