@@ -233,18 +233,6 @@ impl Validator<'a, 'mir, 'tcx> {
233233 self . check_op_spanned ( ops:: StaticAccess , span)
234234 }
235235 }
236-
237- fn check_immutable_borrow_like ( & mut self , location : Location , place : & Place < ' tcx > ) {
238- let borrowed_place_has_mut_interior = HasMutInterior :: in_place (
239- & self . item ,
240- & mut |local| self . qualifs . has_mut_interior ( local, location) ,
241- place. as_ref ( ) ,
242- ) ;
243-
244- if borrowed_place_has_mut_interior {
245- self . check_op ( ops:: CellBorrow ) ;
246- }
247- }
248236}
249237
250238impl Visitor < ' tcx > for Validator < ' _ , ' mir , ' tcx > {
@@ -350,12 +338,17 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
350338 Rvalue :: AddressOf ( Mutability :: Mut , _) => self . check_op ( ops:: MutAddressOf ) ,
351339
352340 Rvalue :: Ref ( _, BorrowKind :: Shared , ref place)
353- | Rvalue :: Ref ( _, BorrowKind :: Shallow , ref place) => {
354- self . check_immutable_borrow_like ( location, place)
355- }
356-
357- Rvalue :: AddressOf ( Mutability :: Not , ref place) => {
358- self . check_immutable_borrow_like ( location, place)
341+ | Rvalue :: Ref ( _, BorrowKind :: Shallow , ref place)
342+ | Rvalue :: AddressOf ( Mutability :: Not , ref place) => {
343+ let borrowed_place_has_mut_interior = HasMutInterior :: in_place (
344+ & self . item ,
345+ & mut |local| self . qualifs . has_mut_interior ( local, location) ,
346+ place. as_ref ( ) ,
347+ ) ;
348+
349+ if borrowed_place_has_mut_interior {
350+ self . check_op ( ops:: CellBorrow ) ;
351+ }
359352 }
360353
361354 Rvalue :: Cast ( CastKind :: Misc , ref operand, cast_ty) => {
0 commit comments