chore: add stack overflow warning for Visitor and VisitorMut (#2068)

This commit is contained in:
niebayes 2025-10-16 16:37:01 +08:00 committed by GitHub
parent c8531d41a1
commit 218f43cf2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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