-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Surprising diagnostics about using const value in match pattern #92454
Comments
This is because cc @rust-lang/wg-const-eval |
@fee1-dead that's helpful, my intuition was that it had something to do with const stuff. Still, it seems this story is still really hard to explain:
This all seems really weird because apparently |
StructuralEq is kind of a mess currently and something we want to clean up. Also see #74446. |
Okay, but then we should definitely improve diagnostics such that the messiness from an unstable filter leak out into stable Rust via crappy errors (especially as there seems to be no clear/fast path towards stabilization). |
Just took an hour googling to end up here with the same error message. Anything that at least adds a bit more information (eg 'can not be structurally equal' or includes a compiler error number) would be much appreciated. |
The error explicitly says See rust-lang/lang-team#220 for some recent discussion of the subject. The current plan is to keep this a hard error. |
Given the following code (playground:
The current output is:
Surprisingly to me at least, using a custom
PartialEq
implementation still results in the same issue (playground):This seems pretty unclear:
PartialEq
forCow
when I'm comparing matching againstFoo
?PartialEq
instead of having a custom impl?I don't know exactly what kind of contract
match
depends on, but I would have thought any kind ofPartialEq
impl (that is, even non-const) would be enough here.Original issue here: open-telemetry/opentelemetry-rust#685. This also links to a potential fix in sfackler/rust-postgres@05a0643 (involving adding another layer of indirection), but I'd really like to understand why that is even necessary.
(To be clear: the diagnostic is unclear here, but maybe there's an actual compiler problem here, too?)
cc @estebank
The text was updated successfully, but these errors were encountered: