Make our pattern matching logic undestand &[T] constants#70699
Make our pattern matching logic undestand &[T] constants#70699oli-obk wants to merge 3 commits intorust-lang:masterfrom
&[T] constants#70699Conversation
|
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.
Was this comment incorrect before?
There was a problem hiding this comment.
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 <github@varkor.com>
| (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.
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.