Skip to content

Commit 1334638

Browse files
committed
Add some doc to struct Borrows.
1 parent 658ed79 commit 1334638

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/librustc_mir/dataflow/impls/borrows.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,36 @@ use std::fmt;
3333
use std::hash::Hash;
3434
use std::rc::Rc;
3535

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.
3943
pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
4044
tcx: TyCtxt<'a, 'gcx, 'tcx>,
4145
mir: &'a Mir<'tcx>,
4246
scope_tree: Rc<region::ScopeTree>,
4347
root_scope: Option<region::Scope>,
48+
49+
/// The fundamental map relating bitvector indexes to the borrows
50+
/// in the MIR.
4451
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`.
4557
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.
4662
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.
4766
region_map: FxHashMap<Region<'tcx>, FxHashSet<BorrowIndex>>,
4867
local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
4968
region_span_map: FxHashMap<RegionKind, Span>,

0 commit comments

Comments
 (0)