Fix exhaustiveness checking of strings#78553
Conversation
|
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
|
After a good night's sleep I found a way of solving the issue that involves fewer footguns. I feel a bit more confident about my solution now. |
|
@varkor it's ready to go |
Before rust-lang#78430, string literals worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. Since then, string literals are special cased and a bit hacky. I did not anticipate patterns for the `&str` type other than string literals, hence this bug. This makes string literals less hacky.
It is now unneeded, since we handle `&str` patterns in a consistent way.
|
@bors r+ |
|
📌 Commit 1bdcd02 has been approved by |
|
☀️ Test successful - checks-actions |
|
A fairly large improvement on perf, up to 10% on instructions and this is reflected with a roughly 3% win on wall times. Good work. |
|
Thanks! I was not expecting a perf gain from this one ^^. |
Before #78430, the code worked because
specialize_constructordidn't actually care too much which constructor was passed to it unless needed. That PR however handles&stras a special case, and I did not anticipate patterns for the&strtype other than string literals.I am not very confident there are not other similar oversights left, but hopefully only
&strwas different enough to break my assumptions.Fixes #78549