Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Oct 5, 2023
1 parent 3fc4180 commit fb0f72d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 60 deletions.

This file was deleted.

3 changes: 1 addition & 2 deletions tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![cfg_attr(warn, warn(long_running_const_eval))]
#![cfg_attr(allow, allow(long_running_const_eval))]

// compile-flags: -Z tiny-const-eval-limit
const fn simple_loop(n: u32) -> u32 {
let mut index = 0;
while index < n {
Expand All @@ -16,7 +15,7 @@ const fn simple_loop(n: u32) -> u32 {
}

const X: u32 = simple_loop(19);
const Y: u32 = simple_loop(35);
const Y: u32 = simple_loop(3000005);

fn main() {
println!("{X}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: constant evaluation is taking a long time
--> $DIR/ctfe-simple-loop.rs:9:5
--> $DIR/ctfe-simple-loop.rs:8:5
|
LL | / while index < n {
LL | |
Expand All @@ -14,49 +14,13 @@ LL | | }
help: the constant being evaluated
--> $DIR/ctfe-simple-loop.rs:18:1
|
LL | const X: u32 = simple_loop(19);
LL | const Y: u32 = simple_loop(3000005);
| ^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/ctfe-simple-loop.rs:3:24
|
LL | #![cfg_attr(warn, warn(long_running_const_eval))]
| ^^^^^^^^^^^^^^^^^^^^^^^

warning: constant evaluation is taking a long time
--> $DIR/ctfe-simple-loop.rs:9:5
|
LL | / while index < n {
LL | |
LL | |
LL | |
LL | | index = index + 1;
LL | | }
| |_____^
|
= note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
--> $DIR/ctfe-simple-loop.rs:19:1
|
LL | const Y: u32 = simple_loop(35);
| ^^^^^^^^^^^^

warning: constant evaluation is taking a long time
--> $DIR/ctfe-simple-loop.rs:9:5
|
LL | / while index < n {
LL | |
LL | |
LL | |
LL | | index = index + 1;
LL | | }
| |_____^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> $DIR/ctfe-simple-loop.rs:19:1
|
LL | const Y: u32 = simple_loop(35);
| ^^^^^^^^^^^^

warning: 3 warnings emitted
warning: 1 warning emitted

0 comments on commit fb0f72d

Please sign in to comment.