@@ -11,11 +11,10 @@ use syntax_pos::Span;
11
11
use std:: cell:: RefCell ;
12
12
use std:: fmt;
13
13
use std:: ops:: Deref ;
14
- use std:: rc:: Rc ;
15
14
16
15
use crate :: dataflow as old_dataflow;
17
16
use super :: { Item , Qualif , is_lang_panic_fn} ;
18
- use super :: resolver:: { QualifResolver , FlowSensitiveResolver } ;
17
+ use super :: resolver:: { FlowSensitiveResolver , IndirectlyMutableResults , QualifResolver } ;
19
18
use super :: qualifs:: { HasMutInterior , NeedsDrop } ;
20
19
use super :: ops:: { self , NonConstOp } ;
21
20
@@ -127,37 +126,47 @@ impl Deref for Validator<'_, 'mir, 'tcx> {
127
126
}
128
127
}
129
128
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
+
130
152
impl 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 {
132
157
let dead_unwinds = BitSet :: new_empty ( item. body . basic_blocks ( ) . len ( ) ) ;
133
158
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
-
150
159
let needs_drop = FlowSensitiveResolver :: new (
151
160
NeedsDrop ,
152
161
item,
153
- indirectly_mutable_locals. clone ( ) ,
162
+ indirectly_mutable_locals,
154
163
& dead_unwinds,
155
164
) ;
156
165
157
166
let has_mut_interior = FlowSensitiveResolver :: new (
158
167
HasMutInterior ,
159
168
item,
160
- indirectly_mutable_locals. clone ( ) ,
169
+ indirectly_mutable_locals,
161
170
& dead_unwinds,
162
171
) ;
163
172
0 commit comments