From 476ccf6ac03fdf5e9abd96726a37e7e16db2d53a Mon Sep 17 00:00:00 2001 From: Shicong Nie Date: Wed, 15 Oct 2025 17:48:17 +0800 Subject: [PATCH 1/2] add important note for Visitor and VisitorMut --- src/ast/visitor.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index 7840f0e14..6e60a3e6e 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -124,6 +124,10 @@ visit_noop!(bigdecimal::BigDecimal); /// node and `post_visit_` methods are invoked after visiting all /// children of the node. /// +/// 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. +/// /// # See also /// /// These methods provide a more concise way of visiting nodes of a certain type: @@ -251,6 +255,10 @@ pub trait Visitor { /// node and `post_visit_` methods are invoked after visiting all /// children of the node. /// +/// 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. +/// /// # See also /// /// These methods provide a more concise way of visiting nodes of a certain type: From d92528c82691af5c660723782cf6a0f6b7bcdf7c Mon Sep 17 00:00:00 2001 From: Shicong Nie Date: Thu, 16 Oct 2025 10:21:52 +0800 Subject: [PATCH 2/2] move note --- src/ast/visitor.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ast/visitor.rs b/src/ast/visitor.rs index 6e60a3e6e..328f925f7 100644 --- a/src/ast/visitor.rs +++ b/src/ast/visitor.rs @@ -124,10 +124,6 @@ visit_noop!(bigdecimal::BigDecimal); /// node and `post_visit_` methods are invoked after visiting all /// children of the node. /// -/// 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. -/// /// # See also /// /// These methods provide a more concise way of visiting nodes of a certain type: @@ -186,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 @@ -255,10 +255,6 @@ pub trait Visitor { /// node and `post_visit_` methods are invoked after visiting all /// children of the node. /// -/// 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. -/// /// # See also /// /// These methods provide a more concise way of visiting nodes of a certain type: @@ -298,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