Skip to content

Commit 1308711

Browse files
committed
Document guarantee_one_mb_stack_left
1 parent 2d08a56 commit 1308711

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/librustc/middle/recursion_limit.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
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
1818
use session::Session;
1919
use syntax::ast;
@@ -23,6 +23,11 @@ use rustc_data_structures::sync::Once;
2323
const RED_ZONE: usize = 1024*1024; // 1MB
2424
const 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.
2631
pub fn guarantee_one_mb_stack_left<R, F: FnOnce() -> R>(
2732
f: F
2833
) -> R {

0 commit comments

Comments
 (0)