1
- use super :: * ;
2
-
3
- use crate :: { AnalysisDomain , CallReturnPlaces , GenKill , GenKillAnalysis } ;
1
+ use rustc_index:: bit_set:: BitSet ;
4
2
use rustc_middle:: mir:: visit:: Visitor ;
5
3
use rustc_middle:: mir:: * ;
6
4
5
+ use crate :: framework:: CallReturnPlaces ;
6
+ use crate :: { AnalysisDomain , GenKill , GenKillAnalysis } ;
7
+
7
8
/// A dataflow analysis that tracks whether a pointer or reference could possibly exist that points
8
9
/// to a given local.
9
10
///
@@ -23,12 +24,12 @@ impl<'tcx> AnalysisDomain<'tcx> for MaybeBorrowedLocals {
23
24
type Domain = BitSet < Local > ;
24
25
const NAME : & ' static str = "maybe_borrowed_locals" ;
25
26
26
- fn bottom_value ( & self , body : & mir :: Body < ' tcx > ) -> Self :: Domain {
27
+ fn bottom_value ( & self , body : & Body < ' tcx > ) -> Self :: Domain {
27
28
// bottom = unborrowed
28
29
BitSet :: new_empty ( body. local_decls ( ) . len ( ) )
29
30
}
30
31
31
- fn initialize_start_block ( & self , _: & mir :: Body < ' tcx > , _: & mut Self :: Domain ) {
32
+ fn initialize_start_block ( & self , _: & Body < ' tcx > , _: & mut Self :: Domain ) {
32
33
// No locals are aliased on function entry
33
34
}
34
35
}
@@ -39,7 +40,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
39
40
fn statement_effect (
40
41
& mut self ,
41
42
trans : & mut impl GenKill < Self :: Idx > ,
42
- statement : & mir :: Statement < ' tcx > ,
43
+ statement : & Statement < ' tcx > ,
43
44
location : Location ,
44
45
) {
45
46
self . transfer_function ( trans) . visit_statement ( statement, location) ;
@@ -48,7 +49,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
48
49
fn terminator_effect (
49
50
& mut self ,
50
51
trans : & mut impl GenKill < Self :: Idx > ,
51
- terminator : & mir :: Terminator < ' tcx > ,
52
+ terminator : & Terminator < ' tcx > ,
52
53
location : Location ,
53
54
) {
54
55
self . transfer_function ( trans) . visit_terminator ( terminator, location) ;
@@ -57,7 +58,7 @@ impl<'tcx> GenKillAnalysis<'tcx> for MaybeBorrowedLocals {
57
58
fn call_return_effect (
58
59
& mut self ,
59
60
_trans : & mut impl GenKill < Self :: Idx > ,
60
- _block : mir :: BasicBlock ,
61
+ _block : BasicBlock ,
61
62
_return_places : CallReturnPlaces < ' _ , ' tcx > ,
62
63
) {
63
64
}
@@ -82,37 +83,37 @@ where
82
83
}
83
84
}
84
85
85
- fn visit_rvalue ( & mut self , rvalue : & mir :: Rvalue < ' tcx > , location : Location ) {
86
+ fn visit_rvalue ( & mut self , rvalue : & Rvalue < ' tcx > , location : Location ) {
86
87
self . super_rvalue ( rvalue, location) ;
87
88
88
89
match rvalue {
89
- mir :: Rvalue :: AddressOf ( _, borrowed_place) | mir :: Rvalue :: Ref ( _, _, borrowed_place) => {
90
+ Rvalue :: AddressOf ( _, borrowed_place) | Rvalue :: Ref ( _, _, borrowed_place) => {
90
91
if !borrowed_place. is_indirect ( ) {
91
92
self . trans . gen ( borrowed_place. local ) ;
92
93
}
93
94
}
94
95
95
- mir :: Rvalue :: Cast ( ..)
96
- | mir :: Rvalue :: ShallowInitBox ( ..)
97
- | mir :: Rvalue :: Use ( ..)
98
- | mir :: Rvalue :: ThreadLocalRef ( ..)
99
- | mir :: Rvalue :: Repeat ( ..)
100
- | mir :: Rvalue :: Len ( ..)
101
- | mir :: Rvalue :: BinaryOp ( ..)
102
- | mir :: Rvalue :: CheckedBinaryOp ( ..)
103
- | mir :: Rvalue :: NullaryOp ( ..)
104
- | mir :: Rvalue :: UnaryOp ( ..)
105
- | mir :: Rvalue :: Discriminant ( ..)
106
- | mir :: Rvalue :: Aggregate ( ..)
107
- | mir :: Rvalue :: CopyForDeref ( ..) => { }
96
+ Rvalue :: Cast ( ..)
97
+ | Rvalue :: ShallowInitBox ( ..)
98
+ | Rvalue :: Use ( ..)
99
+ | Rvalue :: ThreadLocalRef ( ..)
100
+ | Rvalue :: Repeat ( ..)
101
+ | Rvalue :: Len ( ..)
102
+ | Rvalue :: BinaryOp ( ..)
103
+ | Rvalue :: CheckedBinaryOp ( ..)
104
+ | Rvalue :: NullaryOp ( ..)
105
+ | Rvalue :: UnaryOp ( ..)
106
+ | Rvalue :: Discriminant ( ..)
107
+ | Rvalue :: Aggregate ( ..)
108
+ | Rvalue :: CopyForDeref ( ..) => { }
108
109
}
109
110
}
110
111
111
- fn visit_terminator ( & mut self , terminator : & mir :: Terminator < ' tcx > , location : Location ) {
112
+ fn visit_terminator ( & mut self , terminator : & Terminator < ' tcx > , location : Location ) {
112
113
self . super_terminator ( terminator, location) ;
113
114
114
115
match terminator. kind {
115
- mir :: TerminatorKind :: Drop { place : dropped_place, .. } => {
116
+ TerminatorKind :: Drop { place : dropped_place, .. } => {
116
117
// Drop terminators may call custom drop glue (`Drop::drop`), which takes `&mut
117
118
// self` as a parameter. In the general case, a drop impl could launder that
118
119
// reference into the surrounding environment through a raw pointer, thus creating
0 commit comments