Skip to content

Commit e7ab33e

Browse files
committed
type_check/mod.rs: rustfmt
1 parent a0a3b4c commit e7ab33e

File tree

1 file changed

+29
-40
lines changed
  • src/librustc_mir/borrow_check/nll/type_check

1 file changed

+29
-40
lines changed

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -753,10 +753,8 @@ crate struct MirTypeckRegionConstraints<'tcx> {
753753

754754
crate outlives_constraints: ConstraintSet,
755755

756-
crate closure_bounds_mapping: FxHashMap<
757-
Location,
758-
FxHashMap<(RegionVid, RegionVid), (ConstraintCategory, Span)>,
759-
>,
756+
crate closure_bounds_mapping:
757+
FxHashMap<Location, FxHashMap<(RegionVid, RegionVid), (ConstraintCategory, Span)>>,
760758

761759
crate type_tests: Vec<TypeTest<'tcx>>,
762760
}
@@ -866,7 +864,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
866864
&mut self,
867865
locations: Locations,
868866
category: ConstraintCategory,
869-
op: impl type_op::TypeOp<'gcx, 'tcx, Output=R>,
867+
op: impl type_op::TypeOp<'gcx, 'tcx, Output = R>,
870868
) -> Fallible<R> {
871869
let (r, opt_data) = op.fully_perform(self.infcx)?;
872870

@@ -979,11 +977,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
979977
category,
980978
self.borrowck_context.as_mut().map(|x| &mut **x),
981979
)?;
982-
self.prove_predicate(
983-
ty::Predicate::WellFormed(ty),
984-
locations,
985-
category,
986-
);
980+
self.prove_predicate(ty::Predicate::WellFormed(ty), locations, category);
987981
Ok(())
988982
}
989983

@@ -1115,17 +1109,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
11151109
let place_ty = place.ty(mir, tcx).to_ty(tcx);
11161110
let rv_ty = rv.ty(mir, tcx);
11171111
if let Err(terr) =
1118-
self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category)
1119-
{
1120-
span_mirbug!(
1112+
self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category)
1113+
{
1114+
span_mirbug!(
11211115
self,
11221116
stmt,
11231117
"bad assignment ({:?} = {:?}): {:?}",
11241118
place_ty,
11251119
rv_ty,
11261120
terr
11271121
);
1128-
}
1122+
}
11291123

11301124
if let Some(user_ty) = self.rvalue_user_ty(rv) {
11311125
if let Err(terr) = self.relate_type_and_user_type(
@@ -1245,17 +1239,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
12451239

12461240
let locations = term_location.to_locations();
12471241
if let Err(terr) =
1248-
self.sub_types(rv_ty, place_ty, locations, ConstraintCategory::Assignment)
1249-
{
1250-
span_mirbug!(
1242+
self.sub_types(rv_ty, place_ty, locations, ConstraintCategory::Assignment)
1243+
{
1244+
span_mirbug!(
12511245
self,
12521246
term,
12531247
"bad DropAndReplace ({:?} = {:?}): {:?}",
12541248
place_ty,
12551249
rv_ty,
12561250
terr
12571251
);
1258-
}
1252+
}
12591253
}
12601254
TerminatorKind::SwitchInt {
12611255
ref discr,
@@ -1399,17 +1393,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
13991393
let locations = term_location.to_locations();
14001394

14011395
if let Err(terr) =
1402-
self.sub_types_or_anon(sig.output(), dest_ty, locations, category)
1403-
{
1404-
span_mirbug!(
1396+
self.sub_types_or_anon(sig.output(), dest_ty, locations, category)
1397+
{
1398+
span_mirbug!(
14051399
self,
14061400
term,
14071401
"call dest mismatch ({:?} <- {:?}): {:?}",
14081402
dest_ty,
14091403
sig.output(),
14101404
terr
14111405
);
1412-
}
1406+
}
14131407

14141408
// When `#![feature(unsized_locals)]` is not enabled,
14151409
// this check is done at `check_local`.
@@ -2050,7 +2044,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
20502044
aggregate_kind, location
20512045
);
20522046

2053-
let instantiated_predicates = match aggregate_kind {
2047+
let instantiated_predicates = match aggregate_kind {
20542048
AggregateKind::Adt(def, _, substs, _, _) => {
20552049
tcx.predicates_of(def.did).instantiate(tcx, substs)
20562050
}
@@ -2096,15 +2090,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
20962090
substs: &'tcx Substs<'tcx>,
20972091
location: Location,
20982092
) -> ty::InstantiatedPredicates<'tcx> {
2099-
if let Some(closure_region_requirements) =
2100-
tcx.mir_borrowck(def_id).closure_requirements
2101-
{
2102-
let closure_constraints = closure_region_requirements.apply_requirements(
2103-
tcx,
2104-
location,
2105-
def_id,
2106-
substs,
2107-
);
2093+
if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements {
2094+
let closure_constraints =
2095+
closure_region_requirements.apply_requirements(tcx, location, def_id, substs);
21082096

21092097
if let Some(ref mut borrowck_context) = self.borrowck_context {
21102098
let bounds_mapping = closure_constraints
@@ -2113,19 +2101,16 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
21132101
.filter_map(|(idx, constraint)| {
21142102
let ty::OutlivesPredicate(k1, r2) =
21152103
constraint.no_late_bound_regions().unwrap_or_else(|| {
2116-
bug!(
2117-
"query_constraint {:?} contained bound regions",
2118-
constraint,
2119-
);
2104+
bug!("query_constraint {:?} contained bound regions", constraint,);
21202105
});
21212106

21222107
match k1.unpack() {
21232108
UnpackedKind::Lifetime(r1) => {
21242109
// constraint is r1: r2
21252110
let r1_vid = borrowck_context.universal_regions.to_region_vid(r1);
21262111
let r2_vid = borrowck_context.universal_regions.to_region_vid(r2);
2127-
let outlives_requirements = &closure_region_requirements
2128-
.outlives_requirements[idx];
2112+
let outlives_requirements =
2113+
&closure_region_requirements.outlives_requirements[idx];
21292114
Some((
21302115
(r1_vid, r2_vid),
21312116
(
@@ -2139,10 +2124,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
21392124
})
21402125
.collect();
21412126

2142-
let existing = borrowck_context.constraints
2127+
let existing = borrowck_context
2128+
.constraints
21432129
.closure_bounds_mapping
21442130
.insert(location, bounds_mapping);
2145-
assert!(existing.is_none(), "Multiple closures at the same location.");
2131+
assert!(
2132+
existing.is_none(),
2133+
"Multiple closures at the same location."
2134+
);
21462135
}
21472136

21482137
self.push_region_constraints(

0 commit comments

Comments
 (0)