X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_mir%2Fborrow_check%2Flocation.rs;h=7bc746b181d818a54b101b4db78df57217bbb062;hb=131772c5e0ba40cd656dedb5e1990d36e3ea31cf;hp=cc44dc3f5d46bd34be686d7bcea9a36281710d7e;hpb=9eb88f3b821ec5ca276e2f5d5c4f41dc3e9f0e87;p=rust.git diff --git a/src/librustc_mir/borrow_check/location.rs b/src/librustc_mir/borrow_check/location.rs index cc44dc3f5d4..7bc746b181d 100644 --- a/src/librustc_mir/borrow_check/location.rs +++ b/src/librustc_mir/borrow_check/location.rs @@ -1,5 +1,5 @@ -use rustc::mir::{BasicBlock, Location, Body}; -use rustc_data_structures::indexed_vec::{Idx, IndexVec}; +use rustc::mir::{BasicBlock, Body, Location}; +use rustc_index::vec::{Idx, IndexVec}; /// Maps between a MIR Location, which identifies a particular /// statement within a basic block, to a "rich location", which @@ -17,7 +17,7 @@ statements_before_block: IndexVec, } -newtype_index! { +rustc_index::newtype_index! { pub struct LocationIndex { DEBUG_FORMAT = "LocationIndex({})" } @@ -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 { @@ -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()