diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-03 10:33:29 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-03 10:33:33 -0800 |
| commit | 110a7e25b62b94612bbc7c453e191e20c4b38290 (patch) | |
| tree | b23d9408360614ea8649b51e50b557c362f16b15 | |
| parent | 4c5ca44b92691424b9a624e08b9588eaa2bfde25 (diff) | |
| download | rust-110a7e25b62b94612bbc7c453e191e20c4b38290.tar.gz rust-110a7e25b62b94612bbc7c453e191e20c4b38290.zip | |
Eliminate "eager" qualif getter
All qualif getters are now lazy
| -rw-r--r-- | src/librustc_mir/transform/check_consts/validation.rs | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 4dac0d09413..1728037ad43 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -64,7 +64,7 @@ impl Qualifs<'a, 'mir, 'tcx> { /// Returns `true` if `local` is `NeedsDrop` at the given `Location`. /// /// Only updates the cursor if absolutely necessary - fn needs_drop_lazy_seek(&mut self, local: Local, location: Location) -> bool { + fn needs_drop(&mut self, local: Local, location: Location) -> bool { if !self.needs_drop.in_any_value_of_ty.contains(local) { return false; } @@ -76,7 +76,7 @@ impl Qualifs<'a, 'mir, 'tcx> { /// Returns `true` if `local` is `HasMutInterior` at the given `Location`. /// /// Only updates the cursor if absolutely necessary. - fn has_mut_interior_lazy_seek(&mut self, local: Local, location: Location) -> bool { + fn has_mut_interior(&mut self, local: Local, location: Location) -> bool { if !self.has_mut_interior.in_any_value_of_ty.contains(local) { return false; } @@ -86,17 +86,6 @@ impl Qualifs<'a, 'mir, 'tcx> { || self.indirectly_mutable(local, location) } - /// Returns `true` if `local` is `HasMutInterior`, but requires the `has_mut_interior` and - /// `indirectly_mutable` cursors to be updated beforehand. - fn has_mut_interior_eager_seek(&self, local: Local) -> bool { - if !self.has_mut_interior.in_any_value_of_ty.contains(local) { - return false; - } - - self.has_mut_interior.cursor.get().contains(local) - || self.indirectly_mutable.get().contains(local) - } - fn in_return_place(&mut self, item: &Item<'_, 'tcx>) -> ConstQualifs { // Find the `Return` terminator if one exists. // @@ -120,8 +109,8 @@ impl Qualifs<'a, 'mir, 'tcx> { let return_loc = item.body.terminator_loc(return_block); ConstQualifs { - needs_drop: self.needs_drop_lazy_seek(RETURN_PLACE, return_loc), - has_mut_interior: self.has_mut_interior_lazy_seek(RETURN_PLACE, return_loc), + needs_drop: self.needs_drop(RETURN_PLACE, return_loc), + has_mut_interior: self.has_mut_interior(RETURN_PLACE, return_loc), } } } @@ -246,14 +235,9 @@ impl Validator<'a, 'mir, 'tcx> { } fn check_immutable_borrow_like(&mut self, location: Location, place: &Place<'tcx>) { - // FIXME: Change the `in_*` methods to take a `FnMut` so we don't have to manually - // seek the cursors beforehand. - self.qualifs.has_mut_interior.cursor.seek_before(location); - self.qualifs.indirectly_mutable.seek(location); - let borrowed_place_has_mut_interior = HasMutInterior::in_place( &self.item, - &mut |local| self.qualifs.has_mut_interior_eager_seek(local), + &mut |local| self.qualifs.has_mut_interior(local, location), place.as_ref(), ); @@ -571,7 +555,7 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { let needs_drop = if let Some(local) = dropped_place.as_local() { // Use the span where the local was declared as the span of the drop error. err_span = self.body.local_decls[local].source_info.span; - self.qualifs.needs_drop_lazy_seek(local, location) + self.qualifs.needs_drop(local, location) } else { true }; |
