@@ -74,7 +74,6 @@ impl<'tcx> MirPass<'tcx> for Validator {
74
74
mir_phase,
75
75
unwind_edge_count : 0 ,
76
76
reachable_blocks : traversal:: reachable_as_bitset ( body) ,
77
- place_cache : FxHashSet :: default ( ) ,
78
77
value_cache : FxHashSet :: default ( ) ,
79
78
can_unwind,
80
79
} ;
@@ -106,7 +105,6 @@ struct CfgChecker<'a, 'tcx> {
106
105
mir_phase : MirPhase ,
107
106
unwind_edge_count : usize ,
108
107
reachable_blocks : BitSet < BasicBlock > ,
109
- place_cache : FxHashSet < PlaceRef < ' tcx > > ,
110
108
value_cache : FxHashSet < u128 > ,
111
109
// If `false`, then the MIR must not contain `UnwindAction::Continue` or
112
110
// `TerminatorKind::Resume`.
@@ -294,19 +292,6 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
294
292
295
293
fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
296
294
match & statement. kind {
297
- StatementKind :: Assign ( box ( dest, rvalue) ) => {
298
- // FIXME(JakobDegen): Check this for all rvalues, not just this one.
299
- if let Rvalue :: Use ( Operand :: Copy ( src) | Operand :: Move ( src) ) = rvalue {
300
- // The sides of an assignment must not alias. Currently this just checks whether
301
- // the places are identical.
302
- if dest == src {
303
- self . fail (
304
- location,
305
- "encountered `Assign` statement with overlapping memory" ,
306
- ) ;
307
- }
308
- }
309
- }
310
295
StatementKind :: AscribeUserType ( ..) => {
311
296
if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
312
297
self . fail (
@@ -341,7 +326,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
341
326
self . fail ( location, format ! ( "explicit `{kind:?}` is forbidden" ) ) ;
342
327
}
343
328
}
344
- StatementKind :: StorageLive ( _)
329
+ StatementKind :: Assign ( ..)
330
+ | StatementKind :: StorageLive ( _)
345
331
| StatementKind :: StorageDead ( _)
346
332
| StatementKind :: Intrinsic ( _)
347
333
| StatementKind :: Coverage ( _)
@@ -404,10 +390,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
404
390
}
405
391
406
392
// The call destination place and Operand::Move place used as an argument might be
407
- // passed by a reference to the callee. Consequently they must be non-overlapping
408
- // and cannot be packed. Currently this simply checks for duplicate places.
409
- self . place_cache . clear ( ) ;
410
- self . place_cache . insert ( destination. as_ref ( ) ) ;
393
+ // passed by a reference to the callee. Consequently they cannot be packed.
411
394
if is_within_packed ( self . tcx , & self . body . local_decls , * destination) . is_some ( ) {
412
395
// This is bad! The callee will expect the memory to be aligned.
413
396
self . fail (
@@ -418,10 +401,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
418
401
) ,
419
402
) ;
420
403
}
421
- let mut has_duplicates = false ;
422
404
for arg in args {
423
405
if let Operand :: Move ( place) = arg {
424
- has_duplicates |= !self . place_cache . insert ( place. as_ref ( ) ) ;
425
406
if is_within_packed ( self . tcx , & self . body . local_decls , * place) . is_some ( ) {
426
407
// This is bad! The callee will expect the memory to be aligned.
427
408
self . fail (
@@ -434,16 +415,6 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
434
415
}
435
416
}
436
417
}
437
-
438
- if has_duplicates {
439
- self . fail (
440
- location,
441
- format ! (
442
- "encountered overlapping memory in `Move` arguments to `Call` terminator: {:?}" ,
443
- terminator. kind,
444
- ) ,
445
- ) ;
446
- }
447
418
}
448
419
TerminatorKind :: Assert { target, unwind, .. } => {
449
420
self . check_edge ( location, * target, EdgeKind :: Normal ) ;
@@ -1112,17 +1083,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1112
1083
)
1113
1084
}
1114
1085
}
1115
- // FIXME(JakobDegen): Check this for all rvalues, not just this one.
1116
- if let Rvalue :: Use ( Operand :: Copy ( src) | Operand :: Move ( src) ) = rvalue {
1117
- // The sides of an assignment must not alias. Currently this just checks whether
1118
- // the places are identical.
1119
- if dest == src {
1120
- self . fail (
1121
- location,
1122
- "encountered `Assign` statement with overlapping memory" ,
1123
- ) ;
1124
- }
1125
- }
1126
1086
}
1127
1087
StatementKind :: AscribeUserType ( ..) => {
1128
1088
if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
0 commit comments