@@ -87,41 +87,46 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
8787 Terminator { source_info : self . source_info , kind }
8888 }
8989
90- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
90+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < ( ) , ( ) > {
9191 use crate :: mir:: TerminatorKind :: * ;
9292
9393 match self . kind {
9494 SwitchInt { ref discr, switch_ty, .. } => {
95- discr. visit_with ( visitor) || switch_ty. visit_with ( visitor)
95+ discr. visit_with ( visitor) ?;
96+ switch_ty. visit_with ( visitor)
9697 }
9798 Drop { ref place, .. } => place. visit_with ( visitor) ,
9899 DropAndReplace { ref place, ref value, .. } => {
99- place. visit_with ( visitor) || value. visit_with ( visitor)
100+ place. visit_with ( visitor) ?;
101+ value. visit_with ( visitor)
100102 }
101103 Yield { ref value, .. } => value. visit_with ( visitor) ,
102104 Call { ref func, ref args, ref destination, .. } => {
103- let dest = if let Some ( ( ref loc, _) ) = * destination {
104- loc. visit_with ( visitor)
105- } else {
106- false
105+ if let Some ( ( ref loc, _) ) = * destination {
106+ loc. visit_with ( visitor) ?;
107107 } ;
108- dest || func. visit_with ( visitor) || args. visit_with ( visitor)
108+ func. visit_with ( visitor) ?;
109+ args. visit_with ( visitor)
109110 }
110111 Assert { ref cond, ref msg, .. } => {
111- if cond. visit_with ( visitor) {
112+ if cond. visit_with ( visitor) == ControlFlow :: BREAK {
112113 use AssertKind :: * ;
113114 match msg {
114115 BoundsCheck { ref len, ref index } => {
115- len. visit_with ( visitor) || index. visit_with ( visitor)
116+ len. visit_with ( visitor) ?;
117+ index. visit_with ( visitor)
118+ }
119+ Overflow ( _, l, r) => {
120+ l. visit_with ( visitor) ?;
121+ r. visit_with ( visitor)
116122 }
117- Overflow ( _, l, r) => l. visit_with ( visitor) || r. visit_with ( visitor) ,
118123 OverflowNeg ( op) | DivisionByZero ( op) | RemainderByZero ( op) => {
119124 op. visit_with ( visitor)
120125 }
121- ResumedAfterReturn ( _) | ResumedAfterPanic ( _) => false ,
126+ ResumedAfterReturn ( _) | ResumedAfterPanic ( _) => ControlFlow :: CONTINUE ,
122127 }
123128 } else {
124- false
129+ ControlFlow :: CONTINUE
125130 }
126131 }
127132 InlineAsm { ref operands, .. } => operands. visit_with ( visitor) ,
@@ -132,7 +137,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
132137 | GeneratorDrop
133138 | Unreachable
134139 | FalseEdge { .. }
135- | FalseUnwind { .. } => false ,
140+ | FalseUnwind { .. } => ControlFlow :: CONTINUE ,
136141 }
137142 }
138143}
@@ -142,8 +147,8 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
142147 * self
143148 }
144149
145- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> bool {
146- false
150+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> ControlFlow < ( ) , ( ) > {
151+ ControlFlow :: CONTINUE
147152 }
148153}
149154
@@ -152,8 +157,9 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
152157 Place { local : self . local . fold_with ( folder) , projection : self . projection . fold_with ( folder) }
153158 }
154159
155- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
156- self . local . visit_with ( visitor) || self . projection . visit_with ( visitor)
160+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < ( ) , ( ) > {
161+ self . local . visit_with ( visitor) ?;
162+ self . projection . visit_with ( visitor)
157163 }
158164}
159165
@@ -163,8 +169,8 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
163169 folder. tcx ( ) . intern_place_elems ( & v)
164170 }
165171
166- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
167- self . iter ( ) . any ( |t| t. visit_with ( visitor) )
172+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < ( ) , ( ) > {
173+ self . iter ( ) . try_for_each ( |t| t. visit_with ( visitor) )
168174 }
169175}
170176
@@ -213,32 +219,47 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
213219 }
214220 }
215221
216- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
222+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < ( ) , ( ) > {
217223 use crate :: mir:: Rvalue :: * ;
218224 match * self {
219225 Use ( ref op) => op. visit_with ( visitor) ,
220226 Repeat ( ref op, _) => op. visit_with ( visitor) ,
221227 ThreadLocalRef ( did) => did. visit_with ( visitor) ,
222- Ref ( region, _, ref place) => region. visit_with ( visitor) || place. visit_with ( visitor) ,
228+ Ref ( region, _, ref place) => {
229+ region. visit_with ( visitor) ?;
230+ place. visit_with ( visitor)
231+ }
223232 AddressOf ( _, ref place) => place. visit_with ( visitor) ,
224233 Len ( ref place) => place. visit_with ( visitor) ,
225- Cast ( _, ref op, ty) => op. visit_with ( visitor) || ty. visit_with ( visitor) ,
234+ Cast ( _, ref op, ty) => {
235+ op. visit_with ( visitor) ?;
236+ ty. visit_with ( visitor)
237+ }
226238 BinaryOp ( _, ref rhs, ref lhs) | CheckedBinaryOp ( _, ref rhs, ref lhs) => {
227- rhs. visit_with ( visitor) || lhs. visit_with ( visitor)
239+ rhs. visit_with ( visitor) ?;
240+ lhs. visit_with ( visitor)
228241 }
229242 UnaryOp ( _, ref val) => val. visit_with ( visitor) ,
230243 Discriminant ( ref place) => place. visit_with ( visitor) ,
231244 NullaryOp ( _, ty) => ty. visit_with ( visitor) ,
232245 Aggregate ( ref kind, ref fields) => {
233- ( match * * kind {
234- AggregateKind :: Array ( ty) => ty. visit_with ( visitor) ,
235- AggregateKind :: Tuple => false ,
246+ match * * kind {
247+ AggregateKind :: Array ( ty) => {
248+ ty. visit_with ( visitor) ?;
249+ }
250+ AggregateKind :: Tuple => { }
236251 AggregateKind :: Adt ( _, _, substs, user_ty, _) => {
237- substs. visit_with ( visitor) || user_ty. visit_with ( visitor)
252+ substs. visit_with ( visitor) ?;
253+ user_ty. visit_with ( visitor) ?;
254+ }
255+ AggregateKind :: Closure ( _, substs) => {
256+ substs. visit_with ( visitor) ?;
238257 }
239- AggregateKind :: Closure ( _, substs) => substs. visit_with ( visitor) ,
240- AggregateKind :: Generator ( _, substs, _) => substs. visit_with ( visitor) ,
241- } ) || fields. visit_with ( visitor)
258+ AggregateKind :: Generator ( _, substs, _) => {
259+ substs. visit_with ( visitor) ?;
260+ }
261+ }
262+ fields. visit_with ( visitor)
242263 }
243264 }
244265 }
@@ -253,7 +274,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
253274 }
254275 }
255276
256- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
277+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < ( ) , ( ) > {
257278 match * self {
258279 Operand :: Copy ( ref place) | Operand :: Move ( ref place) => place. visit_with ( visitor) ,
259280 Operand :: Constant ( ref c) => c. visit_with ( visitor) ,
@@ -277,13 +298,13 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
277298 }
278299 }
279300
280- fn super_visit_with < Vs : TypeVisitor < ' tcx > > ( & self , visitor : & mut Vs ) -> bool {
301+ fn super_visit_with < Vs : TypeVisitor < ' tcx > > ( & self , visitor : & mut Vs ) -> ControlFlow < ( ) , ( ) > {
281302 use crate :: mir:: ProjectionElem :: * ;
282303
283304 match self {
284305 Field ( _, ty) => ty. visit_with ( visitor) ,
285306 Index ( v) => v. visit_with ( visitor) ,
286- _ => false ,
307+ _ => ControlFlow :: CONTINUE ,
287308 }
288309 }
289310}
@@ -292,26 +313,26 @@ impl<'tcx> TypeFoldable<'tcx> for Field {
292313 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , _: & mut F ) -> Self {
293314 * self
294315 }
295- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> bool {
296- false
316+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> ControlFlow < ( ) , ( ) > {
317+ ControlFlow :: CONTINUE
297318 }
298319}
299320
300321impl < ' tcx > TypeFoldable < ' tcx > for GeneratorSavedLocal {
301322 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , _: & mut F ) -> Self {
302323 * self
303324 }
304- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> bool {
305- false
325+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> ControlFlow < ( ) , ( ) > {
326+ ControlFlow :: CONTINUE
306327 }
307328}
308329
309330impl < ' tcx , R : Idx , C : Idx > TypeFoldable < ' tcx > for BitMatrix < R , C > {
310331 fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , _: & mut F ) -> Self {
311332 self . clone ( )
312333 }
313- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> bool {
314- false
334+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , _: & mut V ) -> ControlFlow < ( ) , ( ) > {
335+ ControlFlow :: CONTINUE
315336 }
316337}
317338
@@ -323,7 +344,7 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
323344 literal : self . literal . fold_with ( folder) ,
324345 }
325346 }
326- fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
347+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> ControlFlow < ( ) , ( ) > {
327348 self . literal . visit_with ( visitor)
328349 }
329350}
0 commit comments