@@ -33,17 +33,36 @@ use std::fmt;
33
33
use std:: hash:: Hash ;
34
34
use std:: rc:: Rc ;
35
35
36
- // `Borrows` maps each dataflow bit to an `Rvalue::Ref`, which can be
37
- // uniquely identified in the MIR by the `Location` of the assigment
38
- // statement in which it appears on the right hand side.
36
+ /// `Borrows` stores the data used in the analyses that track the flow
37
+ /// of borrows.
38
+ ///
39
+ /// It uniquely identifies every borrow (`Rvalue::Ref`) by a
40
+ /// `BorrowIndex`, and maps each such index to a `BorrowData`
41
+ /// describing the borrow. These indexes are used for representing the
42
+ /// borrows in compact bitvectors.
39
43
pub struct Borrows < ' a , ' gcx : ' tcx , ' tcx : ' a > {
40
44
tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
41
45
mir : & ' a Mir < ' tcx > ,
42
46
scope_tree : Rc < region:: ScopeTree > ,
43
47
root_scope : Option < region:: Scope > ,
48
+
49
+ /// The fundamental map relating bitvector indexes to the borrows
50
+ /// in the MIR.
44
51
borrows : IndexVec < BorrowIndex , BorrowData < ' tcx > > ,
52
+
53
+ /// Each borrow is also uniquely identified in the MIR by the
54
+ /// `Location` of the assignment statement in which it appears on
55
+ /// the right hand side; we map each such location to the
56
+ /// corresponding `BorrowIndex`.
45
57
location_map : FxHashMap < Location , BorrowIndex > ,
58
+
59
+ /// Every borrow in MIR is immediately stored into a place via an
60
+ /// assignment statement. This maps each such assigned place back
61
+ /// to its borrow-indexes.
46
62
assigned_map : FxHashMap < Place < ' tcx > , FxHashSet < BorrowIndex > > ,
63
+
64
+ /// Every borrow has a region; this maps each such regions back to
65
+ /// its borrow-indexes.
47
66
region_map : FxHashMap < Region < ' tcx > , FxHashSet < BorrowIndex > > ,
48
67
local_map : FxHashMap < mir:: Local , FxHashSet < BorrowIndex > > ,
49
68
region_span_map : FxHashMap < RegionKind , Span > ,
0 commit comments