Skip to content

Commit

Permalink
Run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jul 1, 2018
1 parent 0957ede commit 71f25b4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 58 deletions.
52 changes: 20 additions & 32 deletions src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions src/librustc_mir/borrow_check/nll/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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<E: ToElementIndex>(
&mut self,
r: RegionVid,
elem: E,
) -> bool {
pub(super) fn add_element<E: ToElementIndex>(&mut self, r: RegionVid, elem: E) -> bool {
let i = self.elements.index(elem);
debug!("add(r={:?}, elem={:?})", r, elem);
self.matrix.add(r, i)
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/borrow_check/nll/type_check/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}

Expand Down
30 changes: 14 additions & 16 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 71f25b4

Please sign in to comment.