Skip to content

Commit 218f43c

Browse files
authored
chore: add stack overflow warning for Visitor and VisitorMut (#2068)
1 parent c8531d4 commit 218f43c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ast/visitor.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ visit_noop!(bigdecimal::BigDecimal);
182182
/// ```
183183
pub trait Visitor {
184184
/// Type returned when the recursion returns early.
185+
///
186+
/// Important note: The `Break` type should be kept as small as possible to prevent
187+
/// stack overflow during recursion. If you need to return an error, consider
188+
/// boxing it with `Box` to minimize stack usage.
185189
type Break;
186190

187191
/// Invoked for any queries that appear in the AST before visiting children
@@ -290,6 +294,10 @@ pub trait Visitor {
290294
/// ```
291295
pub trait VisitorMut {
292296
/// Type returned when the recursion returns early.
297+
///
298+
/// Important note: The `Break` type should be kept as small as possible to prevent
299+
/// stack overflow during recursion. If you need to return an error, consider
300+
/// boxing it with `Box` to minimize stack usage.
293301
type Break;
294302

295303
/// Invoked for any queries that appear in the AST before visiting children

0 commit comments

Comments
 (0)