diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-03 22:24:21 +0000 | 
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2025-07-22 01:52:34 +0000 | 
| commit | 3c81faec23161d3f997666e90e6e34747ace6d28 (patch) | |
| tree | 26cafe1a5afbcedcf754c0e3fac9d3dc91bab4a5 /compiler/rustc_macros/src/lib.rs | |
| parent | ca9eecda36795789511e6e19500cb13b5a053fec (diff) | |
| download | rust-3c81faec23161d3f997666e90e6e34747ace6d28.tar.gz rust-3c81faec23161d3f997666e90e6e34747ace6d28.zip | |
Implement AST visitors using a derive macro.
Diffstat (limited to 'compiler/rustc_macros/src/lib.rs')
| -rw-r--r-- | compiler/rustc_macros/src/lib.rs | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 1006ea3ba10..101f5ccb7a4 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -21,6 +21,7 @@ mod symbols; mod try_from; mod type_foldable; mod type_visitable; +mod visitable; // Reads the rust version (e.g. "1.75.0") from the CFG_RELEASE env var and // produces a `RustcVersion` literal containing that version (e.g. @@ -101,6 +102,16 @@ decl_derive!( /// visited (and its type is not required to implement `TypeVisitable`). type_visitable::type_visitable_derive ); +decl_derive!( + [Walkable, attributes(visitable)] => + /// Derives `Walkable` for the annotated `struct` or `enum` (`union` is not supported). + /// + /// Each field of the struct or enum variant will be visited in definition order, using the + /// `Walkable` implementation for its type. However, if a field of a struct or an enum + /// variant is annotated with `#[visitable(ignore)]` then that field will not be + /// visited (and its type is not required to implement `Walkable`). + visitable::visitable_derive +); decl_derive!([Lift, attributes(lift)] => lift::lift_derive); decl_derive!( [Diagnostic, attributes( | 
