File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- // Recursion limit.
12
- //
13
- // There are various parts of the compiler that must impose arbitrary limits
14
- // on how deeply they recurse to prevent stack overflow. Users can override
15
- // this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
16
- // just peeks and looks for that attribute.
11
+ //! Recursion limit.
12
+ //!
13
+ //! There are various parts of the compiler that must impose arbitrary limits
14
+ //! on how deeply they recurse to prevent stack overflow. Users can override
15
+ //! this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
16
+ //! just peeks and looks for that attribute.
17
17
18
18
use session:: Session ;
19
19
use syntax:: ast;
@@ -23,6 +23,11 @@ use rustc_data_structures::sync::Once;
23
23
const RED_ZONE : usize = 1024 * 1024 ; // 1MB
24
24
const STACK_PER_RECURSION : usize = 8 * 1024 * 1024 ; // 8MB
25
25
26
+ /// Grows the stack on demand to prevent stack overflow. Call this in strategic locations
27
+ /// to "break up" recursive calls. E.g. almost any call to `visit_expr` or equivalent can benefit
28
+ /// from this.
29
+ ///
30
+ /// Should not be sprinkled around carelessly, as it causes a little bit of overhead.
26
31
pub fn guarantee_one_mb_stack_left < R , F : FnOnce ( ) -> R > (
27
32
f : F
28
33
) -> R {
You can’t perform that action at this time.
0 commit comments