]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/const-eval/infinite_loop.rs
New upstream version 1.32.0~beta.2+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / infinite_loop.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(const_let)]
12
13 fn main() {
14 // Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
15 // The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
16 let _ = [(); {
17 //~^ WARNING Constant evaluating a complex constant, this might take some time
18 let mut n = 113383; // #20 in https://oeis.org/A006884
19 while n != 0 { //~ ERROR constant contains unimplemented expression type
20 n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
21 //~^ ERROR evaluation of constant value failed
22 }
23 n
24 }];
25 }