From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/consts/const-eval/infinite_loop.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/test/ui/consts/const-eval/infinite_loop.rs (limited to 'src/test/ui/consts/const-eval/infinite_loop.rs') diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs new file mode 100644 index 000000000..14a573ccf --- /dev/null +++ b/src/test/ui/consts/const-eval/infinite_loop.rs @@ -0,0 +1,12 @@ +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 _ = [(); { + let mut n = 113383; // #20 in https://oeis.org/A006884 + while n != 0 { + n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; + //~^ ERROR evaluation of constant value failed + } + n + }]; +} -- cgit v1.2.3