@@ -64,7 +64,7 @@ impl Qualifs<'a, 'mir, 'tcx> {
64
64
/// Returns `true` if `local` is `NeedsDrop` at the given `Location`.
65
65
///
66
66
/// Only updates the cursor if absolutely necessary
67
- fn needs_drop_lazy_seek ( & mut self , local : Local , location : Location ) -> bool {
67
+ fn needs_drop ( & mut self , local : Local , location : Location ) -> bool {
68
68
if !self . needs_drop . in_any_value_of_ty . contains ( local) {
69
69
return false ;
70
70
}
@@ -76,7 +76,7 @@ impl Qualifs<'a, 'mir, 'tcx> {
76
76
/// Returns `true` if `local` is `HasMutInterior` at the given `Location`.
77
77
///
78
78
/// Only updates the cursor if absolutely necessary.
79
- fn has_mut_interior_lazy_seek ( & mut self , local : Local , location : Location ) -> bool {
79
+ fn has_mut_interior ( & mut self , local : Local , location : Location ) -> bool {
80
80
if !self . has_mut_interior . in_any_value_of_ty . contains ( local) {
81
81
return false ;
82
82
}
@@ -86,17 +86,6 @@ impl Qualifs<'a, 'mir, 'tcx> {
86
86
|| self . indirectly_mutable ( local, location)
87
87
}
88
88
89
- /// Returns `true` if `local` is `HasMutInterior`, but requires the `has_mut_interior` and
90
- /// `indirectly_mutable` cursors to be updated beforehand.
91
- fn has_mut_interior_eager_seek ( & self , local : Local ) -> bool {
92
- if !self . has_mut_interior . in_any_value_of_ty . contains ( local) {
93
- return false ;
94
- }
95
-
96
- self . has_mut_interior . cursor . get ( ) . contains ( local)
97
- || self . indirectly_mutable . get ( ) . contains ( local)
98
- }
99
-
100
89
fn in_return_place ( & mut self , item : & Item < ' _ , ' tcx > ) -> ConstQualifs {
101
90
// Find the `Return` terminator if one exists.
102
91
//
@@ -120,8 +109,8 @@ impl Qualifs<'a, 'mir, 'tcx> {
120
109
let return_loc = item. body . terminator_loc ( return_block) ;
121
110
122
111
ConstQualifs {
123
- needs_drop : self . needs_drop_lazy_seek ( RETURN_PLACE , return_loc) ,
124
- has_mut_interior : self . has_mut_interior_lazy_seek ( RETURN_PLACE , return_loc) ,
112
+ needs_drop : self . needs_drop ( RETURN_PLACE , return_loc) ,
113
+ has_mut_interior : self . has_mut_interior ( RETURN_PLACE , return_loc) ,
125
114
}
126
115
}
127
116
}
@@ -244,23 +233,6 @@ impl Validator<'a, 'mir, 'tcx> {
244
233
self . check_op_spanned ( ops:: StaticAccess , span)
245
234
}
246
235
}
247
-
248
- fn check_immutable_borrow_like ( & mut self , location : Location , place : & Place < ' tcx > ) {
249
- // FIXME: Change the `in_*` methods to take a `FnMut` so we don't have to manually
250
- // seek the cursors beforehand.
251
- self . qualifs . has_mut_interior . cursor . seek_before ( location) ;
252
- self . qualifs . indirectly_mutable . seek ( location) ;
253
-
254
- let borrowed_place_has_mut_interior = HasMutInterior :: in_place (
255
- & self . item ,
256
- & |local| self . qualifs . has_mut_interior_eager_seek ( local) ,
257
- place. as_ref ( ) ,
258
- ) ;
259
-
260
- if borrowed_place_has_mut_interior {
261
- self . check_op ( ops:: CellBorrow ) ;
262
- }
263
- }
264
236
}
265
237
266
238
impl Visitor < ' tcx > for Validator < ' _ , ' mir , ' tcx > {
@@ -366,12 +338,17 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
366
338
Rvalue :: AddressOf ( Mutability :: Mut , _) => self . check_op ( ops:: MutAddressOf ) ,
367
339
368
340
Rvalue :: Ref ( _, BorrowKind :: Shared , ref place)
369
- | Rvalue :: Ref ( _, BorrowKind :: Shallow , ref place) => {
370
- self . check_immutable_borrow_like ( location, place)
371
- }
372
-
373
- Rvalue :: AddressOf ( Mutability :: Not , ref place) => {
374
- 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
+ }
375
352
}
376
353
377
354
Rvalue :: Cast ( CastKind :: Misc , ref operand, cast_ty) => {
@@ -571,7 +548,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> {
571
548
let needs_drop = if let Some ( local) = dropped_place. as_local ( ) {
572
549
// Use the span where the local was declared as the span of the drop error.
573
550
err_span = self . body . local_decls [ local] . source_info . span ;
574
- self . qualifs . needs_drop_lazy_seek ( local, location)
551
+ self . qualifs . needs_drop ( local, location)
575
552
} else {
576
553
true
577
554
} ;
0 commit comments