@@ -11,11 +11,10 @@ use syntax_pos::Span;
1111use std:: cell:: RefCell ;
1212use std:: fmt;
1313use std:: ops:: Deref ;
14- use std:: rc:: Rc ;
1514
1615use crate :: dataflow as old_dataflow;
1716use super :: { Item , Qualif , is_lang_panic_fn} ;
18- use super :: resolver:: { QualifResolver , FlowSensitiveResolver } ;
17+ use super :: resolver:: { FlowSensitiveResolver , IndirectlyMutableResults , QualifResolver } ;
1918use super :: qualifs:: { HasMutInterior , NeedsDrop } ;
2019use super :: ops:: { self , NonConstOp } ;
2120
@@ -127,37 +126,47 @@ impl Deref for Validator<'_, 'mir, 'tcx> {
127126 }
128127}
129128
129+ pub fn compute_indirectly_mutable_locals < ' mir , ' tcx > (
130+ item : & Item < ' mir , ' tcx > ,
131+ ) -> RefCell < IndirectlyMutableResults < ' mir , ' tcx > > {
132+ let dead_unwinds = BitSet :: new_empty ( item. body . basic_blocks ( ) . len ( ) ) ;
133+
134+ let indirectly_mutable_locals = old_dataflow:: do_dataflow (
135+ item. tcx ,
136+ item. body ,
137+ item. def_id ,
138+ & [ ] ,
139+ & dead_unwinds,
140+ old_dataflow:: IndirectlyMutableLocals :: new ( item. tcx , item. body , item. param_env ) ,
141+ |_, local| old_dataflow:: DebugFormatted :: new ( & local) ,
142+ ) ;
143+
144+ let indirectly_mutable_locals = old_dataflow:: DataflowResultsCursor :: new (
145+ indirectly_mutable_locals,
146+ item. body ,
147+ ) ;
148+
149+ RefCell :: new ( indirectly_mutable_locals)
150+ }
151+
130152impl Validator < ' a , ' mir , ' tcx > {
131- pub fn new ( item : & ' a Item < ' mir , ' tcx > ) -> Self {
153+ pub fn new (
154+ item : & ' a Item < ' mir , ' tcx > ,
155+ indirectly_mutable_locals : & ' a RefCell < IndirectlyMutableResults < ' mir , ' tcx > > ,
156+ ) -> Self {
132157 let dead_unwinds = BitSet :: new_empty ( item. body . basic_blocks ( ) . len ( ) ) ;
133158
134- let indirectly_mutable_locals = old_dataflow:: do_dataflow (
135- item. tcx ,
136- item. body ,
137- item. def_id ,
138- & [ ] ,
139- & dead_unwinds,
140- old_dataflow:: IndirectlyMutableLocals :: new ( item. tcx , item. body , item. param_env ) ,
141- |_, local| old_dataflow:: DebugFormatted :: new ( & local) ,
142- ) ;
143-
144- let indirectly_mutable_locals = old_dataflow:: DataflowResultsCursor :: new (
145- indirectly_mutable_locals,
146- item. body ,
147- ) ;
148- let indirectly_mutable_locals = Rc :: new ( RefCell :: new ( indirectly_mutable_locals) ) ;
149-
150159 let needs_drop = FlowSensitiveResolver :: new (
151160 NeedsDrop ,
152161 item,
153- indirectly_mutable_locals. clone ( ) ,
162+ indirectly_mutable_locals,
154163 & dead_unwinds,
155164 ) ;
156165
157166 let has_mut_interior = FlowSensitiveResolver :: new (
158167 HasMutInterior ,
159168 item,
160- indirectly_mutable_locals. clone ( ) ,
169+ indirectly_mutable_locals,
161170 & dead_unwinds,
162171 ) ;
163172
0 commit comments