@@ -74,7 +74,6 @@ impl<'tcx> MirPass<'tcx> for Validator {
7474 mir_phase,
7575 unwind_edge_count : 0 ,
7676 reachable_blocks : traversal:: reachable_as_bitset ( body) ,
77- place_cache : FxHashSet :: default ( ) ,
7877 value_cache : FxHashSet :: default ( ) ,
7978 can_unwind,
8079 } ;
@@ -106,7 +105,6 @@ struct CfgChecker<'a, 'tcx> {
106105 mir_phase : MirPhase ,
107106 unwind_edge_count : usize ,
108107 reachable_blocks : BitSet < BasicBlock > ,
109- place_cache : FxHashSet < PlaceRef < ' tcx > > ,
110108 value_cache : FxHashSet < u128 > ,
111109 // If `false`, then the MIR must not contain `UnwindAction::Continue` or
112110 // `TerminatorKind::Resume`.
@@ -294,19 +292,6 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
294292
295293 fn visit_statement ( & mut self , statement : & Statement < ' tcx > , location : Location ) {
296294 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- }
310295 StatementKind :: AscribeUserType ( ..) => {
311296 if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
312297 self . fail (
@@ -341,7 +326,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
341326 self . fail ( location, format ! ( "explicit `{kind:?}` is forbidden" ) ) ;
342327 }
343328 }
344- StatementKind :: StorageLive ( _)
329+ StatementKind :: Assign ( ..)
330+ | StatementKind :: StorageLive ( _)
345331 | StatementKind :: StorageDead ( _)
346332 | StatementKind :: Intrinsic ( _)
347333 | StatementKind :: Coverage ( _)
@@ -404,10 +390,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
404390 }
405391
406392 // 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.
411394 if is_within_packed ( self . tcx , & self . body . local_decls , * destination) . is_some ( ) {
412395 // This is bad! The callee will expect the memory to be aligned.
413396 self . fail (
@@ -418,10 +401,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
418401 ) ,
419402 ) ;
420403 }
421- let mut has_duplicates = false ;
422404 for arg in args {
423405 if let Operand :: Move ( place) = arg {
424- has_duplicates |= !self . place_cache . insert ( place. as_ref ( ) ) ;
425406 if is_within_packed ( self . tcx , & self . body . local_decls , * place) . is_some ( ) {
426407 // This is bad! The callee will expect the memory to be aligned.
427408 self . fail (
@@ -434,16 +415,6 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
434415 }
435416 }
436417 }
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- }
447418 }
448419 TerminatorKind :: Assert { target, unwind, .. } => {
449420 self . check_edge ( location, * target, EdgeKind :: Normal ) ;
@@ -1112,17 +1083,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
11121083 )
11131084 }
11141085 }
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- }
11261086 }
11271087 StatementKind :: AscribeUserType ( ..) => {
11281088 if self . mir_phase >= MirPhase :: Runtime ( RuntimePhase :: Initial ) {
0 commit comments