Open Nadrieril opened 3 years ago
It is actionable, we have working match checking already, it's just not shared with rustc yet. (This is a bit more complicated than match checking though, I think, since match checking only takes into account the discriminant's type, not its actual value.)
This should probably even be a (hint) diagnostic.
You do have match checking, but afaik it's copy-pasted from the rustc code so you're not going to modify it, right? Or do you also have your own implementation?
Our implementation is mainly copied from rustc yes, see https://github.com/rust-analyzer/rust-analyzer/pull/8717 that updated the implementation.
Oh I see, you are essentially maintaining some patches over it, so the feature would be doable. Cool!
FYI I'm moving stuff around quite a bit on the rustc side of this. I hope to move the core of the logic to a separate crate in the not-too-far future. So you may want to wait.
Now that we've librarified match checking, would anyone be keen to work on this? I can help with the pattern logic, I'd just rather not have to learn the rust-analyzer side of things :angel:
When I'm refactoring and inlining stuff all over the place, I often end up with cases like this:
I would love an assist that keeps only the
Some
branches and simplifies this toIt would also make sense for
if let
s and even plainif
s.I realize this is unlikely to be actionable until match checking is librarified, but that's not too far in the future hopefully.