@@ -753,10 +753,8 @@ crate struct MirTypeckRegionConstraints<'tcx> {
753
753
754
754
crate outlives_constraints : ConstraintSet ,
755
755
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 ) > > ,
760
758
761
759
crate type_tests : Vec < TypeTest < ' tcx > > ,
762
760
}
@@ -866,7 +864,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
866
864
& mut self ,
867
865
locations : Locations ,
868
866
category : ConstraintCategory ,
869
- op : impl type_op:: TypeOp < ' gcx , ' tcx , Output = R > ,
867
+ op : impl type_op:: TypeOp < ' gcx , ' tcx , Output = R > ,
870
868
) -> Fallible < R > {
871
869
let ( r, opt_data) = op. fully_perform ( self . infcx ) ?;
872
870
@@ -979,11 +977,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
979
977
category,
980
978
self . borrowck_context . as_mut ( ) . map ( |x| & mut * * x) ,
981
979
) ?;
982
- self . prove_predicate (
983
- ty:: Predicate :: WellFormed ( ty) ,
984
- locations,
985
- category,
986
- ) ;
980
+ self . prove_predicate ( ty:: Predicate :: WellFormed ( ty) , locations, category) ;
987
981
Ok ( ( ) )
988
982
}
989
983
@@ -1115,17 +1109,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1115
1109
let place_ty = place. ty ( mir, tcx) . to_ty ( tcx) ;
1116
1110
let rv_ty = rv. ty ( mir, tcx) ;
1117
1111
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 ! (
1121
1115
self ,
1122
1116
stmt,
1123
1117
"bad assignment ({:?} = {:?}): {:?}" ,
1124
1118
place_ty,
1125
1119
rv_ty,
1126
1120
terr
1127
1121
) ;
1128
- }
1122
+ }
1129
1123
1130
1124
if let Some ( user_ty) = self . rvalue_user_ty ( rv) {
1131
1125
if let Err ( terr) = self . relate_type_and_user_type (
@@ -1245,17 +1239,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1245
1239
1246
1240
let locations = term_location. to_locations ( ) ;
1247
1241
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 ! (
1251
1245
self ,
1252
1246
term,
1253
1247
"bad DropAndReplace ({:?} = {:?}): {:?}" ,
1254
1248
place_ty,
1255
1249
rv_ty,
1256
1250
terr
1257
1251
) ;
1258
- }
1252
+ }
1259
1253
}
1260
1254
TerminatorKind :: SwitchInt {
1261
1255
ref discr,
@@ -1399,17 +1393,17 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
1399
1393
let locations = term_location. to_locations ( ) ;
1400
1394
1401
1395
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 ! (
1405
1399
self ,
1406
1400
term,
1407
1401
"call dest mismatch ({:?} <- {:?}): {:?}" ,
1408
1402
dest_ty,
1409
1403
sig. output( ) ,
1410
1404
terr
1411
1405
) ;
1412
- }
1406
+ }
1413
1407
1414
1408
// When `#![feature(unsized_locals)]` is not enabled,
1415
1409
// this check is done at `check_local`.
@@ -2050,7 +2044,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
2050
2044
aggregate_kind, location
2051
2045
) ;
2052
2046
2053
- let instantiated_predicates = match aggregate_kind {
2047
+ let instantiated_predicates = match aggregate_kind {
2054
2048
AggregateKind :: Adt ( def, _, substs, _, _) => {
2055
2049
tcx. predicates_of ( def. did ) . instantiate ( tcx, substs)
2056
2050
}
@@ -2096,15 +2090,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
2096
2090
substs : & ' tcx Substs < ' tcx > ,
2097
2091
location : Location ,
2098
2092
) -> 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) ;
2108
2096
2109
2097
if let Some ( ref mut borrowck_context) = self . borrowck_context {
2110
2098
let bounds_mapping = closure_constraints
@@ -2113,19 +2101,16 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
2113
2101
. filter_map ( |( idx, constraint) | {
2114
2102
let ty:: OutlivesPredicate ( k1, r2) =
2115
2103
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, ) ;
2120
2105
} ) ;
2121
2106
2122
2107
match k1. unpack ( ) {
2123
2108
UnpackedKind :: Lifetime ( r1) => {
2124
2109
// constraint is r1: r2
2125
2110
let r1_vid = borrowck_context. universal_regions . to_region_vid ( r1) ;
2126
2111
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] ;
2129
2114
Some ( (
2130
2115
( r1_vid, r2_vid) ,
2131
2116
(
@@ -2139,10 +2124,14 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
2139
2124
} )
2140
2125
. collect ( ) ;
2141
2126
2142
- let existing = borrowck_context. constraints
2127
+ let existing = borrowck_context
2128
+ . constraints
2143
2129
. closure_bounds_mapping
2144
2130
. 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
+ ) ;
2146
2135
}
2147
2136
2148
2137
self . push_region_constraints (
0 commit comments