Improve MIR match generation so that we more effecitvely rule out inapplicable match-pairs
Once we perform a test -- such as checking a value or a variant -- we then weed out the matches that are invalidated by this test. The current code is no as smart as it could be: for example, if we test and find that a value equals 'c', we ought to be able to rule out that the character also equals 'd'. But, because the test tells us nothing if we find that the character is NOT equal to 'c', we take the simple path right now and say that an equality test against 'c' and an equality test against 'd' are completely orthogonal from one another. Similar limitations exist for range tests, slice length tests, etc. We should do better!
Once we perform a test -- such as checking a value or a variant -- we then weed out the matches that are invalidated by this test. The current code is no as smart as it could be: for example, if we test and find that a value equals 'c', we ought to be able to rule out that the character also equals 'd'. But, because the test tells us nothing if we find that the character is NOT equal to 'c', we take the simple path right now and say that an equality test against 'c' and an equality test against 'd' are completely orthogonal from one another. Similar limitations exist for range tests, slice length tests, etc. We should do better!
<!-- TRIAGEBOT_START --> <!-- TRIAGEBOT_ASSIGN_START --> <!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"xacrimon"}$$TRIAGEBOT_ASSIGN_DATA_END --> <!-- TRIAGEBOT_ASSIGN_END --> <!-- TRIAGEBOT_END -->rustbot at 2025-02-01 01:51:46
There are FIXMEs in the code related to this issue.
Niko Matsakis at 2015-11-05 16:56:24
How hard is this to work on? Where are the FIXMEs / how can I grep for them? What would be improved by doing this better?
Jacob Finkelman at 2016-08-04 15:02:45
@Eh2406 The code is mainly located in
librustc_mir::build::matchesGrepping for
FIXME(#29623)in that module finds 3 lines with more info.Jonas Schievink at 2016-08-04 19:27:47
Triage: FIXMEs are still there, so I assume this is still an issue.
Steve Klabnik at 2017-09-30 16:09:47
@rustbot claim
Joel Wejdenstål at 2025-02-01 01:51:44
Started up work on this a few days ago while investigating another more severe issue with match MIR generation after noticing a weird perf hole. Taking this for now since my work should resolve both. Should have a draft PR to track progress soon.
Here's an example of the original problem. I'm not aware of any issues for it yet but will open one.
Joel Wejdenstål at 2025-02-01 01:55:06