-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the structural_match
error diagnostic for const generics clearer
#70845
Make the structural_match
error diagnostic for const generics clearer
#70845
Conversation
Ping from triage: @estebank could you review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this fell through the cracks of my notifications.
It looks good. Left a nitpick, but r=me if you don't wish to fix it.
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]>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice if we could detect that T
is a type param and instead of suggesting the annotation we suggested binding it with PartialEq + Eq
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, actually we ought to emit a specific error for this case: we don't currently accept using generic parameters as the types of const generics yet.
1e51940
to
f8b796b
Compare
@estebank: I've added a specific message for the case you highlighted. |
@bors r+ rollup |
📌 Commit f8b796b has been approved by |
…gnostic, r=estebank Make the `structural_match` error diagnostic for const generics clearer The previous diagnostic caused confusion (rust-lang#70790), so this changes the message to be closer to the message for using non-`structural_match` constants in patterns, explicitly mentioning `#[derive(PartialEq, Eq)]`. Fixes rust-lang#70790. r? @estebank
Rollup of 6 pull requests Successful merges: - rust-lang#70845 (Make the `structural_match` error diagnostic for const generics clearer) - rust-lang#71063 (Document unsafety in core::{option, hash}) - rust-lang#71068 (Stabilize UNICODE_VERSION (feature unicode_version)) - rust-lang#71426 (fix error code in E0751.md) - rust-lang#71459 (Add leading 0x to offset in Debug fmt of Pointer) - rust-lang#71492 (Document unsafety in core::{panicking, alloc::layout, hint, iter::adapters::zip}) Failed merges: r? @ghost
The previous diagnostic caused confusion (#70790), so this changes the message to be closer to the message for using non-
structural_match
constants in patterns, explicitly mentioning#[derive(PartialEq, Eq)]
.Fixes #70790.
r? @estebank