]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/borrow_check/location.rs
Auto merge of #69076 - cjgillot:split_trait, r=matthewjasper
[rust.git] / src / librustc_mir / borrow_check / location.rs
index 9e94317b87e5493789b563d5d9ad9dd0ffa0a85c..7bc746b181d818a54b101b4db78df57217bbb062 100644 (file)
@@ -1,4 +1,4 @@
-use rustc::mir::{BasicBlock, Location, Body};
+use rustc::mir::{BasicBlock, Body, Location};
 use rustc_index::vec::{Idx, IndexVec};
 
 /// Maps between a MIR Location, which identifies a particular
@@ -32,7 +32,8 @@ pub struct LocationIndex {
 impl LocationTable {
     crate fn new(body: &Body<'_>) -> Self {
         let mut num_points = 0;
-        let statements_before_block = body.basic_blocks()
+        let statements_before_block = body
+            .basic_blocks()
             .iter()
             .map(|block_data| {
                 let v = num_points;
@@ -41,16 +42,10 @@ impl LocationTable {
             })
             .collect();
 
-        debug!(
-            "LocationTable(statements_before_block={:#?})",
-            statements_before_block
-        );
+        debug!("LocationTable(statements_before_block={:#?})", statements_before_block);
         debug!("LocationTable: num_points={:#?}", num_points);
 
-        Self {
-            num_points,
-            statements_before_block,
-        }
+        Self { num_points, statements_before_block }
     }
 
     crate fn all_points(&self) -> impl Iterator<Item = LocationIndex> {
@@ -58,19 +53,13 @@ impl LocationTable {
     }
 
     crate fn start_index(&self, location: Location) -> LocationIndex {
-        let Location {
-            block,
-            statement_index,
-        } = location;
+        let Location { block, statement_index } = location;
         let start_index = self.statements_before_block[block];
         LocationIndex::new(start_index + statement_index * 2)
     }
 
     crate fn mid_index(&self, location: Location) -> LocationIndex {
-        let Location {
-            block,
-            statement_index,
-        } = location;
+        let Location { block, statement_index } = location;
         let start_index = self.statements_before_block[block];
         LocationIndex::new(start_index + statement_index * 2 + 1)
     }
@@ -94,7 +83,8 @@ impl LocationTable {
         // the last point where the "first index" (0, 10, or 20)
         // was less than the statement index (22). In our case, this will
         // be (BB2, 20).
-        let (block, &first_index) = self.statements_before_block
+        let (block, &first_index) = self
+            .statements_before_block
             .iter_enumerated()
             .filter(|(_, first_index)| **first_index <= point_index)
             .last()