@@ -87,41 +87,46 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
87
87
Terminator { source_info : self . source_info , kind }
88
88
}
89
89
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 < ( ) , ( ) > {
91
91
use crate :: mir:: TerminatorKind :: * ;
92
92
93
93
match self . kind {
94
94
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)
96
97
}
97
98
Drop { ref place, .. } => place. visit_with ( visitor) ,
98
99
DropAndReplace { ref place, ref value, .. } => {
99
- place. visit_with ( visitor) || value. visit_with ( visitor)
100
+ place. visit_with ( visitor) ?;
101
+ value. visit_with ( visitor)
100
102
}
101
103
Yield { ref value, .. } => value. visit_with ( visitor) ,
102
104
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) ?;
107
107
} ;
108
- dest || func. visit_with ( visitor) || args. visit_with ( visitor)
108
+ func. visit_with ( visitor) ?;
109
+ args. visit_with ( visitor)
109
110
}
110
111
Assert { ref cond, ref msg, .. } => {
111
- if cond. visit_with ( visitor) {
112
+ if cond. visit_with ( visitor) == ControlFlow :: BREAK {
112
113
use AssertKind :: * ;
113
114
match msg {
114
115
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)
116
122
}
117
- Overflow ( _, l, r) => l. visit_with ( visitor) || r. visit_with ( visitor) ,
118
123
OverflowNeg ( op) | DivisionByZero ( op) | RemainderByZero ( op) => {
119
124
op. visit_with ( visitor)
120
125
}
121
- ResumedAfterReturn ( _) | ResumedAfterPanic ( _) => false ,
126
+ ResumedAfterReturn ( _) | ResumedAfterPanic ( _) => ControlFlow :: CONTINUE ,
122
127
}
123
128
} else {
124
- false
129
+ ControlFlow :: CONTINUE
125
130
}
126
131
}
127
132
InlineAsm { ref operands, .. } => operands. visit_with ( visitor) ,
@@ -132,7 +137,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
132
137
| GeneratorDrop
133
138
| Unreachable
134
139
| FalseEdge { .. }
135
- | FalseUnwind { .. } => false ,
140
+ | FalseUnwind { .. } => ControlFlow :: CONTINUE ,
136
141
}
137
142
}
138
143
}
@@ -142,8 +147,8 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
142
147
* self
143
148
}
144
149
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
147
152
}
148
153
}
149
154
@@ -152,8 +157,9 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
152
157
Place { local : self . local . fold_with ( folder) , projection : self . projection . fold_with ( folder) }
153
158
}
154
159
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)
157
163
}
158
164
}
159
165
@@ -163,8 +169,8 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
163
169
folder. tcx ( ) . intern_place_elems ( & v)
164
170
}
165
171
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) )
168
174
}
169
175
}
170
176
@@ -213,32 +219,47 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
213
219
}
214
220
}
215
221
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 < ( ) , ( ) > {
217
223
use crate :: mir:: Rvalue :: * ;
218
224
match * self {
219
225
Use ( ref op) => op. visit_with ( visitor) ,
220
226
Repeat ( ref op, _) => op. visit_with ( visitor) ,
221
227
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
+ }
223
232
AddressOf ( _, ref place) => place. visit_with ( visitor) ,
224
233
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
+ }
226
238
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)
228
241
}
229
242
UnaryOp ( _, ref val) => val. visit_with ( visitor) ,
230
243
Discriminant ( ref place) => place. visit_with ( visitor) ,
231
244
NullaryOp ( _, ty) => ty. visit_with ( visitor) ,
232
245
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 => { }
236
251
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) ?;
238
257
}
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)
242
263
}
243
264
}
244
265
}
@@ -253,7 +274,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
253
274
}
254
275
}
255
276
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 < ( ) , ( ) > {
257
278
match * self {
258
279
Operand :: Copy ( ref place) | Operand :: Move ( ref place) => place. visit_with ( visitor) ,
259
280
Operand :: Constant ( ref c) => c. visit_with ( visitor) ,
@@ -277,13 +298,13 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
277
298
}
278
299
}
279
300
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 < ( ) , ( ) > {
281
302
use crate :: mir:: ProjectionElem :: * ;
282
303
283
304
match self {
284
305
Field ( _, ty) => ty. visit_with ( visitor) ,
285
306
Index ( v) => v. visit_with ( visitor) ,
286
- _ => false ,
307
+ _ => ControlFlow :: CONTINUE ,
287
308
}
288
309
}
289
310
}
@@ -292,26 +313,26 @@ impl<'tcx> TypeFoldable<'tcx> for Field {
292
313
fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , _: & mut F ) -> Self {
293
314
* self
294
315
}
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
297
318
}
298
319
}
299
320
300
321
impl < ' tcx > TypeFoldable < ' tcx > for GeneratorSavedLocal {
301
322
fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , _: & mut F ) -> Self {
302
323
* self
303
324
}
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
306
327
}
307
328
}
308
329
309
330
impl < ' tcx , R : Idx , C : Idx > TypeFoldable < ' tcx > for BitMatrix < R , C > {
310
331
fn super_fold_with < F : TypeFolder < ' tcx > > ( & self , _: & mut F ) -> Self {
311
332
self . clone ( )
312
333
}
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
315
336
}
316
337
}
317
338
@@ -323,7 +344,7 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
323
344
literal : self . literal . fold_with ( folder) ,
324
345
}
325
346
}
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 < ( ) , ( ) > {
327
348
self . literal . visit_with ( visitor)
328
349
}
329
350
}
0 commit comments