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 88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
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.
1717
1818use session:: Session ;
1919use syntax:: ast;
@@ -23,6 +23,11 @@ use rustc_data_structures::sync::Once;
2323const RED_ZONE : usize = 1024 * 1024 ; // 1MB
2424const STACK_PER_RECURSION : usize = 8 * 1024 * 1024 ; // 8MB
2525
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.
2631pub fn guarantee_one_mb_stack_left < R , F : FnOnce ( ) -> R > (
2732 f : F
2833) -> R {
You can’t perform that action at this time.
0 commit comments