Skip to content

Commit 527456e

Browse files
committed
Bumped version number for const_eval_limit in active.rs
and renamed 'recursion_limit' in limits.rs to simple 'limit' because it does handle other limits too.
1 parent c94c74e commit 527456e

13 files changed

+47
-25
lines changed

src/librustc/middle/limits.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ fn update_limit(
3838
return;
3939
}
4040
Err(e) => {
41-
let mut err = sess.struct_span_err(
42-
attr.span,
43-
"`recursion_limit` must be a non-negative integer",
44-
);
41+
let mut err =
42+
sess.struct_span_err(attr.span, "`limit` must be a non-negative integer");
4543

4644
let value_span = attr
4745
.meta()
@@ -50,11 +48,11 @@ fn update_limit(
5048
.unwrap_or(attr.span);
5149

5250
let error_str = match e.kind() {
53-
IntErrorKind::Overflow => "`recursion_limit` is too large",
54-
IntErrorKind::Empty => "`recursion_limit` must be a non-negative integer",
51+
IntErrorKind::Overflow => "`limit` is too large",
52+
IntErrorKind::Empty => "`limit` must be a non-negative integer",
5553
IntErrorKind::InvalidDigit => "not a valid integer",
56-
IntErrorKind::Underflow => bug!("`recursion_limit` should never underflow"),
57-
IntErrorKind::Zero => bug!("zero is a valid `recursion_limit`"),
54+
IntErrorKind::Underflow => bug!("`limit` should never underflow"),
55+
IntErrorKind::Zero => bug!("zero is a valid `limit`"),
5856
kind => bug!("unimplemented IntErrorKind variant: {:?}", kind),
5957
};
6058

src/librustc_feature/active.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,6 @@ declare_features! (
532532
/// Allows using `&mut` in constant functions.
533533
(active, const_mut_refs, "1.41.0", Some(57349), None),
534534

535-
// Allows limiting the evaluation steps of const expressions
536-
(active, const_eval_limit, "1.41.0", Some(67217), None),
537-
538535
/// Allows the use of `loop` and `while` in constants.
539536
(active, const_loop, "1.41.0", Some(52000), None),
540537

@@ -555,6 +552,9 @@ declare_features! (
555552
/// Allows the use of `no_sanitize` attribute.
556553
(active, no_sanitize, "1.42.0", Some(39699), None),
557554

555+
// Allows limiting the evaluation steps of const expressions
556+
(active, const_eval_limit, "1.43.0", Some(67217), None),
557+
558558
// -------------------------------------------------------------------------
559559
// feature-group-end: actual feature gates
560560
// -------------------------------------------------------------------------

src/test/ui/consts/const_limit/const_eval_limit_overflow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// check-pass
21
#![feature(const_eval_limit)]
32
#![const_eval_limit="18_446_744_073_709_551_615"]
3+
//~^ ERROR `limit` must be a non-negative integer
44

55
const CONSTANT: usize = limit();
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `limit` must be a non-negative integer
2+
--> $DIR/const_eval_limit_overflow.rs:2:1
3+
|
4+
LL | #![const_eval_limit="18_446_744_073_709_551_615"]
5+
| ^^^^^^^^^^^^^^^^^^^^----------------------------^
6+
| |
7+
| not a valid integer
8+
9+
error: aborting due to previous error
10+

src/test/ui/consts/const_limit/const_eval_limit_reached.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
// ignore-tidy-linelength
12
// only-x86_64
23
// check-pass
4+
// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
5+
// optimize away the const function
6+
// compile-flags:-Copt-level=0
37
#![feature(const_eval_limit)]
48
#![const_eval_limit="2"]
59

@@ -10,7 +14,7 @@ fn main() {
1014
assert_eq!(CONSTANT, 1764);
1115
}
1216

13-
const fn limit() -> usize {
17+
const fn limit() -> usize { //~ WARNING Constant evaluating a complex constant, this might take some time
1418
let x = 42;
1519

1620
x * 42

src/test/ui/consts/const_limit/const_eval_limit_reached.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
warning: Constant evaluating a complex constant, this might take some time
2-
--> $DIR/const_eval_limit_reached.rs:6:1
2+
--> $DIR/const_eval_limit_reached.rs:17:1
3+
|
4+
LL | / const fn limit() -> usize {
5+
LL | | let x = 42;
6+
LL | |
7+
LL | | x * 42
8+
LL | | }
9+
| |_^
10+
11+
warning: Constant evaluating a complex constant, this might take some time
12+
--> $DIR/const_eval_limit_reached.rs:10:1
313
|
414
LL | const CONSTANT: usize = limit();
515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/recursion_limit/empty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test the parse error for an empty recursion_limit
22

3-
#![recursion_limit = ""] //~ ERROR `recursion_limit` must be a non-negative integer
4-
//~| `recursion_limit` must be a non-negative integer
3+
#![recursion_limit = ""] //~ ERROR `limit` must be a non-negative integer
4+
//~| `limit` must be a non-negative integer
55

66
fn main() {}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: `recursion_limit` must be a non-negative integer
1+
error: `limit` must be a non-negative integer
22
--> $DIR/empty.rs:3:1
33
|
44
LL | #![recursion_limit = ""]
55
| ^^^^^^^^^^^^^^^^^^^^^--^
66
| |
7-
| `recursion_limit` must be a non-negative integer
7+
| `limit` must be a non-negative integer
88

99
error: aborting due to previous error
1010

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test the parse error for an invalid digit in recursion_limit
22

3-
#![recursion_limit = "-100"] //~ ERROR `recursion_limit` must be a non-negative integer
3+
#![recursion_limit = "-100"] //~ ERROR `limit` must be a non-negative integer
44
//~| not a valid integer
55

66
fn main() {}

src/test/ui/recursion_limit/invalid_digit.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `recursion_limit` must be a non-negative integer
1+
error: `limit` must be a non-negative integer
22
--> $DIR/invalid_digit.rs:3:1
33
|
44
LL | #![recursion_limit = "-100"]
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Test the parse error for an overflowing recursion_limit
22

33
#![recursion_limit = "999999999999999999999999"]
4-
//~^ ERROR `recursion_limit` must be a non-negative integer
5-
//~| `recursion_limit` is too large
4+
//~^ ERROR `limit` must be a non-negative integer
5+
//~| `limit` is too large
66

77
fn main() {}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: `recursion_limit` must be a non-negative integer
1+
error: `limit` must be a non-negative integer
22
--> $DIR/overflow.rs:3:1
33
|
44
LL | #![recursion_limit = "999999999999999999999999"]
55
| ^^^^^^^^^^^^^^^^^^^^^--------------------------^
66
| |
7-
| `recursion_limit` is too large
7+
| `limit` is too large
88

99
error: aborting due to previous error
1010

src/test/ui/recursion_limit/zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Test that a `recursion_limit` of 0 is valid
1+
// Test that a `limit` of 0 is valid
22

33
#![recursion_limit = "0"]
44

0 commit comments

Comments
 (0)