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;
pub yield_ty: Option<Ty<'tcx>>,
/// Generator drop glue.
- pub generator_drop: Option<Box<Body<'tcx>>>,
+ pub generator_drop: Option<Box<BodyCache<'tcx>>>,
/// The layout of a generator. Produced by the state transformation.
pub generator_layout: Option<GeneratorLayout<'tcx>>,
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`.
}
// If we're in another block, then we want to check that block is a predecessor of `other`.
- let mut queue: Vec<BasicBlock> = body_cache.predecessors_for(other.block).to_vec();
+ let mut queue: Vec<BasicBlock> = 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;
}