X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fmir%2Fmod.rs;h=cc25ad0e22529e3a57d5afa7f97c5b4198c8e7d4;hb=c6354e9839cefbaf80d3a26304bc3e4adacfabb0;hp=9f71840576382fccbd0334af45b24bd90274e1ad;hpb=649c73f96d8969f05000a071007bcd050fa8d466;p=rust.git diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 9f718405763..cc25ad0e225 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -38,7 +38,8 @@ use syntax_pos::{Span, DUMMY_SP}; pub use crate::mir::interpret::AssertMessage; -pub use crate::mir::cache::BodyCache; +pub use crate::mir::cache::{BodyCache, ReadOnlyBodyCache}; +pub use crate::read_only; pub mod cache; pub mod interpret; @@ -107,7 +108,7 @@ pub struct Body<'tcx> { pub yield_ty: Option>, /// Generator drop glue. - pub generator_drop: Option>>, + pub generator_drop: Option>>, /// The layout of a generator. Produced by the state transformation. pub generator_layout: Option>, @@ -2600,7 +2601,7 @@ pub fn successor_within_block(&self) -> Location { pub fn is_predecessor_of<'tcx>( &self, other: Location, - mut body_cache: BodyCache<&'_ Body<'tcx>> + body: ReadOnlyBodyCache<'_, 'tcx> ) -> bool { // If we are in the same block as the other location and are an earlier statement // then we are a predecessor of `other`. @@ -2609,13 +2610,13 @@ pub fn is_predecessor_of<'tcx>( } // If we're in another block, then we want to check that block is a predecessor of `other`. - let mut queue: Vec = body_cache.predecessors_for(other.block).to_vec(); + let mut queue: Vec = body.predecessors_for(other.block).to_vec(); let mut visited = FxHashSet::default(); while let Some(block) = queue.pop() { // If we haven't visited this block before, then make sure we visit it's predecessors. if visited.insert(block) { - queue.extend(body_cache.predecessors_for(block).iter().cloned()); + queue.extend(body.predecessors_for(block).iter().cloned()); } else { continue; }