use std::cell::RefCell;
use std::marker::PhantomData;
-use std::rc::Rc;
use crate::dataflow::{self as old_dataflow, generic as dataflow};
use super::{Item, Qualif};
fn reset(&mut self);
}
-type IndirectlyMutableResults<'mir, 'tcx> =
+pub type IndirectlyMutableResults<'mir, 'tcx> =
old_dataflow::DataflowResultsCursor<'mir, 'tcx, IndirectlyMutableLocals<'mir, 'tcx>>;
/// A resolver for qualifs that works on arbitrarily complex CFGs.
Q: Qualif,
{
location: Location,
- indirectly_mutable_locals: Rc<RefCell<IndirectlyMutableResults<'mir, 'tcx>>>,
+ indirectly_mutable_locals: &'a RefCell<IndirectlyMutableResults<'mir, 'tcx>>,
cursor: dataflow::ResultsCursor<'mir, 'tcx, FlowSensitiveAnalysis<'a, 'mir, 'tcx, Q>>,
qualifs_per_local: BitSet<Local>,
}
pub fn new(
_: Q,
item: &'a Item<'mir, 'tcx>,
- indirectly_mutable_locals: Rc<RefCell<IndirectlyMutableResults<'mir, 'tcx>>>,
+ indirectly_mutable_locals: &'a RefCell<IndirectlyMutableResults<'mir, 'tcx>>,
dead_unwinds: &BitSet<BasicBlock>,
) -> Self {
let analysis = FlowSensitiveAnalysis {
use std::cell::RefCell;
use std::fmt;
use std::ops::Deref;
-use std::rc::Rc;
use crate::dataflow as old_dataflow;
use super::{Item, Qualif, is_lang_panic_fn};
-use super::resolver::{QualifResolver, FlowSensitiveResolver};
+use super::resolver::{FlowSensitiveResolver, IndirectlyMutableResults, QualifResolver};
use super::qualifs::{HasMutInterior, NeedsDrop};
use super::ops::{self, NonConstOp};
}
}
+pub fn compute_indirectly_mutable_locals<'mir, 'tcx>(
+ item: &Item<'mir, 'tcx>,
+) -> RefCell<IndirectlyMutableResults<'mir, 'tcx>> {
+ let dead_unwinds = BitSet::new_empty(item.body.basic_blocks().len());
+
+ let indirectly_mutable_locals = old_dataflow::do_dataflow(
+ item.tcx,
+ item.body,
+ item.def_id,
+ &[],
+ &dead_unwinds,
+ old_dataflow::IndirectlyMutableLocals::new(item.tcx, item.body, item.param_env),
+ |_, local| old_dataflow::DebugFormatted::new(&local),
+ );
+
+ let indirectly_mutable_locals = old_dataflow::DataflowResultsCursor::new(
+ indirectly_mutable_locals,
+ item.body,
+ );
+
+ RefCell::new(indirectly_mutable_locals)
+}
+
impl Validator<'a, 'mir, 'tcx> {
- pub fn new(item: &'a Item<'mir, 'tcx>) -> Self {
+ pub fn new(
+ item: &'a Item<'mir, 'tcx>,
+ indirectly_mutable_locals: &'a RefCell<IndirectlyMutableResults<'mir, 'tcx>>,
+ ) -> Self {
let dead_unwinds = BitSet::new_empty(item.body.basic_blocks().len());
- let indirectly_mutable_locals = old_dataflow::do_dataflow(
- item.tcx,
- item.body,
- item.def_id,
- &[],
- &dead_unwinds,
- old_dataflow::IndirectlyMutableLocals::new(item.tcx, item.body, item.param_env),
- |_, local| old_dataflow::DebugFormatted::new(&local),
- );
-
- let indirectly_mutable_locals = old_dataflow::DataflowResultsCursor::new(
- indirectly_mutable_locals,
- item.body,
- );
- let indirectly_mutable_locals = Rc::new(RefCell::new(indirectly_mutable_locals));
-
let needs_drop = FlowSensitiveResolver::new(
NeedsDrop,
item,
- indirectly_mutable_locals.clone(),
+ indirectly_mutable_locals,
&dead_unwinds,
);
let has_mut_interior = FlowSensitiveResolver::new(
HasMutInterior,
item,
- indirectly_mutable_locals.clone(),
+ indirectly_mutable_locals,
&dead_unwinds,
);