Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
14e59bb317c3c901bce83deb16ee9bfa5cc90e28
rust/tests/ui/consts/const-eval/infinite_loop.rs

13 lines
398 B
Rust
Raw Normal View History

Add a UI test for #50637 This test relies on the fact that restrictions on expressions in `const fn` do not apply when computing array lengths. It is more difficult to statically analyze than the simple `loop{}` mentioned in #50637. This test should be updated to ignore the warning after #49980 is resolved.
2018-06-24 13:53:27 -07:00
fn main() {
// Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
// The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
let _ = [(); {
Shorten error message and add link to test Implements @bjorn3's suggestions.
2018-06-29 13:32:54 -07:00
let mut n = 113383; // #20 in https://oeis.org/A006884
rustc_mir: follow FalseUnwind's real_target edge in qualify_consts.
2019-07-01 19:26:36 +03:00
while n != 0 {
Remove const eval limit and implement an exponential backoff lint instead
2022-11-02 11:57:40 +00:00
//~^ ERROR is taking a long time
n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
Add a UI test for #50637 This test relies on the fact that restrictions on expressions in `const fn` do not apply when computing array lengths. It is more difficult to statically analyze than the simple `loop{}` mentioned in #50637. This test should be updated to ignore the warning after #49980 is resolved.
2018-06-24 13:53:27 -07:00
}
n
}];
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 2154ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API