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.
77
88use crate :: session:: Session ;
99use core:: num:: IntErrorKind ;
@@ -16,6 +16,7 @@ use rustc_data_structures::sync::Once;
1616pub fn update_limits ( sess : & Session , krate : & ast:: Crate ) {
1717 update_limit ( sess, krate, & sess. recursion_limit , sym:: recursion_limit, 128 ) ;
1818 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 ) ;
1920}
2021
2122fn update_limit (
@@ -37,10 +38,8 @@ fn update_limit(
3738 return ;
3839 }
3940 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" ) ;
4443
4544 let value_span = attr
4645 . meta ( )
@@ -49,11 +48,11 @@ fn update_limit(
4948 . unwrap_or ( attr. span ) ;
5049
5150 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" ,
5453 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 `" ) ,
5756 kind => bug ! ( "unimplemented IntErrorKind variant: {:?}" , kind) ,
5857 } ;
5958
0 commit comments