New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit a warning if a match
is too complex
#122685
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in exhaustiveness checking cc @Nadrieril |
b44b29e
to
48b4105
Compare
Some changes occurred in match checking cc @Nadrieril |
This comment has been minimized.
This comment has been minimized.
48b4105
to
99e670f
Compare
99e670f
to
adbb719
Compare
This comment has been minimized.
This comment has been minimized.
adbb719
to
117a4d2
Compare
This comment has been minimized.
This comment has been minimized.
117a4d2
to
079530a
Compare
// Default value to emit the warning for "too complex" match. We picked it based on | ||
// this crater run: <https://github.com/rust-lang/rust/pull/121979>. | ||
.or(Some(10_000_000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Default value to emit the warning for "too complex" match. We picked it based on | |
// this crater run: <https://github.com/rust-lang/rust/pull/121979>. | |
.or(Some(10_000_000)); | |
// Default value to emit the warning for "too complex" match. We picked it to warn after a second or two. | |
.or(Some(10_000_000)); |
I don't think the crater matters much to future readers of this code, but the timing intent does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you said that limit took more like 20s on your machine? I'd be curious to crater a lower limit then, because I'm afraid people won't wait 20s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me!
Beautiful :D One last remark |
Dear T-lang, this PR adds a warning that cannot be silenced, triggered when a match takes a really long time to analyze (in the order of seconds). This is to help users figure out what's taking so long and fix it. We could make the limit configurable or the warning We're still figuring out the exact limit, but does the team approve in principle? |
079530a
to
2826060
Compare
2826060
to
d1c20e2
Compare
Updated! |
…r when complexity reaches 10_000_000
d1c20e2
to
045f417
Compare
Fixed typo. |
Those interested in pushing the limits of exhaustiveness checking may be interested in: |
Based on the results of crater run from #121979, we can safely set this limit without introducing regressions in the current rust ecosystem.
Follow-up of #121917.
r? @Nadrieril