diff options
| author | Alan Egerton <eggyal@gmail.com> | 2023-02-14 00:01:37 +0000 |
|---|---|---|
| committer | Alan Egerton <eggyal@gmail.com> | 2023-02-14 15:09:40 +0000 |
| commit | 3b510e88efebb50c19776cfbaa7f43492cacf71d (patch) | |
| tree | 2c2bddfcf3f18c225e3b11fc9566f2ff42c5f1d3 /compiler/rustc_macros/src/lib.rs | |
| parent | e9ab7872fd77861e3d182ea85a82c4649c5bb3f8 (diff) | |
| download | rust-3b510e88efebb50c19776cfbaa7f43492cacf71d.tar.gz rust-3b510e88efebb50c19776cfbaa7f43492cacf71d.zip | |
Use derive attributes for uninteresting traversals
Diffstat (limited to 'compiler/rustc_macros/src/lib.rs')
| -rw-r--r-- | compiler/rustc_macros/src/lib.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index bb3722fe156..d2cb6ee9f71 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -124,8 +124,27 @@ decl_derive!([TyDecodable] => serialize::type_decodable_derive); decl_derive!([TyEncodable] => serialize::type_encodable_derive); decl_derive!([MetadataDecodable] => serialize::meta_decodable_derive); decl_derive!([MetadataEncodable] => serialize::meta_encodable_derive); -decl_derive!([TypeFoldable, attributes(type_foldable)] => type_foldable::type_foldable_derive); -decl_derive!([TypeVisitable, attributes(type_visitable)] => type_visitable::type_visitable_derive); +decl_derive!( + [TypeFoldable, attributes(type_foldable)] => + /// Derives `TypeFoldable` for the annotated `struct` or `enum` (`union` is not supported). + /// + /// The fold will produce a value of the same struct or enum variant as the input, with + /// each field respectively folded using the `TypeFoldable` implementation for its type. + /// However, if a field of a struct or an enum variant is annotated with + /// `#[type_foldable(identity)]` then that field will retain its incumbent value (and its + /// type is not required to implement `TypeFoldable`). + type_foldable::type_foldable_derive +); +decl_derive!( + [TypeVisitable, attributes(type_visitable)] => + /// Derives `TypeVisitable` 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 + /// `TypeVisitable` implementation for its type. However, if a field of a struct or an enum + /// variant is annotated with `#[type_visitable(ignore)]` then that field will not be + /// visited (and its type is not required to implement `TypeVisitable`). + type_visitable::type_visitable_derive +); decl_derive!([Lift, attributes(lift)] => lift::lift_derive); decl_derive!( [Diagnostic, attributes( |
