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.
This commit is contained in:
Christoph Schmidler 2020-02-19 10:24:16 +01:00
parent c94c74e2d9
commit 527456e219
13 changed files with 47 additions and 25 deletions

View File

@ -38,10 +38,8 @@ fn update_limit(
return;
}
Err(e) => {
let mut err = sess.struct_span_err(
attr.span,
"`recursion_limit` must be a non-negative integer",
);
let mut err =
sess.struct_span_err(attr.span, "`limit` must be a non-negative integer");
let value_span = attr
.meta()
@ -50,11 +48,11 @@ fn update_limit(
.unwrap_or(attr.span);
let error_str = match e.kind() {
IntErrorKind::Overflow => "`recursion_limit` is too large",
IntErrorKind::Empty => "`recursion_limit` must be a non-negative integer",
IntErrorKind::Overflow => "`limit` is too large",
IntErrorKind::Empty => "`limit` must be a non-negative integer",
IntErrorKind::InvalidDigit => "not a valid integer",
IntErrorKind::Underflow => bug!("`recursion_limit` should never underflow"),
IntErrorKind::Zero => bug!("zero is a valid `recursion_limit`"),
IntErrorKind::Underflow => bug!("`limit` should never underflow"),
IntErrorKind::Zero => bug!("zero is a valid `limit`"),
kind => bug!("unimplemented IntErrorKind variant: {:?}", kind),
};

View File

@ -532,9 +532,6 @@ declare_features! (
/// Allows using `&mut` in constant functions.
(active, const_mut_refs, "1.41.0", Some(57349), None),
// Allows limiting the evaluation steps of const expressions
(active, const_eval_limit, "1.41.0", Some(67217), None),
/// Allows the use of `loop` and `while` in constants.
(active, const_loop, "1.41.0", Some(52000), None),
@ -555,6 +552,9 @@ declare_features! (
/// Allows the use of `no_sanitize` attribute.
(active, no_sanitize, "1.42.0", Some(39699), None),
// Allows limiting the evaluation steps of const expressions
(active, const_eval_limit, "1.43.0", Some(67217), None),
// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
// check-pass
#![feature(const_eval_limit)]
#![const_eval_limit="18_446_744_073_709_551_615"]
//~^ ERROR `limit` must be a non-negative integer
const CONSTANT: usize = limit();

View File

@ -0,0 +1,10 @@
error: `limit` must be a non-negative integer
--> $DIR/const_eval_limit_overflow.rs:2:1
|
LL | #![const_eval_limit="18_446_744_073_709_551_615"]
| ^^^^^^^^^^^^^^^^^^^^----------------------------^
| |
| not a valid integer
error: aborting due to previous error

View File

@ -1,5 +1,9 @@
// ignore-tidy-linelength
// only-x86_64
// check-pass
// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
// optimize away the const function
// compile-flags:-Copt-level=0
#![feature(const_eval_limit)]
#![const_eval_limit="2"]
@ -10,7 +14,7 @@ fn main() {
assert_eq!(CONSTANT, 1764);
}
const fn limit() -> usize {
const fn limit() -> usize { //~ WARNING Constant evaluating a complex constant, this might take some time
let x = 42;
x * 42

View File

@ -1,5 +1,15 @@
warning: Constant evaluating a complex constant, this might take some time
--> $DIR/const_eval_limit_reached.rs:6:1
--> $DIR/const_eval_limit_reached.rs:17:1
|
LL | / const fn limit() -> usize {
LL | | let x = 42;
LL | |
LL | | x * 42
LL | | }
| |_^
warning: Constant evaluating a complex constant, this might take some time
--> $DIR/const_eval_limit_reached.rs:10:1
|
LL | const CONSTANT: usize = limit();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,6 +1,6 @@
// Test the parse error for an empty recursion_limit
#![recursion_limit = ""] //~ ERROR `recursion_limit` must be a non-negative integer
//~| `recursion_limit` must be a non-negative integer
#![recursion_limit = ""] //~ ERROR `limit` must be a non-negative integer
//~| `limit` must be a non-negative integer
fn main() {}

View File

@ -1,10 +1,10 @@
error: `recursion_limit` must be a non-negative integer
error: `limit` must be a non-negative integer
--> $DIR/empty.rs:3:1
|
LL | #![recursion_limit = ""]
| ^^^^^^^^^^^^^^^^^^^^^--^
| |
| `recursion_limit` must be a non-negative integer
| `limit` must be a non-negative integer
error: aborting due to previous error

View File

@ -1,6 +1,6 @@
// Test the parse error for an invalid digit in recursion_limit
#![recursion_limit = "-100"] //~ ERROR `recursion_limit` must be a non-negative integer
#![recursion_limit = "-100"] //~ ERROR `limit` must be a non-negative integer
//~| not a valid integer
fn main() {}

View File

@ -1,4 +1,4 @@
error: `recursion_limit` must be a non-negative integer
error: `limit` must be a non-negative integer
--> $DIR/invalid_digit.rs:3:1
|
LL | #![recursion_limit = "-100"]

View File

@ -1,7 +1,7 @@
// Test the parse error for an overflowing recursion_limit
#![recursion_limit = "999999999999999999999999"]
//~^ ERROR `recursion_limit` must be a non-negative integer
//~| `recursion_limit` is too large
//~^ ERROR `limit` must be a non-negative integer
//~| `limit` is too large
fn main() {}

View File

@ -1,10 +1,10 @@
error: `recursion_limit` must be a non-negative integer
error: `limit` must be a non-negative integer
--> $DIR/overflow.rs:3:1
|
LL | #![recursion_limit = "999999999999999999999999"]
| ^^^^^^^^^^^^^^^^^^^^^--------------------------^
| |
| `recursion_limit` is too large
| `limit` is too large
error: aborting due to previous error

View File

@ -1,4 +1,4 @@
// Test that a `recursion_limit` of 0 is valid
// Test that a `limit` of 0 is valid
#![recursion_limit = "0"]