1- //! Registering limits, recursion_limit, type_length_limit and const_eval_limit
1+ //! Registering limits:
2+ //! * recursion_limit,
3+ //! * move_size_limit,
4+ //! * type_length_limit, and
5+ //! * const_eval_limit
26//!
37//! There are various parts of the compiler that must impose arbitrary limits
48//! on how deeply they recurse to prevent stack overflow. Users can override
812use crate :: bug;
913use rustc_ast as ast;
1014use rustc_data_structures:: sync:: OnceCell ;
11- use rustc_session:: { Limit , Session } ;
15+ use rustc_session:: Session ;
1216use rustc_span:: symbol:: { sym, Symbol } ;
1317
1418use std:: num:: IntErrorKind ;
1519
1620pub fn update_limits ( sess : & Session , krate : & ast:: Crate ) {
1721 update_limit ( sess, krate, & sess. recursion_limit , sym:: recursion_limit, 128 ) ;
22+ update_limit ( sess, krate, & sess. move_size_limit , sym:: move_size_limit, 0 ) ;
1823 update_limit ( sess, krate, & sess. type_length_limit , sym:: type_length_limit, 1048576 ) ;
1924 update_limit ( sess, krate, & sess. const_eval_limit , sym:: const_eval_limit, 1_000_000 ) ;
2025}
2126
2227fn update_limit (
2328 sess : & Session ,
2429 krate : & ast:: Crate ,
25- limit : & OnceCell < Limit > ,
30+ limit : & OnceCell < impl From < usize > + std :: fmt :: Debug > ,
2631 name : Symbol ,
2732 default : usize ,
2833) {
@@ -34,7 +39,7 @@ fn update_limit(
3439 if let Some ( s) = attr. value_str ( ) {
3540 match s. as_str ( ) . parse ( ) {
3641 Ok ( n) => {
37- limit. set ( Limit :: new ( n) ) . unwrap ( ) ;
42+ limit. set ( From :: from ( n) ) . unwrap ( ) ;
3843 return ;
3944 }
4045 Err ( e) => {
@@ -63,5 +68,5 @@ fn update_limit(
6368 }
6469 }
6570 }
66- limit. set ( Limit :: new ( default) ) . unwrap ( ) ;
71+ limit. set ( From :: from ( default) ) . unwrap ( ) ;
6772}
0 commit comments