@@ -100,35 +100,11 @@ macro_rules! TrivialTypeTraversalImpls {
100100 } ;
101101
102102 ( $( $ty: ty, ) +) => {
103- $(
104- impl <I : $crate:: ty:: Interner > $crate:: ty:: fold:: ir:: TypeFoldable <I > for $ty {
105- fn try_fold_with<F : $crate:: ty:: fold:: ir:: FallibleTypeFolder <I >>(
106- self ,
107- _: & mut F ,
108- ) -> :: std:: result:: Result <Self , F :: Error > {
109- Ok ( self )
110- }
111-
112- #[ inline]
113- fn fold_with<F : $crate:: ty:: fold:: ir:: TypeFolder <I >>(
114- self ,
115- _: & mut F ,
116- ) -> Self {
117- self
118- }
119- }
120-
121- impl <I : $crate:: ty:: Interner > $crate:: ty:: visit:: ir:: TypeVisitable <I > for $ty {
122- #[ inline]
123- fn visit_with<F : $crate:: ty:: visit:: ir:: TypeVisitor <I >>(
124- & self ,
125- _: & mut F )
126- -> :: std:: ops:: ControlFlow <F :: BreakTy >
127- {
128- :: std:: ops:: ControlFlow :: Continue ( ( ) )
129- }
103+ TrivialTypeTraversalImpls ! {
104+ for <' tcx> {
105+ $( $ty, ) +
130106 }
131- ) +
107+ }
132108 } ;
133109}
134110
@@ -139,145 +115,3 @@ macro_rules! TrivialTypeTraversalAndLiftImpls {
139115 CloneLiftImpls ! { $( $t) * }
140116 }
141117}
142-
143- #[ macro_export]
144- macro_rules! EnumTypeTraversalImpl {
145- ( impl <$( $p: tt) ,* > TypeFoldable <$tcx: tt> for $s: path {
146- $( $variants: tt) *
147- } $( where $( $wc: tt) * ) * ) => {
148- impl <$( $p) ,* > $crate:: ty:: fold:: ir:: TypeFoldable <$tcx> for $s
149- $( where $( $wc) * ) *
150- {
151- fn try_fold_with<V : $crate:: ty:: fold:: ir:: FallibleTypeFolder <$tcx>>(
152- self ,
153- folder: & mut V ,
154- ) -> :: std:: result:: Result <Self , V :: Error > {
155- EnumTypeTraversalImpl !( @FoldVariants ( self , folder) input( $( $variants) * ) output( ) )
156- }
157- }
158- } ;
159-
160- ( impl <$( $p: tt) ,* > TypeVisitable <$tcx: tt> for $s: path {
161- $( $variants: tt) *
162- } $( where $( $wc: tt) * ) * ) => {
163- impl <$( $p) ,* > $crate:: ty:: visit:: ir:: TypeVisitable <$tcx> for $s
164- $( where $( $wc) * ) *
165- {
166- fn visit_with<V : $crate:: ty:: visit:: ir:: TypeVisitor <$tcx>>(
167- & self ,
168- visitor: & mut V ,
169- ) -> :: std:: ops:: ControlFlow <V :: BreakTy > {
170- EnumTypeTraversalImpl !( @VisitVariants ( self , visitor) input( $( $variants) * ) output( ) )
171- }
172- }
173- } ;
174-
175- ( @FoldVariants ( $this: expr, $folder: expr) input( ) output( $( $output: tt) * ) ) => {
176- Ok ( match $this {
177- $( $output) *
178- } )
179- } ;
180-
181- ( @FoldVariants ( $this: expr, $folder: expr)
182- input( ( $variant: path) ( $( $variant_arg: ident) ,* ) , $( $input: tt) * )
183- output( $( $output: tt) * ) ) => {
184- EnumTypeTraversalImpl !(
185- @FoldVariants ( $this, $folder)
186- input( $( $input) * )
187- output(
188- $variant ( $( $variant_arg) ,* ) => {
189- $variant (
190- $( $crate:: ty:: fold:: ir:: TypeFoldable :: try_fold_with( $variant_arg, $folder) ?) ,*
191- )
192- }
193- $( $output) *
194- )
195- )
196- } ;
197-
198- ( @FoldVariants ( $this: expr, $folder: expr)
199- input( ( $variant: path) { $( $variant_arg: ident) ,* $( , ) ? } , $( $input: tt) * )
200- output( $( $output: tt) * ) ) => {
201- EnumTypeTraversalImpl !(
202- @FoldVariants ( $this, $folder)
203- input( $( $input) * )
204- output(
205- $variant { $( $variant_arg) ,* } => {
206- $variant {
207- $( $variant_arg: $crate:: ty:: fold:: ir:: TypeFoldable :: fold_with(
208- $variant_arg, $folder
209- ) ?) ,* }
210- }
211- $( $output) *
212- )
213- )
214- } ;
215-
216- ( @FoldVariants ( $this: expr, $folder: expr)
217- input( ( $variant: path) , $( $input: tt) * )
218- output( $( $output: tt) * ) ) => {
219- EnumTypeTraversalImpl !(
220- @FoldVariants ( $this, $folder)
221- input( $( $input) * )
222- output(
223- $variant => { $variant }
224- $( $output) *
225- )
226- )
227- } ;
228-
229- ( @VisitVariants ( $this: expr, $visitor: expr) input( ) output( $( $output: tt) * ) ) => {
230- match $this {
231- $( $output) *
232- }
233- } ;
234-
235- ( @VisitVariants ( $this: expr, $visitor: expr)
236- input( ( $variant: path) ( $( $variant_arg: ident) ,* ) , $( $input: tt) * )
237- output( $( $output: tt) * ) ) => {
238- EnumTypeTraversalImpl !(
239- @VisitVariants ( $this, $visitor)
240- input( $( $input) * )
241- output(
242- $variant ( $( $variant_arg) ,* ) => {
243- $( $crate:: ty:: visit:: ir:: TypeVisitable :: visit_with(
244- $variant_arg, $visitor
245- ) ?; ) *
246- :: std:: ops:: ControlFlow :: Continue ( ( ) )
247- }
248- $( $output) *
249- )
250- )
251- } ;
252-
253- ( @VisitVariants ( $this: expr, $visitor: expr)
254- input( ( $variant: path) { $( $variant_arg: ident) ,* $( , ) ? } , $( $input: tt) * )
255- output( $( $output: tt) * ) ) => {
256- EnumTypeTraversalImpl !(
257- @VisitVariants ( $this, $visitor)
258- input( $( $input) * )
259- output(
260- $variant { $( $variant_arg) ,* } => {
261- $( $crate:: ty:: visit:: ir:: TypeVisitable :: visit_with(
262- $variant_arg, $visitor
263- ) ?; ) *
264- :: std:: ops:: ControlFlow :: Continue ( ( ) )
265- }
266- $( $output) *
267- )
268- )
269- } ;
270-
271- ( @VisitVariants ( $this: expr, $visitor: expr)
272- input( ( $variant: path) , $( $input: tt) * )
273- output( $( $output: tt) * ) ) => {
274- EnumTypeTraversalImpl !(
275- @VisitVariants ( $this, $visitor)
276- input( $( $input) * )
277- output(
278- $variant => { :: std:: ops:: ControlFlow :: Continue ( ( ) ) }
279- $( $output) *
280- )
281- )
282- } ;
283- }
0 commit comments