@@ -18,7 +18,7 @@ macro_rules! span_bug {
1818}
1919
2020///////////////////////////////////////////////////////////////////////////
21- // Lift and TypeFoldable macros
21+ // Lift and TypeFoldable/TypeVisitable macros
2222//
2323// When possible, use one of these (relatively) convenient macros to write
2424// the impls for you.
@@ -48,7 +48,7 @@ macro_rules! CloneLiftImpls {
4848/// Used for types that are `Copy` and which **do not care arena
4949/// allocated data** (i.e., don't need to be folded).
5050#[ macro_export]
51- macro_rules! TrivialTypeFoldableImpls {
51+ macro_rules! TrivialTypeTraversalImpls {
5252 ( for <$tcx: lifetime> { $( $ty: ty, ) + } ) => {
5353 $(
5454 impl <$tcx> $crate:: ty:: fold:: TypeFoldable <$tcx> for $ty {
@@ -58,8 +58,10 @@ macro_rules! TrivialTypeFoldableImpls {
5858 ) -> :: std:: result:: Result <$ty, F :: Error > {
5959 Ok ( self )
6060 }
61+ }
6162
62- fn visit_with<F : $crate:: ty:: fold:: TypeVisitor <$tcx>>(
63+ impl <$tcx> $crate:: ty:: visit:: TypeVisitable <$tcx> for $ty {
64+ fn visit_with<F : $crate:: ty:: visit:: TypeVisitor <$tcx>>(
6365 & self ,
6466 _: & mut F )
6567 -> :: std:: ops:: ControlFlow <F :: BreakTy >
@@ -71,7 +73,7 @@ macro_rules! TrivialTypeFoldableImpls {
7173 } ;
7274
7375 ( $( $ty: ty, ) +) => {
74- TrivialTypeFoldableImpls ! {
76+ TrivialTypeTraversalImpls ! {
7577 for <' tcx> {
7678 $( $ty, ) +
7779 }
@@ -80,15 +82,15 @@ macro_rules! TrivialTypeFoldableImpls {
8082}
8183
8284#[ macro_export]
83- macro_rules! TrivialTypeFoldableAndLiftImpls {
85+ macro_rules! TrivialTypeTraversalAndLiftImpls {
8486 ( $( $t: tt) * ) => {
85- TrivialTypeFoldableImpls ! { $( $t) * }
87+ TrivialTypeTraversalImpls ! { $( $t) * }
8688 CloneLiftImpls ! { $( $t) * }
8789 }
8890}
8991
9092#[ macro_export]
91- macro_rules! EnumTypeFoldableImpl {
93+ macro_rules! EnumTypeTraversalImpl {
9294 ( impl <$( $p: tt) ,* > TypeFoldable <$tcx: tt> for $s: path {
9395 $( $variants: tt) *
9496 } $( where $( $wc: tt) * ) * ) => {
@@ -99,14 +101,22 @@ macro_rules! EnumTypeFoldableImpl {
99101 self ,
100102 folder: & mut V ,
101103 ) -> :: std:: result:: Result <Self , V :: Error > {
102- EnumTypeFoldableImpl !( @FoldVariants ( self , folder) input( $( $variants) * ) output( ) )
104+ EnumTypeTraversalImpl !( @FoldVariants ( self , folder) input( $( $variants) * ) output( ) )
103105 }
106+ }
107+ } ;
104108
105- fn visit_with<V : $crate:: ty:: fold:: TypeVisitor <$tcx>>(
109+ ( impl <$( $p: tt) ,* > TypeVisitable <$tcx: tt> for $s: path {
110+ $( $variants: tt) *
111+ } $( where $( $wc: tt) * ) * ) => {
112+ impl <$( $p) ,* > $crate:: ty:: visit:: TypeVisitable <$tcx> for $s
113+ $( where $( $wc) * ) *
114+ {
115+ fn visit_with<V : $crate:: ty:: visit:: TypeVisitor <$tcx>>(
106116 & self ,
107117 visitor: & mut V ,
108118 ) -> :: std:: ops:: ControlFlow <V :: BreakTy > {
109- EnumTypeFoldableImpl !( @VisitVariants ( self , visitor) input( $( $variants) * ) output( ) )
119+ EnumTypeTraversalImpl !( @VisitVariants ( self , visitor) input( $( $variants) * ) output( ) )
110120 }
111121 }
112122 } ;
@@ -120,7 +130,7 @@ macro_rules! EnumTypeFoldableImpl {
120130 ( @FoldVariants ( $this: expr, $folder: expr)
121131 input( ( $variant: path) ( $( $variant_arg: ident) ,* ) , $( $input: tt) * )
122132 output( $( $output: tt) * ) ) => {
123- EnumTypeFoldableImpl !(
133+ EnumTypeTraversalImpl !(
124134 @FoldVariants ( $this, $folder)
125135 input( $( $input) * )
126136 output(
@@ -137,7 +147,7 @@ macro_rules! EnumTypeFoldableImpl {
137147 ( @FoldVariants ( $this: expr, $folder: expr)
138148 input( ( $variant: path) { $( $variant_arg: ident) ,* $( , ) ? } , $( $input: tt) * )
139149 output( $( $output: tt) * ) ) => {
140- EnumTypeFoldableImpl !(
150+ EnumTypeTraversalImpl !(
141151 @FoldVariants ( $this, $folder)
142152 input( $( $input) * )
143153 output(
@@ -155,7 +165,7 @@ macro_rules! EnumTypeFoldableImpl {
155165 ( @FoldVariants ( $this: expr, $folder: expr)
156166 input( ( $variant: path) , $( $input: tt) * )
157167 output( $( $output: tt) * ) ) => {
158- EnumTypeFoldableImpl !(
168+ EnumTypeTraversalImpl !(
159169 @FoldVariants ( $this, $folder)
160170 input( $( $input) * )
161171 output(
@@ -174,12 +184,12 @@ macro_rules! EnumTypeFoldableImpl {
174184 ( @VisitVariants ( $this: expr, $visitor: expr)
175185 input( ( $variant: path) ( $( $variant_arg: ident) ,* ) , $( $input: tt) * )
176186 output( $( $output: tt) * ) ) => {
177- EnumTypeFoldableImpl !(
187+ EnumTypeTraversalImpl !(
178188 @VisitVariants ( $this, $visitor)
179189 input( $( $input) * )
180190 output(
181191 $variant ( $( $variant_arg) ,* ) => {
182- $( $crate:: ty:: fold :: TypeFoldable :: visit_with(
192+ $( $crate:: ty:: visit :: TypeVisitable :: visit_with(
183193 $variant_arg, $visitor
184194 ) ?; ) *
185195 :: std:: ops:: ControlFlow :: CONTINUE
@@ -192,12 +202,12 @@ macro_rules! EnumTypeFoldableImpl {
192202 ( @VisitVariants ( $this: expr, $visitor: expr)
193203 input( ( $variant: path) { $( $variant_arg: ident) ,* $( , ) ? } , $( $input: tt) * )
194204 output( $( $output: tt) * ) ) => {
195- EnumTypeFoldableImpl !(
205+ EnumTypeTraversalImpl !(
196206 @VisitVariants ( $this, $visitor)
197207 input( $( $input) * )
198208 output(
199209 $variant { $( $variant_arg) ,* } => {
200- $( $crate:: ty:: fold :: TypeFoldable :: visit_with(
210+ $( $crate:: ty:: visit :: TypeVisitable :: visit_with(
201211 $variant_arg, $visitor
202212 ) ?; ) *
203213 :: std:: ops:: ControlFlow :: CONTINUE
@@ -210,7 +220,7 @@ macro_rules! EnumTypeFoldableImpl {
210220 ( @VisitVariants ( $this: expr, $visitor: expr)
211221 input( ( $variant: path) , $( $input: tt) * )
212222 output( $( $output: tt) * ) ) => {
213- EnumTypeFoldableImpl !(
223+ EnumTypeTraversalImpl !(
214224 @VisitVariants ( $this, $visitor)
215225 input( $( $input) * )
216226 output(
0 commit comments