1
- // Recursion limit.
2
- //
3
- // There are various parts of the compiler that must impose arbitrary limits
4
- // on how deeply they recurse to prevent stack overflow. Users can override
5
- // this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
6
- // just peeks and looks for that attribute.
1
+ //! Registering limits, recursion_limit, type_length_limit and const_eval_limit
2
+ //!
3
+ //! There are various parts of the compiler that must impose arbitrary limits
4
+ //! on how deeply they recurse to prevent stack overflow. Users can override
5
+ //! this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
6
+ //! just peeks and looks for that attribute.
7
7
8
8
use crate :: session:: Session ;
9
9
use core:: num:: IntErrorKind ;
@@ -16,6 +16,7 @@ use rustc_data_structures::sync::Once;
16
16
pub fn update_limits ( sess : & Session , krate : & ast:: Crate ) {
17
17
update_limit ( sess, krate, & sess. recursion_limit , sym:: recursion_limit, 128 ) ;
18
18
update_limit ( sess, krate, & sess. type_length_limit , sym:: type_length_limit, 1048576 ) ;
19
+ update_limit ( sess, krate, & sess. const_eval_limit , sym:: const_eval_limit, 1_000_000 ) ;
19
20
}
20
21
21
22
fn update_limit (
@@ -37,10 +38,8 @@ fn update_limit(
37
38
return ;
38
39
}
39
40
Err ( e) => {
40
- let mut err = sess. struct_span_err (
41
- attr. span ,
42
- "`recursion_limit` must be a non-negative integer" ,
43
- ) ;
41
+ let mut err =
42
+ sess. struct_span_err ( attr. span , "`limit` must be a non-negative integer" ) ;
44
43
45
44
let value_span = attr
46
45
. meta ( )
@@ -49,11 +48,11 @@ fn update_limit(
49
48
. unwrap_or ( attr. span ) ;
50
49
51
50
let error_str = match e. kind ( ) {
52
- IntErrorKind :: Overflow => "`recursion_limit ` is too large" ,
53
- 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" ,
54
53
IntErrorKind :: InvalidDigit => "not a valid integer" ,
55
- IntErrorKind :: Underflow => bug ! ( "`recursion_limit ` should never underflow" ) ,
56
- 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 `" ) ,
57
56
kind => bug ! ( "unimplemented IntErrorKind variant: {:?}" , kind) ,
58
57
} ;
59
58
0 commit comments