-
Notifications
You must be signed in to change notification settings - Fork 13k
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 our pattern matching logic undestand &[T]
constants
#70699
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
// Deref of a reference to a ZST is a nop. | ||
ConstValue::Scalar(Scalar::zst()) | ||
} else { | ||
// FIXME(oli-obk): this is reachable for `const FOO: &&&u32 = &&&42;` |
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.
Was this comment incorrect before?
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.
apparently, we have a test for this, but the ICE is a different one somewhere in the middle of pattern matching. I've so far been unable to figure it out.
Co-Authored-By: varkor <[email protected]>
(ConstValue::Scalar(Scalar::Ptr(p)), ty::Array(t, n), ty::Slice(u)) => { | ||
// Unsize array to slice if pattern is array | ||
// but match value or other patterns are slice. | ||
(ConstValue::Scalar(s), ty::Array(t, n), ty::Slice(u)) => { |
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.
Would be good to avoid these one-letter variable names.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I found a rabbit hole and wrote some text about it: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/constants.20in.20patterns/near/192783049 I want to fix this once and for all, instead of the piecemeal thing that I've been doing the last years. |
closing in favour of #70743 |
We should generalize this to other types, too, so treat this as a proof of concept.