@@ -15,17 +15,19 @@ use rustc_span::Span;
15
15
use std:: borrow:: Cow ;
16
16
use std:: ops:: Deref ;
17
17
18
- use self :: old_dataflow:: IndirectlyMutableLocals ;
19
18
use super :: ops:: { self , NonConstOp } ;
20
19
use super :: qualifs:: { self , HasMutInterior , NeedsDrop } ;
21
20
use super :: resolver:: FlowSensitiveAnalysis ;
22
21
use super :: { is_lang_panic_fn, ConstKind , Item , Qualif } ;
23
22
use crate :: const_eval:: { is_const_fn, is_unstable_const_fn} ;
24
- use crate :: dataflow:: { self as old_dataflow , generic as dataflow } ;
25
- use dataflow:: Analysis ;
23
+ use crate :: dataflow:: generic :: { self as dataflow , Analysis } ;
24
+ use crate :: dataflow:: MaybeMutBorrowedLocals ;
26
25
26
+ // We are using `MaybeMutBorrowedLocals` as a proxy for whether an item may have been mutated
27
+ // through a pointer prior to the given point. This is okay even though `MaybeMutBorrowedLocals`
28
+ // kills locals upon `StorageDead` because a local will never be used after a `StorageDead`.
27
29
pub type IndirectlyMutableResults < ' mir , ' tcx > =
28
- old_dataflow :: DataflowResultsCursor < ' mir , ' tcx , IndirectlyMutableLocals < ' mir , ' tcx > > ;
30
+ dataflow :: ResultsCursor < ' mir , ' tcx , MaybeMutBorrowedLocals < ' mir , ' tcx > > ;
29
31
30
32
struct QualifCursor < ' a , ' mir , ' tcx , Q : Qualif > {
31
33
cursor : dataflow:: ResultsCursor < ' mir , ' tcx , FlowSensitiveAnalysis < ' a , ' mir , ' tcx , Q > > ,
@@ -58,7 +60,7 @@ pub struct Qualifs<'a, 'mir, 'tcx> {
58
60
59
61
impl Qualifs < ' a , ' mir , ' tcx > {
60
62
fn indirectly_mutable ( & mut self , local : Local , location : Location ) -> bool {
61
- self . indirectly_mutable . seek ( location) ;
63
+ self . indirectly_mutable . seek_before ( location) ;
62
64
self . indirectly_mutable . get ( ) . contains ( local)
63
65
}
64
66
@@ -134,22 +136,15 @@ impl Deref for Validator<'_, 'mir, 'tcx> {
134
136
135
137
impl Validator < ' a , ' mir , ' tcx > {
136
138
pub fn new ( item : & ' a Item < ' mir , ' tcx > ) -> Self {
139
+ let Item { tcx, body, def_id, param_env, .. } = * item;
140
+
137
141
let needs_drop = QualifCursor :: new ( NeedsDrop , item) ;
138
142
let has_mut_interior = QualifCursor :: new ( HasMutInterior , item) ;
139
143
140
- let dead_unwinds = BitSet :: new_empty ( item. body . basic_blocks ( ) . len ( ) ) ;
141
- let indirectly_mutable = old_dataflow:: do_dataflow (
142
- item. tcx ,
143
- & * item. body ,
144
- item. def_id ,
145
- & item. tcx . get_attrs ( item. def_id ) ,
146
- & dead_unwinds,
147
- old_dataflow:: IndirectlyMutableLocals :: new ( item. tcx , * item. body , item. param_env ) ,
148
- |_, local| old_dataflow:: DebugFormatted :: new ( & local) ,
149
- ) ;
150
-
151
- let indirectly_mutable =
152
- old_dataflow:: DataflowResultsCursor :: new ( indirectly_mutable, * item. body ) ;
144
+ let indirectly_mutable = MaybeMutBorrowedLocals :: new_mut_only ( tcx, * body, param_env)
145
+ . into_engine ( tcx, * body, def_id)
146
+ . iterate_to_fixpoint ( )
147
+ . into_results_cursor ( * body) ;
153
148
154
149
let qualifs = Qualifs { needs_drop, has_mut_interior, indirectly_mutable } ;
155
150
0 commit comments