diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index fd6d79d160e..13cc0c0419e 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -19,7 +19,7 @@ use rustc::infer::NLLRegionVariableOrigin; use rustc::infer::RegionVariableOrigin; use rustc::mir::{ ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements, Local, Location, - Mir + Mir, }; use rustc::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable}; use rustc::util::common; @@ -271,17 +271,11 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Add all nodes in the CFG to liveness constraints for point_index in self.elements.all_point_indices() { - self.liveness_constraints.add_element( - variable, - point_index, - ); + self.liveness_constraints.add_element(variable, point_index); } // Add `end(X)` into the set for X. - self.liveness_constraints.add_element( - variable, - variable, - ); + self.liveness_constraints.add_element(variable, variable); } } @@ -335,12 +329,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Indicates that the region variable `sup` must outlive `sub` is live at the point `point`. - pub(super) fn add_outlives( - &mut self, - locations: Locations, - sup: RegionVid, - sub: RegionVid, - ) { + pub(super) fn add_outlives(&mut self, locations: Locations, sup: RegionVid, sub: RegionVid) { assert!(self.inferred_values.is_none(), "values already inferred"); self.constraints.push(OutlivesConstraint { locations, @@ -445,11 +434,14 @@ impl<'tcx> RegionInferenceContext<'tcx> { debug!("propagate_constraints: sub={:?}", constraint.sub); debug!("propagate_constraints: sup={:?}", constraint.sup); - self.constraints.each_affected_by_dirty(dependency_map[constraint.sup], |dep_idx| { - if clean_bit_vec.remove(dep_idx.index()) { - dirty_list.push(dep_idx); - } - }); + self.constraints.each_affected_by_dirty( + dependency_map[constraint.sup], + |dep_idx| { + if clean_bit_vec.remove(dep_idx.index()) { + dirty_list.push(dep_idx); + } + }, + ); } debug!("\n"); @@ -487,8 +479,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { } if let Some(propagated_outlives_requirements) = &mut propagated_outlives_requirements { - if self.try_promote_type_test(infcx, mir, type_test, - propagated_outlives_requirements) { + if self.try_promote_type_test( + infcx, + mir, + type_test, + propagated_outlives_requirements, + ) { continue; } } @@ -744,12 +740,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// Test if `test` is true when applied to `lower_bound` at /// `point`, and returns true or false. - fn eval_region_test( - &self, - mir: &Mir<'tcx>, - lower_bound: RegionVid, - test: &RegionTest, - ) -> bool { + fn eval_region_test(&self, mir: &Mir<'tcx>, lower_bound: RegionVid, test: &RegionTest) -> bool { debug!( "eval_region_test(lower_bound={:?}, test={:?})", lower_bound, test @@ -781,10 +772,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { sup_region: RegionVid, sub_region: RegionVid, ) -> bool { - debug!( - "eval_outlives({:?}: {:?})", - sup_region, sub_region - ); + debug!("eval_outlives({:?}: {:?})", sup_region, sub_region); let inferred_values = self .inferred_values 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 5be4297f660..1039e6d7b97 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/values.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/values.rs @@ -28,7 +28,8 @@ 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() + let statements_before_block = mir + .basic_blocks() .iter() .map(|block_data| { let v = num_points; @@ -96,7 +97,8 @@ 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 + let (block, &first_index) = self + .statements_before_block .iter_enumerated() .filter(|(_, first_index)| **first_index <= point_index) .last() @@ -203,11 +205,7 @@ impl RegionValues { /// Adds the given element to the value for the given region. Returns true if /// the element is newly added (i.e., was not already present). - pub(super) fn add_element( - &mut self, - r: RegionVid, - elem: E, - ) -> bool { + pub(super) fn add_element(&mut self, r: RegionVid, elem: E) -> bool { let i = self.elements.index(elem); debug!("add(r={:?}, elem={:?})", r, elem); self.matrix.add(r, i) diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index dbdfef21970..91025e3f4af 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -168,9 +168,7 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo ); cx.tcx().for_each_free_region(&value, |live_region| { - cx.constraints - .liveness_set - .push((live_region, location)); + cx.constraints.liveness_set.push((live_region, location)); }); } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index d5cf55c0f77..2b47d50b4c2 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -311,7 +311,10 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { debug!("sanitize_constant: expected_ty={:?}", expected_ty); - if let Err(terr) = self.cx.eq_types(expected_ty, constant.ty, location.boring()) { + if let Err(terr) = self + .cx + .eq_types(expected_ty, constant.ty, location.boring()) + { span_mirbug!( self, constant, @@ -770,12 +773,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } - fn sub_types( - &mut self, - sub: Ty<'tcx>, - sup: Ty<'tcx>, - locations: Locations, - ) -> Fallible<()> { + fn sub_types(&mut self, sub: Ty<'tcx>, sup: Ty<'tcx>, locations: Locations) -> Fallible<()> { let param_env = self.param_env; self.fully_perform_op( locations, @@ -807,7 +805,11 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { false }; - let locations = if is_temp { location.boring() } else { location.interesting() }; + let locations = if is_temp { + location.boring() + } else { + location.interesting() + }; let place_ty = place.ty(mir, tcx).to_ty(tcx); let rv_ty = rv.ty(mir, tcx); @@ -982,10 +984,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { // output) types in the signature must be live, since // all the inputs that fed into it were live. for &late_bound_region in map.values() { - self.constraints.liveness_set.push(( - late_bound_region, - term_location, - )); + self.constraints + .liveness_set + .push((late_bound_region, term_location)); } self.check_call_inputs(mir, term, &sig, args, term_location); @@ -1505,10 +1506,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { ); // Hmm, are these constraints *really* boring? - self.push_region_constraints( - location.boring(), - &closure_constraints, - ); + self.push_region_constraints(location.boring(), &closure_constraints); } tcx.predicates_of(*def_id).instantiate(tcx, substs.substs)