@@ -78,21 +78,52 @@ decl_derive!(
78
78
[ TypeFoldable , attributes( type_foldable) ] =>
79
79
/// Derives `TypeFoldable` for the annotated `struct` or `enum` (`union` is not supported).
80
80
///
81
- /// The fold will produce a value of the same struct or enum variant as the input, with
82
- /// each field respectively folded using the `TypeFoldable` implementation for its type.
83
- /// However, if a field of a struct or an enum variant is annotated with
84
- /// `#[type_foldable(identity)]` then that field will retain its incumbent value (and its
85
- /// type is not required to implement `TypeFoldable`).
81
+ /// Folds will produce a value of the same struct or enum variant as the input, with each field
82
+ /// respectively folded (in definition order) using the `TypeFoldable` implementation for its
83
+ /// type. However, if a field of a struct or of an enum variant is annotated with
84
+ /// `#[type_foldable(identity)]` then that field will retain its incumbent value (and its type
85
+ /// is not required to implement `TypeFoldable`). However use of this attribute is dangerous
86
+ /// and should be used with extreme caution: should the type of the annotated field contain
87
+ /// (now or in the future) a type that is of interest to a folder, it will not get folded (which
88
+ /// may result in unexpected, hard-to-track bugs that could result in unsoundness).
89
+ ///
90
+ /// If the annotated item has a `'tcx` lifetime parameter, then that will be used as the
91
+ /// lifetime for the type context/interner; otherwise the lifetime of the type context/interner
92
+ /// will be unrelated to the annotated type. It therefore matters how any lifetime parameters of
93
+ /// the annotated type are named. For example, deriving `TypeFoldable` for both `Foo<'a>` and
94
+ /// `Bar<'tcx>` will respectively produce:
95
+ ///
96
+ /// `impl<'a, 'tcx> TypeFoldable<TyCtxt<'tcx>> for Foo<'a>`
97
+ ///
98
+ /// and
99
+ ///
100
+ /// `impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Bar<'tcx>`
86
101
type_foldable:: type_foldable_derive
87
102
) ;
88
103
decl_derive ! (
89
104
[ TypeVisitable , attributes( type_visitable) ] =>
90
105
/// Derives `TypeVisitable` for the annotated `struct` or `enum` (`union` is not supported).
91
106
///
92
- /// Each field of the struct or enum variant will be visited in definition order, using the
93
- /// `TypeVisitable` implementation for its type. However, if a field of a struct or an enum
94
- /// variant is annotated with `#[type_visitable(ignore)]` then that field will not be
95
- /// visited (and its type is not required to implement `TypeVisitable`).
107
+ /// Each field of the struct or enum variant will be visited (in definition order) using the
108
+ /// `TypeVisitable` implementation for its type. However, if a field of a struct or of an enum
109
+ /// variant is annotated with `#[type_visitable(ignore)]` then that field will not be visited
110
+ /// (and its type is not required to implement `TypeVisitable`). However use of this attribute
111
+ /// is dangerous and should be used with extreme caution: should the type of the annotated
112
+ /// field (now or in the future) a type that is of interest to a visitor, it will not get
113
+ /// visited (which may result in unexpected, hard-to-track bugs that could result in
114
+ /// unsoundness).
115
+ ///
116
+ /// If the annotated item has a `'tcx` lifetime parameter, then that will be used as the
117
+ /// lifetime for the type context/interner; otherwise the lifetime of the type context/interner
118
+ /// will be unrelated to the annotated type. It therefore matters how any lifetime parameters of
119
+ /// the annotated type are named. For example, deriving `TypeVisitable` for both `Foo<'a>` and
120
+ /// `Bar<'tcx>` will respectively produce:
121
+ ///
122
+ /// `impl<'a, 'tcx> TypeVisitable<TyCtxt<'tcx>> for Foo<'a>`
123
+ ///
124
+ /// and
125
+ ///
126
+ /// `impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Bar<'tcx>`
96
127
type_visitable:: type_visitable_derive
97
128
) ;
98
129
decl_derive ! ( [ Lift , attributes( lift) ] => lift:: lift_derive) ;
0 commit comments