@@ -136,10 +136,10 @@ fn check_rvalue(
136
136
) -> McfResult {
137
137
match rvalue {
138
138
Rvalue :: Repeat ( operand, _) | Rvalue :: Use ( operand) => {
139
- check_operand ( tcx , mir , operand, span)
139
+ check_operand ( operand, span)
140
140
}
141
141
Rvalue :: Len ( place) | Rvalue :: Discriminant ( place) | Rvalue :: Ref ( _, _, place) => {
142
- check_place ( tcx , mir , place, span)
142
+ check_place ( place, span)
143
143
}
144
144
Rvalue :: Cast ( CastKind :: Misc , operand, cast_ty) => {
145
145
use rustc:: ty:: cast:: CastTy ;
@@ -153,11 +153,11 @@ fn check_rvalue(
153
153
( CastTy :: RPtr ( _) , CastTy :: Float ) => bug ! ( ) ,
154
154
( CastTy :: RPtr ( _) , CastTy :: Int ( _) ) => bug ! ( ) ,
155
155
( CastTy :: Ptr ( _) , CastTy :: RPtr ( _) ) => bug ! ( ) ,
156
- _ => check_operand ( tcx , mir , operand, span) ,
156
+ _ => check_operand ( operand, span) ,
157
157
}
158
158
}
159
159
Rvalue :: Cast ( CastKind :: Pointer ( PointerCast :: MutToConstPointer ) , operand, _) => {
160
- check_operand ( tcx , mir , operand, span)
160
+ check_operand ( operand, span)
161
161
}
162
162
Rvalue :: Cast ( CastKind :: Pointer ( PointerCast :: UnsafeFnPointer ) , _, _) |
163
163
Rvalue :: Cast ( CastKind :: Pointer ( PointerCast :: ClosureFnPointer ( _) ) , _, _) |
@@ -171,8 +171,8 @@ fn check_rvalue(
171
171
) ) ,
172
172
// binops are fine on integers
173
173
Rvalue :: BinaryOp ( _, lhs, rhs) | Rvalue :: CheckedBinaryOp ( _, lhs, rhs) => {
174
- check_operand ( tcx , mir , lhs, span) ?;
175
- check_operand ( tcx , mir , rhs, span) ?;
174
+ check_operand ( lhs, span) ?;
175
+ check_operand ( rhs, span) ?;
176
176
let ty = lhs. ty ( mir, tcx) ;
177
177
if ty. is_integral ( ) || ty. is_bool ( ) || ty. is_char ( ) {
178
178
Ok ( ( ) )
@@ -191,7 +191,7 @@ fn check_rvalue(
191
191
Rvalue :: UnaryOp ( _, operand) => {
192
192
let ty = operand. ty ( mir, tcx) ;
193
193
if ty. is_integral ( ) || ty. is_bool ( ) {
194
- check_operand ( tcx , mir , operand, span)
194
+ check_operand ( operand, span)
195
195
} else {
196
196
Err ( (
197
197
span,
@@ -201,7 +201,7 @@ fn check_rvalue(
201
201
}
202
202
Rvalue :: Aggregate ( _, operands) => {
203
203
for operand in operands {
204
- check_operand ( tcx , mir , operand, span) ?;
204
+ check_operand ( operand, span) ?;
205
205
}
206
206
Ok ( ( ) )
207
207
}
@@ -216,11 +216,11 @@ fn check_statement(
216
216
let span = statement. source_info . span ;
217
217
match & statement. kind {
218
218
StatementKind :: Assign ( place, rval) => {
219
- check_place ( tcx , mir , place, span) ?;
219
+ check_place ( place, span) ?;
220
220
check_rvalue ( tcx, mir, rval, span)
221
221
}
222
222
223
- StatementKind :: FakeRead ( _, place) => check_place ( tcx , mir , place, span) ,
223
+ StatementKind :: FakeRead ( _, place) => check_place ( place, span) ,
224
224
225
225
// just an assignment
226
226
StatementKind :: SetDiscriminant { .. } => Ok ( ( ) ) ,
@@ -239,22 +239,18 @@ fn check_statement(
239
239
}
240
240
241
241
fn check_operand (
242
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
243
- mir : & ' a Mir < ' tcx > ,
244
242
operand : & Operand < ' tcx > ,
245
243
span : Span ,
246
244
) -> McfResult {
247
245
match operand {
248
246
Operand :: Move ( place) | Operand :: Copy ( place) => {
249
- check_place ( tcx , mir , place, span)
247
+ check_place ( place, span)
250
248
}
251
249
Operand :: Constant ( _) => Ok ( ( ) ) ,
252
250
}
253
251
}
254
252
255
253
fn check_place (
256
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
257
- mir : & ' a Mir < ' tcx > ,
258
254
place : & Place < ' tcx > ,
259
255
span : Span ,
260
256
) -> McfResult {
@@ -268,7 +264,7 @@ fn check_place(
268
264
match proj. elem {
269
265
| ProjectionElem :: ConstantIndex { .. } | ProjectionElem :: Subslice { .. }
270
266
| ProjectionElem :: Deref | ProjectionElem :: Field ( ..) | ProjectionElem :: Index ( _) => {
271
- check_place ( tcx , mir , & proj. base , span)
267
+ check_place ( & proj. base , span)
272
268
}
273
269
| ProjectionElem :: Downcast ( ..) => {
274
270
Err ( ( span, "`match` or `if let` in `const fn` is unstable" . into ( ) ) )
@@ -290,11 +286,11 @@ fn check_terminator(
290
286
| TerminatorKind :: Resume => Ok ( ( ) ) ,
291
287
292
288
TerminatorKind :: Drop { location, .. } => {
293
- check_place ( tcx , mir , location, span)
289
+ check_place ( location, span)
294
290
}
295
291
TerminatorKind :: DropAndReplace { location, value, .. } => {
296
- check_place ( tcx , mir , location, span) ?;
297
- check_operand ( tcx , mir , value, span)
292
+ check_place ( location, span) ?;
293
+ check_operand ( value, span)
298
294
} ,
299
295
300
296
TerminatorKind :: FalseEdges { .. } | TerminatorKind :: SwitchInt { .. } => Err ( (
@@ -346,10 +342,10 @@ fn check_terminator(
346
342
) ) ,
347
343
}
348
344
349
- check_operand ( tcx , mir , func, span) ?;
345
+ check_operand ( func, span) ?;
350
346
351
347
for arg in args {
352
- check_operand ( tcx , mir , arg, span) ?;
348
+ check_operand ( arg, span) ?;
353
349
}
354
350
Ok ( ( ) )
355
351
} else {
@@ -363,7 +359,7 @@ fn check_terminator(
363
359
msg : _,
364
360
target : _,
365
361
cleanup : _,
366
- } => check_operand ( tcx , mir , cond, span) ,
362
+ } => check_operand ( cond, span) ,
367
363
368
364
TerminatorKind :: FalseUnwind { .. } => {
369
365
Err ( ( span, "loops are not allowed in const fn" . into ( ) ) )
0 commit comments