-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Ignore unwinding edges when checking for unconditional recursion #92889
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
67a3bdd
to
016bda4
Compare
The unconditional recursion lint determines if all execution paths eventually lead to a self-recursive call. The implementation always follows unwinding edges which limits its practical utility. For example, it would not lint function `f` because a call to `g` might unwind. It also wouldn't lint function `h` because an overflow check preceding the self-recursive call might unwind: ```rust pub fn f() { g(); f(); } pub fn g() { /* ... */ } pub fn h(a: usize) { h(a + 1); } ``` To avoid the issue, assume that terminators that might continue execution along non-unwinding edges do so.
016bda4
to
10b722c
Compare
This seems strictly better while preserving existing behavior for the cases in #54444. There might be an interpretation of "lints have zero false positives" and "unconditional recursion" that would cause people to disagree with this change, but I think that interpretation is too narrow. Thanks tmiasko! @bors r+ rollup |
📌 Commit 10b722c has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (21b4a9c): comparison url. Summary: This benchmark run shows 36 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
The performance regression will be addressed by changes from #93381. @rustbot label: +perf-regression-triaged |
The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.
The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function
f
because acall to
g
might unwind. It also wouldn't lint functionh
because anoverflow check preceding the self-recursive call might unwind:
To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.
Fixes #78474.