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
2
6
//!
3
7
//! There are various parts of the compiler that must impose arbitrary limits
4
8
//! on how deeply they recurse to prevent stack overflow. Users can override
8
12
use crate :: bug;
9
13
use rustc_ast as ast;
10
14
use rustc_data_structures:: sync:: OnceCell ;
11
- use rustc_session:: { Limit , Session } ;
15
+ use rustc_session:: Session ;
12
16
use rustc_span:: symbol:: { sym, Symbol } ;
13
17
14
18
use std:: num:: IntErrorKind ;
15
19
16
20
pub fn update_limits ( sess : & Session , krate : & ast:: Crate ) {
17
21
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 ) ;
18
23
update_limit ( sess, krate, & sess. type_length_limit , sym:: type_length_limit, 1048576 ) ;
19
24
update_limit ( sess, krate, & sess. const_eval_limit , sym:: const_eval_limit, 1_000_000 ) ;
20
25
}
21
26
22
27
fn update_limit (
23
28
sess : & Session ,
24
29
krate : & ast:: Crate ,
25
- limit : & OnceCell < Limit > ,
30
+ limit : & OnceCell < impl From < usize > + std :: fmt :: Debug > ,
26
31
name : Symbol ,
27
32
default : usize ,
28
33
) {
@@ -34,7 +39,7 @@ fn update_limit(
34
39
if let Some ( s) = attr. value_str ( ) {
35
40
match s. as_str ( ) . parse ( ) {
36
41
Ok ( n) => {
37
- limit. set ( Limit :: new ( n) ) . unwrap ( ) ;
42
+ limit. set ( From :: from ( n) ) . unwrap ( ) ;
38
43
return ;
39
44
}
40
45
Err ( e) => {
@@ -63,5 +68,5 @@ fn update_limit(
63
68
}
64
69
}
65
70
}
66
- limit. set ( Limit :: new ( default) ) . unwrap ( ) ;
71
+ limit. set ( From :: from ( default) ) . unwrap ( ) ;
67
72
}
0 commit comments