@@ -124,21 +124,52 @@ decl_derive!(
124
124
[ TypeFoldable , attributes( type_foldable) ] =>
125
125
/// Derives `TypeFoldable` for the annotated `struct` or `enum` (`union` is not supported).
126
126
///
127
- /// The fold will produce a value of the same struct or enum variant as the input, with
128
- /// each field respectively folded using the `TypeFoldable` implementation for its type.
129
- /// However, if a field of a struct or an enum variant is annotated with
130
- /// `#[type_foldable(identity)]` then that field will retain its incumbent value (and its
131
- /// type is not required to implement `TypeFoldable`).
127
+ /// Folds will produce a value of the same struct or enum variant as the input, with each field
128
+ /// respectively folded (in definition order) using the `TypeFoldable` implementation for its
129
+ /// type. However, if a field of a struct or of an enum variant is annotated with
130
+ /// `#[type_foldable(identity)]` then that field will retain its incumbent value (and its type
131
+ /// is not required to implement `TypeFoldable`). However use of this attribute is dangerous
132
+ /// and should be used with extreme caution: should the type of the annotated field contain
133
+ /// (now or in the future) a type that is of interest to a folder, it will not get folded (which
134
+ /// may result in unexpected, hard-to-track bugs that could result in unsoundness).
135
+ ///
136
+ /// If the annotated type has a `'tcx` lifetime parameter, then that will be used as the
137
+ /// lifetime for the type context/interner; otherwise the lifetime of the type context/interner
138
+ /// will be unrelated to the annotated type. It therefore matters how any lifetime parameters of
139
+ /// the annotated type are named. For example, deriving `TypeFoldable` for both `Foo<'a>` and
140
+ /// `Bar<'tcx>` will respectively produce:
141
+ ///
142
+ /// `impl<'a, 'tcx> TypeFoldable<TyCtxt<'tcx>> for Foo<'a>`
143
+ ///
144
+ /// and
145
+ ///
146
+ /// `impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Bar<'tcx>`
132
147
type_foldable:: type_foldable_derive
133
148
) ;
134
149
decl_derive ! (
135
150
[ TypeVisitable , attributes( type_visitable) ] =>
136
151
/// Derives `TypeVisitable` for the annotated `struct` or `enum` (`union` is not supported).
137
152
///
138
- /// Each field of the struct or enum variant will be visited in definition order, using the
139
- /// `TypeVisitable` implementation for its type. However, if a field of a struct or an enum
140
- /// variant is annotated with `#[type_visitable(ignore)]` then that field will not be
141
- /// visited (and its type is not required to implement `TypeVisitable`).
153
+ /// Each field of the struct or enum variant will be visited (in definition order) using the
154
+ /// `TypeVisitable` implementation for its type. However, if a field of a struct or of an enum
155
+ /// variant is annotated with `#[type_visitable(ignore)]` then that field will not be visited
156
+ /// (and its type is not required to implement `TypeVisitable`). However use of this attribute
157
+ /// is dangerous and should be used with extreme caution: should the type of the annotated
158
+ /// field (now or in the future) a type that is of interest to a visitor, it will not get
159
+ /// visited (which may result in unexpected, hard-to-track bugs that could result in
160
+ /// unsoundness).
161
+ ///
162
+ /// If the annotated type has a `'tcx` lifetime parameter, then that will be used as the
163
+ /// lifetime for the type context/interner; otherwise the lifetime of the type context/interner
164
+ /// will be unrelated to the annotated type. It therefore matters how any lifetime parameters of
165
+ /// the annotated type are named. For example, deriving `TypeVisitable` for both `Foo<'a>` and
166
+ /// `Bar<'tcx>` will respectively produce:
167
+ ///
168
+ /// `impl<'a, 'tcx> TypeVisitable<TyCtxt<'tcx>> for Foo<'a>`
169
+ ///
170
+ /// and
171
+ ///
172
+ /// `impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Bar<'tcx>`
142
173
type_visitable:: type_visitable_derive
143
174
) ;
144
175
decl_derive ! ( [ Lift , attributes( lift) ] => lift:: lift_derive) ;
0 commit comments