diff options
| author | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-11-12 23:41:43 -0500 |
|---|---|---|
| committer | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-12-02 08:41:30 -0500 |
| commit | 05dc5e9f47729b8bba89f7b0e2b54ea7dd1e1777 (patch) | |
| tree | 776ff2e1367119464d6bb6b7b92c6dcc19ce6384 | |
| parent | ed90818ac8b826249f786aae701bf1602a830a8f (diff) | |
| download | rust-05dc5e9f47729b8bba89f7b0e2b54ea7dd1e1777.tar.gz rust-05dc5e9f47729b8bba89f7b0e2b54ea7dd1e1777.zip | |
Compute predecessors in mir_build query and use existing cache for generating ReadOnlyBodyCache, remove unneeded fns
| -rw-r--r-- | src/librustc/mir/cache.rs | 10 | ||||
| -rw-r--r-- | src/librustc_mir/build/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/transform/check_unsafety.rs | 7 |
3 files changed, 7 insertions, 14 deletions
diff --git a/src/librustc/mir/cache.rs b/src/librustc/mir/cache.rs index 09c18d714f2..44d534caa75 100644 --- a/src/librustc/mir/cache.rs +++ b/src/librustc/mir/cache.rs @@ -181,8 +181,6 @@ impl BodyCache<'tcx> { ReadOnlyBodyCache::new(&self.cache, &self.body) } - pub fn cache(&self) -> &Cache { &self.cache } - pub fn basic_blocks_mut(&mut self) -> &mut IndexVec<BasicBlock, BasicBlockData<'tcx>> { self.cache.basic_blocks_mut(&mut self.body) } @@ -240,14 +238,6 @@ impl ReadOnlyBodyCache<'a, 'tcx> { } } - pub fn from_external_cache(cache: &'a mut Cache, body: &'a Body<'tcx>) -> Self { - cache.ensure_predecessors(body); - Self { - cache, - body, - } - } - #[inline] pub fn predecessors(&self) -> &IndexVec<BasicBlock, Vec<BasicBlock>> { self.cache.predecessors.as_ref().unwrap() diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 28b4c9fd09b..b84461d6b92 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -196,7 +196,9 @@ pub fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyCache<'_> { lints::check(tcx, &body, def_id); - BodyCache::new(body) + let mut body = BodyCache::new(body); + body.ensure_predecessors(); + body }) } diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 85932bc5e5b..2c45dcfbe26 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -528,9 +528,10 @@ fn unsafety_check_result(tcx: TyCtxt<'_>, def_id: DefId) -> UnsafetyCheckResult hir::BodyOwnerKind::Static(_) => (true, false), }; let mut checker = UnsafetyChecker::new(const_context, min_const_fn, body, tcx, param_env); - let mut cache = body.cache().clone(); - let read_only_cache = ReadOnlyBodyCache::from_external_cache(&mut cache, body); - checker.visit_body(read_only_cache); + // mir_built ensures that body has a computed cache, so we don't (and can't) attempt to + // recompute it here. + let body = body.unwrap_read_only(); + checker.visit_body(body); check_unused_unsafe(tcx, def_id, &checker.used_unsafe, &mut checker.inherited_blocks); UnsafetyCheckResult { |
