From 218f43cf2de1b436637430bbd936613b30e277a9 Mon Sep 17 00:00:00 2001 From: niebayes Date: Thu, 16 Oct 2025 16:37:01 +0800 Subject: [PATCH] chore: add stack overflow warning for Visitor and VisitorMut (#2068) --- src/ast/visitor.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index 7840f0e1..328f925f 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -182,6 +182,10 @@ visit_noop!(bigdecimal::BigDecimal); /// ``` pub trait Visitor { /// Type returned when the recursion returns early. + /// + /// Important note: The `Break` type should be kept as small as possible to prevent + /// stack overflow during recursion. If you need to return an error, consider + /// boxing it with `Box` to minimize stack usage. type Break; /// Invoked for any queries that appear in the AST before visiting children @@ -290,6 +294,10 @@ pub trait Visitor { /// ``` pub trait VisitorMut { /// Type returned when the recursion returns early. + /// + /// Important note: The `Break` type should be kept as small as possible to prevent + /// stack overflow during recursion. If you need to return an error, consider + /// boxing it with `Box` to minimize stack usage. type Break; /// Invoked for any queries that appear in the AST before visiting children