diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-09 05:29:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-09 05:29:40 +0200 |
| commit | a209b4f447b528362354edfd78aa96349633dc17 (patch) | |
| tree | 509e31e4c92762c090aa0742e1607cd57fe00512 /src/test | |
| parent | ba50bc588e36a06a7b42970366534946beea5ce9 (diff) | |
| parent | b8f416d67ff77d6eb71902895b59abbfb50737db (diff) | |
| download | rust-a209b4f447b528362354edfd78aa96349633dc17.tar.gz rust-a209b4f447b528362354edfd78aa96349633dc17.zip | |
Rollup merge of #70822 - jonas-schievink:curse-of-the-recursion, r=ecstatic-morse
Don't lint for self-recursion when the function can diverge Fixes https://github.com/rust-lang/rust/issues/54444
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/lint/lint-unconditional-recursion.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/lint/lint-unconditional-recursion.rs b/src/test/ui/lint/lint-unconditional-recursion.rs index ab60a326cd2..d2a0329585b 100644 --- a/src/test/ui/lint/lint-unconditional-recursion.rs +++ b/src/test/ui/lint/lint-unconditional-recursion.rs @@ -131,4 +131,22 @@ trait Bar { } } +// Do not trigger on functions that may diverge instead of self-recursing (#54444) + +pub fn loops(x: bool) { + if x { + loops(x); + } else { + loop {} + } +} + +pub fn panics(x: bool) { + if x { + panics(!x); + } else { + panic!("panics"); + } +} + fn main() {} |
