@@ -178,97 +178,15 @@ pub(crate) fn type_check<'mir, 'tcx>(
178
178
upvars,
179
179
} ;
180
180
181
- let opaque_type_values = type_check_internal (
181
+ let mut checker = TypeChecker :: new (
182
182
infcx,
183
- param_env,
184
183
body,
185
- promoted ,
184
+ param_env ,
186
185
& region_bound_pairs,
187
186
implicit_region_bound,
188
187
& mut borrowck_context,
189
- |mut cx| {
190
- debug ! ( "inside extra closure of type_check_internal" ) ;
191
- cx. equate_inputs_and_outputs ( & body, universal_regions, & normalized_inputs_and_output) ;
192
- liveness:: generate (
193
- & mut cx,
194
- body,
195
- elements,
196
- flow_inits,
197
- move_data,
198
- location_table,
199
- use_polonius,
200
- ) ;
201
-
202
- translate_outlives_facts ( & mut cx) ;
203
- let opaque_type_values =
204
- infcx. inner . borrow_mut ( ) . opaque_type_storage . take_opaque_types ( ) ;
205
-
206
- opaque_type_values
207
- . into_iter ( )
208
- . map ( |( opaque_type_key, decl) | {
209
- cx. fully_perform_op (
210
- Locations :: All ( body. span ) ,
211
- ConstraintCategory :: OpaqueType ,
212
- CustomTypeOp :: new (
213
- |infcx| {
214
- infcx. register_member_constraints (
215
- param_env,
216
- opaque_type_key,
217
- decl. hidden_type . ty ,
218
- decl. hidden_type . span ,
219
- ) ;
220
- Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } )
221
- } ,
222
- || "opaque_type_map" . to_string ( ) ,
223
- ) ,
224
- )
225
- . unwrap ( ) ;
226
- let mut hidden_type = infcx. resolve_vars_if_possible ( decl. hidden_type ) ;
227
- trace ! (
228
- "finalized opaque type {:?} to {:#?}" ,
229
- opaque_type_key,
230
- hidden_type. ty. kind( )
231
- ) ;
232
- if hidden_type. has_infer_types_or_consts ( ) {
233
- infcx. tcx . sess . delay_span_bug (
234
- decl. hidden_type . span ,
235
- & format ! ( "could not resolve {:#?}" , hidden_type. ty. kind( ) ) ,
236
- ) ;
237
- hidden_type. ty = infcx. tcx . ty_error ( ) ;
238
- }
239
-
240
- ( opaque_type_key, ( hidden_type, decl. origin ) )
241
- } )
242
- . collect ( )
243
- } ,
244
188
) ;
245
189
246
- MirTypeckResults { constraints, universal_region_relations, opaque_type_values }
247
- }
248
-
249
- #[ instrument(
250
- skip( infcx, body, promoted, region_bound_pairs, borrowck_context, extra) ,
251
- level = "debug"
252
- ) ]
253
- fn type_check_internal < ' a , ' tcx , R > (
254
- infcx : & ' a InferCtxt < ' a , ' tcx > ,
255
- param_env : ty:: ParamEnv < ' tcx > ,
256
- body : & ' a Body < ' tcx > ,
257
- promoted : & ' a IndexVec < Promoted , Body < ' tcx > > ,
258
- region_bound_pairs : & ' a RegionBoundPairs < ' tcx > ,
259
- implicit_region_bound : ty:: Region < ' tcx > ,
260
- borrowck_context : & ' a mut BorrowCheckContext < ' a , ' tcx > ,
261
- extra : impl FnOnce ( TypeChecker < ' a , ' tcx > ) -> R ,
262
- ) -> R {
263
- debug ! ( "body: {:#?}" , body) ;
264
- let mut checker = TypeChecker :: new (
265
- infcx,
266
- body,
267
- param_env,
268
- region_bound_pairs,
269
- implicit_region_bound,
270
- borrowck_context,
271
- ) ;
272
190
let errors_reported = {
273
191
let mut verifier = TypeVerifier :: new ( & mut checker, promoted) ;
274
192
verifier. visit_body ( & body) ;
@@ -280,7 +198,56 @@ fn type_check_internal<'a, 'tcx, R>(
280
198
checker. typeck_mir ( body) ;
281
199
}
282
200
283
- extra ( checker)
201
+ checker. equate_inputs_and_outputs ( & body, universal_regions, & normalized_inputs_and_output) ;
202
+ liveness:: generate (
203
+ & mut checker,
204
+ body,
205
+ elements,
206
+ flow_inits,
207
+ move_data,
208
+ location_table,
209
+ use_polonius,
210
+ ) ;
211
+
212
+ translate_outlives_facts ( & mut checker) ;
213
+ let opaque_type_values = infcx. inner . borrow_mut ( ) . opaque_type_storage . take_opaque_types ( ) ;
214
+
215
+ let opaque_type_values = opaque_type_values
216
+ . into_iter ( )
217
+ . map ( |( opaque_type_key, decl) | {
218
+ checker
219
+ . fully_perform_op (
220
+ Locations :: All ( body. span ) ,
221
+ ConstraintCategory :: OpaqueType ,
222
+ CustomTypeOp :: new (
223
+ |infcx| {
224
+ infcx. register_member_constraints (
225
+ param_env,
226
+ opaque_type_key,
227
+ decl. hidden_type . ty ,
228
+ decl. hidden_type . span ,
229
+ ) ;
230
+ Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } )
231
+ } ,
232
+ || "opaque_type_map" . to_string ( ) ,
233
+ ) ,
234
+ )
235
+ . unwrap ( ) ;
236
+ let mut hidden_type = infcx. resolve_vars_if_possible ( decl. hidden_type ) ;
237
+ trace ! ( "finalized opaque type {:?} to {:#?}" , opaque_type_key, hidden_type. ty. kind( ) ) ;
238
+ if hidden_type. has_infer_types_or_consts ( ) {
239
+ infcx. tcx . sess . delay_span_bug (
240
+ decl. hidden_type . span ,
241
+ & format ! ( "could not resolve {:#?}" , hidden_type. ty. kind( ) ) ,
242
+ ) ;
243
+ hidden_type. ty = infcx. tcx . ty_error ( ) ;
244
+ }
245
+
246
+ ( opaque_type_key, ( hidden_type, decl. origin ) )
247
+ } )
248
+ . collect ( ) ;
249
+
250
+ MirTypeckResults { constraints, universal_region_relations, opaque_type_values }
284
251
}
285
252
286
253
fn translate_outlives_facts ( typeck : & mut TypeChecker < ' _ , ' _ > ) {
@@ -1911,7 +1878,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1911
1878
}
1912
1879
}
1913
1880
1914
- & Rvalue :: NullaryOp ( _ , ty) => {
1881
+ & Rvalue :: NullaryOp ( NullOp :: SizeOf | NullOp :: AlignOf , ty) => {
1915
1882
let trait_ref = ty:: TraitRef {
1916
1883
def_id : tcx. require_lang_item ( LangItem :: Sized , Some ( self . last_span ) ) ,
1917
1884
substs : tcx. mk_substs_trait ( ty, & [ ] ) ,
0 commit comments