3

Add fuel to match checking by Nadrieril · Pull Request #16879 · rust-lang/rust-...

 4 weeks ago
source link: https://github.com/rust-lang/rust-analyzer/pull/16879
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Conversation

Contributor

Exhaustiveness checking is NP-hard hence can take extremely long to check some specific matches. This PR makes ehxaustiveness bail after a set number of steps. I chose a bound that takes ~100ms on my machine, which should be more than enough for normal matches.

I'd like someone with less recent hardware to run the test to see if that limit is low enough for them. Also curious if the r-a team thinks this is a good ballpark or if we should go lower/higher. I don't have much data on how complex real-life matches get, but we can definitely go lower than 500 000 steps.

The second commit is a drive-by soundness fix which doesn't matter much today but will matter once min_exhaustive_patterns is stabilized.

Fixes #9528 cc @matklad

matklad and Veykril reacted with heart emojimatklad reacted with rocket emoji

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK