@@ -106,7 +106,6 @@ mod relate_tys;
106106/// # Parameters
107107///
108108/// - `infcx` -- inference context to use
109- /// - `param_env` -- parameter environment to use for trait solving
110109/// - `body` -- MIR body to type-check
111110/// - `promoted` -- map of promoted constants within `body`
112111/// - `universal_regions` -- the universal regions from `body`s function signature
@@ -154,7 +153,7 @@ pub(crate) fn type_check<'a, 'tcx>(
154153
155154 debug ! ( ?normalized_inputs_and_output) ;
156155
157- let mut checker = TypeChecker {
156+ let mut typeck = TypeChecker {
158157 infcx,
159158 last_span : body. span ,
160159 body,
@@ -170,23 +169,22 @@ pub(crate) fn type_check<'a, 'tcx>(
170169 constraints : & mut constraints,
171170 } ;
172171
173- checker . check_user_type_annotations ( ) ;
172+ typeck . check_user_type_annotations ( ) ;
174173
175- let mut verifier = TypeVerifier { cx : & mut checker , promoted, last_span : body. span } ;
174+ let mut verifier = TypeVerifier { typeck : & mut typeck , promoted, last_span : body. span } ;
176175 verifier. visit_body ( body) ;
177176
178- checker . typeck_mir ( body) ;
179- checker . equate_inputs_and_outputs ( body, & normalized_inputs_and_output) ;
180- checker . check_signature_annotation ( body) ;
177+ typeck . typeck_mir ( body) ;
178+ typeck . equate_inputs_and_outputs ( body, & normalized_inputs_and_output) ;
179+ typeck . check_signature_annotation ( body) ;
181180
182- liveness:: generate ( & mut checker , body, & elements, flow_inits, move_data) ;
181+ liveness:: generate ( & mut typeck , body, & elements, flow_inits, move_data) ;
183182
184- let opaque_type_values = infcx. take_opaque_types ( ) ;
185-
186- let opaque_type_values = opaque_type_values
183+ let opaque_type_values = infcx
184+ . take_opaque_types ( )
187185 . into_iter ( )
188186 . map ( |( opaque_type_key, decl) | {
189- let _: Result < _ , ErrorGuaranteed > = checker . fully_perform_op (
187+ let _: Result < _ , ErrorGuaranteed > = typeck . fully_perform_op (
190188 Locations :: All ( body. span ) ,
191189 ConstraintCategory :: OpaqueType ,
192190 CustomTypeOp :: new (
@@ -216,11 +214,11 @@ pub(crate) fn type_check<'a, 'tcx>(
216214 match region. kind ( ) {
217215 ty:: ReVar ( _) => region,
218216 ty:: RePlaceholder ( placeholder) => {
219- checker . constraints . placeholder_region ( infcx, placeholder)
217+ typeck . constraints . placeholder_region ( infcx, placeholder)
220218 }
221219 _ => ty:: Region :: new_var (
222220 infcx. tcx ,
223- checker . universal_regions . to_region_vid ( region) ,
221+ typeck . universal_regions . to_region_vid ( region) ,
224222 ) ,
225223 }
226224 } ) ;
@@ -250,7 +248,7 @@ enum FieldAccessError {
250248/// type, calling `span_mirbug` and returning an error type if there
251249/// is a problem.
252250struct TypeVerifier < ' a , ' b , ' tcx > {
253- cx : & ' a mut TypeChecker < ' b , ' tcx > ,
251+ typeck : & ' a mut TypeChecker < ' b , ' tcx > ,
254252 promoted : & ' b IndexSlice < Promoted , Body < ' tcx > > ,
255253 last_span : Span ,
256254}
@@ -272,9 +270,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
272270 self . super_const_operand ( constant, location) ;
273271 let ty = self . sanitize_type ( constant, constant. const_ . ty ( ) ) ;
274272
275- self . cx . infcx . tcx . for_each_free_region ( & ty, |live_region| {
276- let live_region_vid = self . cx . universal_regions . to_region_vid ( live_region) ;
277- self . cx . constraints . liveness_constraints . add_location ( live_region_vid, location) ;
273+ self . typeck . infcx . tcx . for_each_free_region ( & ty, |live_region| {
274+ let live_region_vid = self . typeck . universal_regions . to_region_vid ( live_region) ;
275+ self . typeck . constraints . liveness_constraints . add_location ( live_region_vid, location) ;
278276 } ) ;
279277
280278 // HACK(compiler-errors): Constants that are gathered into Body.required_consts
@@ -286,14 +284,14 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
286284 } ;
287285
288286 if let Some ( annotation_index) = constant. user_ty {
289- if let Err ( terr) = self . cx . relate_type_and_user_type (
287+ if let Err ( terr) = self . typeck . relate_type_and_user_type (
290288 constant. const_ . ty ( ) ,
291289 ty:: Invariant ,
292290 & UserTypeProjection { base : annotation_index, projs : vec ! [ ] } ,
293291 locations,
294292 ConstraintCategory :: Boring ,
295293 ) {
296- let annotation = & self . cx . user_type_annotations [ annotation_index] ;
294+ let annotation = & self . typeck . user_type_annotations [ annotation_index] ;
297295 span_mirbug ! (
298296 self ,
299297 constant,
@@ -322,9 +320,12 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
322320 promoted : & Body < ' tcx > ,
323321 ty,
324322 san_ty| {
325- if let Err ( terr) =
326- verifier. cx . eq_types ( ty, san_ty, locations, ConstraintCategory :: Boring )
327- {
323+ if let Err ( terr) = verifier. typeck . eq_types (
324+ ty,
325+ san_ty,
326+ locations,
327+ ConstraintCategory :: Boring ,
328+ ) {
328329 span_mirbug ! (
329330 verifier,
330331 promoted,
@@ -342,21 +343,21 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
342343 let promoted_ty = promoted_body. return_ty ( ) ;
343344 check_err ( self , promoted_body, ty, promoted_ty) ;
344345 } else {
345- self . cx . ascribe_user_type (
346+ self . typeck . ascribe_user_type (
346347 constant. const_ . ty ( ) ,
347348 ty:: UserType :: new ( ty:: UserTypeKind :: TypeOf ( uv. def , UserArgs {
348349 args : uv. args ,
349350 user_self_ty : None ,
350351 } ) ) ,
351- locations. span ( self . cx . body ) ,
352+ locations. span ( self . typeck . body ) ,
352353 ) ;
353354 }
354355 } else if let Some ( static_def_id) = constant. check_static_ptr ( tcx) {
355356 let unnormalized_ty = tcx. type_of ( static_def_id) . instantiate_identity ( ) ;
356- let normalized_ty = self . cx . normalize ( unnormalized_ty, locations) ;
357+ let normalized_ty = self . typeck . normalize ( unnormalized_ty, locations) ;
357358 let literal_ty = constant. const_ . ty ( ) . builtin_deref ( true ) . unwrap ( ) ;
358359
359- if let Err ( terr) = self . cx . eq_types (
360+ if let Err ( terr) = self . typeck . eq_types (
360361 literal_ty,
361362 normalized_ty,
362363 locations,
@@ -368,7 +369,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
368369
369370 if let ty:: FnDef ( def_id, args) = * constant. const_ . ty ( ) . kind ( ) {
370371 let instantiated_predicates = tcx. predicates_of ( def_id) . instantiate ( tcx, args) ;
371- self . cx . normalize_and_prove_instantiated_predicates (
372+ self . typeck . normalize_and_prove_instantiated_predicates (
372373 def_id,
373374 instantiated_predicates,
374375 locations,
@@ -378,7 +379,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
378379 tcx. impl_of_method( def_id) . map( |imp| tcx. def_kind( imp) ) ,
379380 Some ( DefKind :: Impl { of_trait: true } )
380381 ) ) ;
381- self . cx . prove_predicates (
382+ self . typeck . prove_predicates (
382383 args. types ( ) . map ( |ty| ty:: ClauseKind :: WellFormed ( ty. into ( ) ) ) ,
383384 locations,
384385 ConstraintCategory :: Boring ,
@@ -412,7 +413,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
412413 local_decl. ty
413414 } ;
414415
415- if let Err ( terr) = self . cx . relate_type_and_user_type (
416+ if let Err ( terr) = self . typeck . relate_type_and_user_type (
416417 ty,
417418 ty:: Invariant ,
418419 user_ty,
@@ -442,11 +443,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
442443
443444impl < ' a , ' b , ' tcx > TypeVerifier < ' a , ' b , ' tcx > {
444445 fn body ( & self ) -> & Body < ' tcx > {
445- self . cx . body
446+ self . typeck . body
446447 }
447448
448449 fn tcx ( & self ) -> TyCtxt < ' tcx > {
449- self . cx . infcx . tcx
450+ self . typeck . infcx . tcx
450451 }
451452
452453 fn sanitize_type ( & mut self , parent : & dyn fmt:: Debug , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
@@ -496,7 +497,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
496497 // whether the bounds fully apply: in effect, the rule is
497498 // that if a value of some type could implement `Copy`, then
498499 // it must.
499- self . cx . prove_trait_ref (
500+ self . typeck . prove_trait_ref (
500501 trait_ref,
501502 location. to_locations ( ) ,
502503 ConstraintCategory :: CopyBound ,
@@ -511,7 +512,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
511512 // checker on the promoted MIR, then transfer the constraints back to
512513 // the main MIR, changing the locations to the provided location.
513514
514- let parent_body = mem:: replace ( & mut self . cx . body , promoted_body) ;
515+ let parent_body = mem:: replace ( & mut self . typeck . body , promoted_body) ;
515516
516517 // Use new sets of constraints and closure bounds so that we can
517518 // modify their locations.
@@ -522,18 +523,18 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
522523 // Don't try to add borrow_region facts for the promoted MIR
523524
524525 let mut swap_constraints = |this : & mut Self | {
525- mem:: swap ( this. cx . all_facts , all_facts) ;
526- mem:: swap ( & mut this. cx . constraints . outlives_constraints , & mut constraints) ;
527- mem:: swap ( & mut this. cx . constraints . liveness_constraints , & mut liveness_constraints) ;
526+ mem:: swap ( this. typeck . all_facts , all_facts) ;
527+ mem:: swap ( & mut this. typeck . constraints . outlives_constraints , & mut constraints) ;
528+ mem:: swap ( & mut this. typeck . constraints . liveness_constraints , & mut liveness_constraints) ;
528529 } ;
529530
530531 swap_constraints ( self ) ;
531532
532533 self . visit_body ( promoted_body) ;
533534
534- self . cx . typeck_mir ( promoted_body) ;
535+ self . typeck . typeck_mir ( promoted_body) ;
535536
536- self . cx . body = parent_body;
537+ self . typeck . body = parent_body;
537538 // Merge the outlives constraints back in, at the given location.
538539 swap_constraints ( self ) ;
539540
@@ -549,7 +550,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
549550 // temporary from the user's point of view.
550551 constraint. category = ConstraintCategory :: Boring ;
551552 }
552- self . cx . constraints . outlives_constraints . push ( constraint)
553+ self . typeck . constraints . outlives_constraints . push ( constraint)
553554 }
554555 // If the region is live at least one location in the promoted MIR,
555556 // then add a liveness constraint to the main MIR for this region
@@ -559,7 +560,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
559560 // unordered.
560561 #[ allow( rustc:: potential_query_instability) ]
561562 for region in liveness_constraints. live_regions_unordered ( ) {
562- self . cx . constraints . liveness_constraints . add_location ( region, location) ;
563+ self . typeck . constraints . liveness_constraints . add_location ( region, location) ;
563564 }
564565 }
565566
@@ -643,13 +644,13 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
643644 } ,
644645 ProjectionElem :: Field ( field, fty) => {
645646 let fty = self . sanitize_type ( place, fty) ;
646- let fty = self . cx . normalize ( fty, location) ;
647+ let fty = self . typeck . normalize ( fty, location) ;
647648 match self . field_ty ( place, base, field, location) {
648649 Ok ( ty) => {
649- let ty = self . cx . normalize ( ty, location) ;
650+ let ty = self . typeck . normalize ( ty, location) ;
650651 debug ! ( ?fty, ?ty) ;
651652
652- if let Err ( terr) = self . cx . relate_types (
653+ if let Err ( terr) = self . typeck . relate_types (
653654 ty,
654655 self . get_ambient_variance ( context) ,
655656 fty,
@@ -681,8 +682,8 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
681682 }
682683 ProjectionElem :: OpaqueCast ( ty) => {
683684 let ty = self . sanitize_type ( place, ty) ;
684- let ty = self . cx . normalize ( ty, location) ;
685- self . cx
685+ let ty = self . typeck . normalize ( ty, location) ;
686+ self . typeck
686687 . relate_types (
687688 ty,
688689 self . get_ambient_variance ( context) ,
@@ -791,7 +792,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
791792 } ;
792793
793794 if let Some ( field) = variant. fields . get ( field) {
794- Ok ( self . cx . normalize ( field. ty ( tcx, args) , location) )
795+ Ok ( self . typeck . normalize ( field. ty ( tcx, args) , location) )
795796 } else {
796797 Err ( FieldAccessError :: OutOfRange { field_count : variant. fields . len ( ) } )
797798 }
0 commit comments