]> git.lizzy.rs Git - rust.git/commitdiff
Make the `structural_match` error diagnostic for const generics clearer
authorvarkor <github@varkor.com>
Mon, 6 Apr 2020 14:12:52 +0000 (15:12 +0100)
committervarkor <github@varkor.com>
Mon, 20 Apr 2020 11:46:27 +0000 (12:46 +0100)
src/librustc_typeck/collect/type_of.rs
src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.rs
src/test/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr
src/test/ui/const-generics/const-param-type-depends-on-type-param.rs
src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr
src/test/ui/const-generics/forbid-non-structural_match-types.rs
src/test/ui/const-generics/forbid-non-structural_match-types.stderr

index e17b736058f0267d9bf1f276181b323944fd05b7..ddf0b247ae3a39ca10ca3d4cfb938dfccc136c9d 100644 (file)
@@ -346,7 +346,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
                         tcx.sess,
                         hir_ty.span,
                         E0741,
-                        "the types of const generic parameters must derive `PartialEq` and `Eq`",
+                        "`{}` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the \
+                         type of a const parameter",
+                        ty,
                     )
                     .span_label(
                         hir_ty.span,
index 78bd549ba791a456739aa62a60d2462aa4d8082f..59bb06690a1c91b6735dc582dc09cd0e36e4ce1d 100644 (file)
@@ -1,6 +1,6 @@
 use std::marker::PhantomData;
 
 struct B<T, const N: T>(PhantomData<[T; N]>); //~ ERROR const generics are unstable
-//~^ ERROR the types of const generic parameters must derive `PartialEq` and `Eq`
+//~^ ERROR `T` must be annotated with `#[derive(PartialEq, Eq)]`
 
 fn main() {}
index 14ade3f33fd9b888ddbde182644af76374921b84..70f9fc4184c2c6ebe54bfb13b90b87ea9d579ca9 100644 (file)
@@ -7,7 +7,7 @@ LL | struct B<T, const N: T>(PhantomData<[T; N]>);
    = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
    = help: add `#![feature(const_generics)]` to the crate attributes to enable
 
-error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq`
+error[E0741]: `T` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
   --> $DIR/const-param-type-depends-on-type-param-ungated.rs:3:22
    |
 LL | struct B<T, const N: T>(PhantomData<[T; N]>);
index 684ccf71082c28ea996ef662d24423e03889ba30..4dcda3b87a8545424c1b2058728850ca8ebd279e 100644 (file)
@@ -7,6 +7,6 @@
 // details.
 
 pub struct Dependent<T, const X: T>([(); X]);
-//~^ ERROR the types of const generic parameters must derive `PartialEq` and `Eq`
+//~^ ERROR `T` must be annotated with `#[derive(PartialEq, Eq)]`
 
 fn main() {}
index 724e3909e458fd76dd803037236308ed4e242f1b..290d53c4e1971402937182324570a920c538bbef 100644 (file)
@@ -6,7 +6,7 @@ LL | #![feature(const_generics)]
    |
    = note: `#[warn(incomplete_features)]` on by default
 
-error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq`
+error[E0741]: `T` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
   --> $DIR/const-param-type-depends-on-type-param.rs:9:34
    |
 LL | pub struct Dependent<T, const X: T>([(); X]);
index 7bc4f3986eb754ba7160739f6dadc49142f7282b..a30cdc3efdf436c92d6387905c67bb182c83b222 100644 (file)
@@ -8,6 +8,6 @@
 
 struct C;
 
-struct D<const X: C>; //~ ERROR the types of const generic parameters must derive
+struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]`
 
 fn main() {}
index d2469ca766ec7c89b230820f1fe128e660e0cf37..4f343146263ba1b115d51b6e85a9e0e0de5de4ec 100644 (file)
@@ -6,7 +6,7 @@ LL | #![feature(const_generics)]
    |
    = note: `#[warn(incomplete_features)]` on by default
 
-error[E0741]: the types of const generic parameters must derive `PartialEq` and `Eq`
+error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
   --> $DIR/forbid-non-structural_match-types.rs:11:19
    |
 LL | struct D<const X: C>;