From f6741d0a7a434ea108e2f26b7e50e028f1302604 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 6 Dec 2017 17:13:39 -0500 Subject: [PATCH] region_infer/values.rs: rustfmt --- .../borrow_check/nll/region_infer/values.rs | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/region_infer/values.rs b/src/librustc_mir/borrow_check/nll/region_infer/values.rs index 5f23a0e5790..b1397c23988 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/values.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/values.rs @@ -27,18 +27,23 @@ pub(super) struct RegionValueElements { impl RegionValueElements { pub(super) fn new(mir: &Mir<'_>, num_universal_regions: usize) -> Self { let mut num_points = 0; - let statements_before_block = - mir.basic_blocks() - .iter() - .map(|block_data| { - let v = num_points; - num_points += block_data.statements.len() + 1; - v - }) - .collect(); + let statements_before_block = mir.basic_blocks() + .iter() + .map(|block_data| { + let v = num_points; + num_points += block_data.statements.len() + 1; + v + }) + .collect(); - debug!("RegionValueElements(num_universal_regions={:?})", num_universal_regions); - debug!("RegionValueElements: statements_before_block={:#?}", statements_before_block); + debug!( + "RegionValueElements(num_universal_regions={:?})", + num_universal_regions + ); + debug!( + "RegionValueElements: statements_before_block={:#?}", + statements_before_block + ); debug!("RegionValueElements: num_points={:#?}", num_points); Self { @@ -60,7 +65,9 @@ impl RegionValueElements { /// Iterates over the `RegionElementIndex` for all points in the CFG. pub(super) fn all_point_indices<'a>(&'a self) -> impl Iterator + 'a { - (0..self.num_points).map(move |i| RegionElementIndex::new(i + self.num_universal_regions)) + (0..self.num_points).map(move |i| { + RegionElementIndex::new(i + self.num_universal_regions) + }) } /// Iterates over the `RegionElementIndex` for all points in the CFG. @@ -95,12 +102,11 @@ impl RegionValueElements { // be (BB2, 20). // // Nit: we could do a binary search here but I'm too lazy. - let (block, &first_index) = - self.statements_before_block - .iter_enumerated() - .filter(|(_, first_index)| **first_index <= point_index) - .last() - .unwrap(); + let (block, &first_index) = self.statements_before_block + .iter_enumerated() + .filter(|(_, first_index)| **first_index <= point_index) + .last() + .unwrap(); RegionElement::Location(Location { block, @@ -151,7 +157,10 @@ pub(super) trait ToElementIndex { impl ToElementIndex for Location { fn to_element_index(self, elements: &RegionValueElements) -> RegionElementIndex { - let Location { block, statement_index } = self; + let Location { + block, + statement_index, + } = self; let start_index = elements.statements_before_block[block]; RegionElementIndex::new(elements.num_universal_regions + start_index + statement_index) }