about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2017-12-13 01:06:39 -0600
committerFelix S. Klock II <pnkfelix@pnkfx.org>2017-12-13 15:48:20 -0600
commit1334638144d660822e02f087b6168356375e92ac (patch)
treef4145875ea3b050046375c00ec30f6792836ad65
parent658ed797003ff392e42e9f29e99905d8558b36f0 (diff)
downloadrust-1334638144d660822e02f087b6168356375e92ac.tar.gz
rust-1334638144d660822e02f087b6168356375e92ac.zip
Add some doc to `struct Borrows`.
-rw-r--r--src/librustc_mir/dataflow/impls/borrows.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs
index abfc3159cff..4c36deae101 100644
--- a/src/librustc_mir/dataflow/impls/borrows.rs
+++ b/src/librustc_mir/dataflow/impls/borrows.rs
@@ -33,17 +33,36 @@ use std::fmt;
 use std::hash::Hash;
 use std::rc::Rc;
 
-// `Borrows` maps each dataflow bit to an `Rvalue::Ref`, which can be
-// uniquely identified in the MIR by the `Location` of the assigment
-// statement in which it appears on the right hand side.
+/// `Borrows` stores the data used in the analyses that track the flow
+/// of borrows.
+///
+/// It uniquely identifies every borrow (`Rvalue::Ref`) by a
+/// `BorrowIndex`, and maps each such index to a `BorrowData`
+/// describing the borrow. These indexes are used for representing the
+/// borrows in compact bitvectors.
 pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'gcx, 'tcx>,
     mir: &'a Mir<'tcx>,
     scope_tree: Rc<region::ScopeTree>,
     root_scope: Option<region::Scope>,
+
+    /// The fundamental map relating bitvector indexes to the borrows
+    /// in the MIR.
     borrows: IndexVec<BorrowIndex, BorrowData<'tcx>>,
+
+    /// Each borrow is also uniquely identified in the MIR by the
+    /// `Location` of the assignment statement in which it appears on
+    /// the right hand side; we map each such location to the
+    /// corresponding `BorrowIndex`.
     location_map: FxHashMap<Location, BorrowIndex>,
+
+    /// Every borrow in MIR is immediately stored into a place via an
+    /// assignment statement. This maps each such assigned place back
+    /// to its borrow-indexes.
     assigned_map: FxHashMap<Place<'tcx>, FxHashSet<BorrowIndex>>,
+
+    /// Every borrow has a region; this maps each such regions back to
+    /// its borrow-indexes.
     region_map: FxHashMap<Region<'tcx>, FxHashSet<BorrowIndex>>,
     local_map: FxHashMap<mir::Local, FxHashSet<BorrowIndex>>,
     region_span_map: FxHashMap<RegionKind, Span>,