@@ -15,17 +15,19 @@ use rustc_span::Span;
1515use std:: borrow:: Cow ;
1616use std:: ops:: Deref ;
1717
18- use self :: old_dataflow:: IndirectlyMutableLocals ;
1918use super :: ops:: { self , NonConstOp } ;
2019use super :: qualifs:: { self , HasMutInterior , NeedsDrop } ;
2120use super :: resolver:: FlowSensitiveAnalysis ;
2221use super :: { is_lang_panic_fn, ConstKind , Item , Qualif } ;
2322use 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 ;
2625
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`.
2729pub type IndirectlyMutableResults < ' mir , ' tcx > =
28- old_dataflow :: DataflowResultsCursor < ' mir , ' tcx , IndirectlyMutableLocals < ' mir , ' tcx > > ;
30+ dataflow :: ResultsCursor < ' mir , ' tcx , MaybeMutBorrowedLocals < ' mir , ' tcx > > ;
2931
3032struct QualifCursor < ' a , ' mir , ' tcx , Q : Qualif > {
3133 cursor : dataflow:: ResultsCursor < ' mir , ' tcx , FlowSensitiveAnalysis < ' a , ' mir , ' tcx , Q > > ,
@@ -58,7 +60,7 @@ pub struct Qualifs<'a, 'mir, 'tcx> {
5860
5961impl Qualifs < ' a , ' mir , ' tcx > {
6062 fn indirectly_mutable ( & mut self , local : Local , location : Location ) -> bool {
61- self . indirectly_mutable . seek ( location) ;
63+ self . indirectly_mutable . seek_before ( location) ;
6264 self . indirectly_mutable . get ( ) . contains ( local)
6365 }
6466
@@ -134,22 +136,15 @@ impl Deref for Validator<'_, 'mir, 'tcx> {
134136
135137impl Validator < ' a , ' mir , ' tcx > {
136138 pub fn new ( item : & ' a Item < ' mir , ' tcx > ) -> Self {
139+ let Item { tcx, body, def_id, param_env, .. } = * item;
140+
137141 let needs_drop = QualifCursor :: new ( NeedsDrop , item) ;
138142 let has_mut_interior = QualifCursor :: new ( HasMutInterior , item) ;
139143
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) ;
153148
154149 let qualifs = Qualifs { needs_drop, has_mut_interior, indirectly_mutable } ;
155150
0 commit comments