diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-11-20 23:10:39 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-12-04 20:29:36 +0000 |
| commit | d136b3108def7af6d43229ba704ab21778f55125 (patch) | |
| tree | 50d7b9d4005724bdd53ec1f9df9716ee1a8f231a /compiler/rustc_mir_build/src/errors.rs | |
| parent | 27a1880593a057da01373c4cdafbbed3d34d650f (diff) | |
| download | rust-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 'compiler/rustc_mir_build/src/errors.rs')
| -rw-r--r-- | compiler/rustc_mir_build/src/errors.rs | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index 49e18891fca..3632da943e1 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -897,7 +897,6 @@ pub(crate) struct TypeNotStructural<'tcx> { #[derive(Diagnostic)] #[diag(mir_build_non_partial_eq_match)] -#[note(mir_build_type_not_structural_def)] #[note(mir_build_type_not_structural_more_info)] pub(crate) struct TypeNotPartialEq<'tcx> { #[primary_span] |
