@@ -106,7 +106,6 @@ mod relate_tys;
106
106
/// # Parameters
107
107
///
108
108
/// - `infcx` -- inference context to use
109
- /// - `param_env` -- parameter environment to use for trait solving
110
109
/// - `body` -- MIR body to type-check
111
110
/// - `promoted` -- map of promoted constants within `body`
112
111
/// - `universal_regions` -- the universal regions from `body`s function signature
@@ -154,7 +153,7 @@ pub(crate) fn type_check<'a, 'tcx>(
154
153
155
154
debug ! ( ?normalized_inputs_and_output) ;
156
155
157
- let mut checker = TypeChecker {
156
+ let mut typeck = TypeChecker {
158
157
infcx,
159
158
last_span : body. span ,
160
159
body,
@@ -170,23 +169,22 @@ pub(crate) fn type_check<'a, 'tcx>(
170
169
constraints : & mut constraints,
171
170
} ;
172
171
173
- checker . check_user_type_annotations ( ) ;
172
+ typeck . check_user_type_annotations ( ) ;
174
173
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 } ;
176
175
verifier. visit_body ( body) ;
177
176
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) ;
181
180
182
- liveness:: generate ( & mut checker , body, & elements, flow_inits, move_data) ;
181
+ liveness:: generate ( & mut typeck , body, & elements, flow_inits, move_data) ;
183
182
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 ( )
187
185
. into_iter ( )
188
186
. map ( |( opaque_type_key, decl) | {
189
- let _: Result < _ , ErrorGuaranteed > = checker . fully_perform_op (
187
+ let _: Result < _ , ErrorGuaranteed > = typeck . fully_perform_op (
190
188
Locations :: All ( body. span ) ,
191
189
ConstraintCategory :: OpaqueType ,
192
190
CustomTypeOp :: new (
@@ -216,11 +214,11 @@ pub(crate) fn type_check<'a, 'tcx>(
216
214
match region. kind ( ) {
217
215
ty:: ReVar ( _) => region,
218
216
ty:: RePlaceholder ( placeholder) => {
219
- checker . constraints . placeholder_region ( infcx, placeholder)
217
+ typeck . constraints . placeholder_region ( infcx, placeholder)
220
218
}
221
219
_ => ty:: Region :: new_var (
222
220
infcx. tcx ,
223
- checker . universal_regions . to_region_vid ( region) ,
221
+ typeck . universal_regions . to_region_vid ( region) ,
224
222
) ,
225
223
}
226
224
} ) ;
@@ -250,7 +248,7 @@ enum FieldAccessError {
250
248
/// type, calling `span_mirbug` and returning an error type if there
251
249
/// is a problem.
252
250
struct TypeVerifier < ' a , ' b , ' tcx > {
253
- cx : & ' a mut TypeChecker < ' b , ' tcx > ,
251
+ typeck : & ' a mut TypeChecker < ' b , ' tcx > ,
254
252
promoted : & ' b IndexSlice < Promoted , Body < ' tcx > > ,
255
253
last_span : Span ,
256
254
}
@@ -272,9 +270,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
272
270
self . super_const_operand ( constant, location) ;
273
271
let ty = self . sanitize_type ( constant, constant. const_ . ty ( ) ) ;
274
272
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) ;
278
276
} ) ;
279
277
280
278
// 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> {
286
284
} ;
287
285
288
286
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 (
290
288
constant. const_ . ty ( ) ,
291
289
ty:: Invariant ,
292
290
& UserTypeProjection { base : annotation_index, projs : vec ! [ ] } ,
293
291
locations,
294
292
ConstraintCategory :: Boring ,
295
293
) {
296
- let annotation = & self . cx . user_type_annotations [ annotation_index] ;
294
+ let annotation = & self . typeck . user_type_annotations [ annotation_index] ;
297
295
span_mirbug ! (
298
296
self ,
299
297
constant,
@@ -322,9 +320,12 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
322
320
promoted : & Body < ' tcx > ,
323
321
ty,
324
322
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
+ ) {
328
329
span_mirbug ! (
329
330
verifier,
330
331
promoted,
@@ -342,21 +343,21 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
342
343
let promoted_ty = promoted_body. return_ty ( ) ;
343
344
check_err ( self , promoted_body, ty, promoted_ty) ;
344
345
} else {
345
- self . cx . ascribe_user_type (
346
+ self . typeck . ascribe_user_type (
346
347
constant. const_ . ty ( ) ,
347
348
ty:: UserType :: new ( ty:: UserTypeKind :: TypeOf ( uv. def , UserArgs {
348
349
args : uv. args ,
349
350
user_self_ty : None ,
350
351
} ) ) ,
351
- locations. span ( self . cx . body ) ,
352
+ locations. span ( self . typeck . body ) ,
352
353
) ;
353
354
}
354
355
} else if let Some ( static_def_id) = constant. check_static_ptr ( tcx) {
355
356
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) ;
357
358
let literal_ty = constant. const_ . ty ( ) . builtin_deref ( true ) . unwrap ( ) ;
358
359
359
- if let Err ( terr) = self . cx . eq_types (
360
+ if let Err ( terr) = self . typeck . eq_types (
360
361
literal_ty,
361
362
normalized_ty,
362
363
locations,
@@ -368,7 +369,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
368
369
369
370
if let ty:: FnDef ( def_id, args) = * constant. const_ . ty ( ) . kind ( ) {
370
371
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 (
372
373
def_id,
373
374
instantiated_predicates,
374
375
locations,
@@ -378,7 +379,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
378
379
tcx. impl_of_method( def_id) . map( |imp| tcx. def_kind( imp) ) ,
379
380
Some ( DefKind :: Impl { of_trait: true } )
380
381
) ) ;
381
- self . cx . prove_predicates (
382
+ self . typeck . prove_predicates (
382
383
args. types ( ) . map ( |ty| ty:: ClauseKind :: WellFormed ( ty. into ( ) ) ) ,
383
384
locations,
384
385
ConstraintCategory :: Boring ,
@@ -412,7 +413,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
412
413
local_decl. ty
413
414
} ;
414
415
415
- if let Err ( terr) = self . cx . relate_type_and_user_type (
416
+ if let Err ( terr) = self . typeck . relate_type_and_user_type (
416
417
ty,
417
418
ty:: Invariant ,
418
419
user_ty,
@@ -442,11 +443,11 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
442
443
443
444
impl < ' a , ' b , ' tcx > TypeVerifier < ' a , ' b , ' tcx > {
444
445
fn body ( & self ) -> & Body < ' tcx > {
445
- self . cx . body
446
+ self . typeck . body
446
447
}
447
448
448
449
fn tcx ( & self ) -> TyCtxt < ' tcx > {
449
- self . cx . infcx . tcx
450
+ self . typeck . infcx . tcx
450
451
}
451
452
452
453
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> {
496
497
// whether the bounds fully apply: in effect, the rule is
497
498
// that if a value of some type could implement `Copy`, then
498
499
// it must.
499
- self . cx . prove_trait_ref (
500
+ self . typeck . prove_trait_ref (
500
501
trait_ref,
501
502
location. to_locations ( ) ,
502
503
ConstraintCategory :: CopyBound ,
@@ -511,7 +512,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
511
512
// checker on the promoted MIR, then transfer the constraints back to
512
513
// the main MIR, changing the locations to the provided location.
513
514
514
- let parent_body = mem:: replace ( & mut self . cx . body , promoted_body) ;
515
+ let parent_body = mem:: replace ( & mut self . typeck . body , promoted_body) ;
515
516
516
517
// Use new sets of constraints and closure bounds so that we can
517
518
// modify their locations.
@@ -522,18 +523,18 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
522
523
// Don't try to add borrow_region facts for the promoted MIR
523
524
524
525
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) ;
528
529
} ;
529
530
530
531
swap_constraints ( self ) ;
531
532
532
533
self . visit_body ( promoted_body) ;
533
534
534
- self . cx . typeck_mir ( promoted_body) ;
535
+ self . typeck . typeck_mir ( promoted_body) ;
535
536
536
- self . cx . body = parent_body;
537
+ self . typeck . body = parent_body;
537
538
// Merge the outlives constraints back in, at the given location.
538
539
swap_constraints ( self ) ;
539
540
@@ -549,7 +550,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
549
550
// temporary from the user's point of view.
550
551
constraint. category = ConstraintCategory :: Boring ;
551
552
}
552
- self . cx . constraints . outlives_constraints . push ( constraint)
553
+ self . typeck . constraints . outlives_constraints . push ( constraint)
553
554
}
554
555
// If the region is live at least one location in the promoted MIR,
555
556
// then add a liveness constraint to the main MIR for this region
@@ -559,7 +560,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
559
560
// unordered.
560
561
#[ allow( rustc:: potential_query_instability) ]
561
562
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) ;
563
564
}
564
565
}
565
566
@@ -643,13 +644,13 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
643
644
} ,
644
645
ProjectionElem :: Field ( field, fty) => {
645
646
let fty = self . sanitize_type ( place, fty) ;
646
- let fty = self . cx . normalize ( fty, location) ;
647
+ let fty = self . typeck . normalize ( fty, location) ;
647
648
match self . field_ty ( place, base, field, location) {
648
649
Ok ( ty) => {
649
- let ty = self . cx . normalize ( ty, location) ;
650
+ let ty = self . typeck . normalize ( ty, location) ;
650
651
debug ! ( ?fty, ?ty) ;
651
652
652
- if let Err ( terr) = self . cx . relate_types (
653
+ if let Err ( terr) = self . typeck . relate_types (
653
654
ty,
654
655
self . get_ambient_variance ( context) ,
655
656
fty,
@@ -681,8 +682,8 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
681
682
}
682
683
ProjectionElem :: OpaqueCast ( ty) => {
683
684
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
686
687
. relate_types (
687
688
ty,
688
689
self . get_ambient_variance ( context) ,
@@ -791,7 +792,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
791
792
} ;
792
793
793
794
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) )
795
796
} else {
796
797
Err ( FieldAccessError :: OutOfRange { field_count : variant. fields . len ( ) } )
797
798
}
0 commit comments