-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add new pattern_complexity
attribute to add possibility to limit and check recursion in pattern matching
#121917
Add new pattern_complexity
attribute to add possibility to limit and check recursion in pattern matching
#121917
Conversation
Some changes occurred in match checking cc @Nadrieril Some changes occurred in exhaustiveness checking cc @Nadrieril |
22ae31c
to
f759c8b
Compare
This comment has been minimized.
This comment has been minimized.
f759c8b
to
77f924d
Compare
This comment has been minimized.
This comment has been minimized.
Could you add a test that ensures the new attribute is internal-only? Like we do for feature gates: #![pattern_complexity = "60"]
//~^ ERROR: internal attribute
fn main() {} |
77f924d
to
84cda42
Compare
This comment has been minimized.
This comment has been minimized.
c962905
to
dd1c55b
Compare
CI caught this one but good catch! ;) |
This comment has been minimized.
This comment has been minimized.
c151ec2
to
0216123
Compare
This comment has been minimized.
This comment has been minimized.
9ef241b
to
1e10212
Compare
.map(|complexity_limit| complexity_limit < self.complexity_level) | ||
.unwrap_or(false) |
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.
.map(|complexity_limit| complexity_limit < self.complexity_level) | |
.unwrap_or(false) | |
.is_some_and(|complexity_limit| complexity_limit < self.complexity_level) |
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.
I'll make a new clippy lint for this if it doesn't exist. :o
Amazing, thank you! r=me with or without the last suggestion |
1e10212
to
f04c5c5
Compare
@bors r=Nadrieril rollup |
…llaumeGomez Rollup of 3 pull requests Successful merges: - rust-lang#121917 (Add new `pattern_complexity` attribute to add possibility to limit and check recursion in pattern matching) - rust-lang#121933 (Add missing get_name for wasm::thread.) - rust-lang#121934 (rustc_log: expose tracing-tree "wraparound" in an env var) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#121917 - GuillaumeGomez:pattern-complexity_limit.rs, r=Nadrieril Add new `pattern_complexity` attribute to add possibility to limit and check recursion in pattern matching Needed for rust-lang/rust-analyzer#9528. This PR adds a new attribute only available when running rust testsuite called `pattern_complexity` which allows to set the maximum recursion for the pattern matching. It is quite useful to ensure the complexity doesn't grow, like in `tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs`. r? `@Nadrieril`
Needed for rust-lang/rust-analyzer#9528.
This PR adds a new attribute only available when running rust testsuite called
pattern_complexity
which allows to set the maximum recursion for the pattern matching. It is quite useful to ensure the complexity doesn't grow, like intests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs
.r? @Nadrieril