about summary refs log tree commit diff
path: root/tests/coverage/branch/lazy-boolean.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2024-11-20 23:10:39 +0000
committerEsteban Küber <esteban@kuber.com.ar>2024-12-04 20:29:36 +0000
commitd136b3108def7af6d43229ba704ab21778f55125 (patch)
tree50d7b9d4005724bdd53ec1f9df9716ee1a8f231a /tests/coverage/branch/lazy-boolean.rs
parent27a1880593a057da01373c4cdafbbed3d34d650f (diff)
downloadrust-d136b3108def7af6d43229ba704ab21778f55125.tar.gz
rust-d136b3108def7af6d43229ba704ab21778f55125.zip
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
```
Diffstat (limited to 'tests/coverage/branch/lazy-boolean.rs')
0 files changed, 0 insertions, 0 deletions