@@ -322,29 +322,29 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: DefId) {
322
322
}
323
323
}
324
324
325
- pub fn coerce_unsized_info < ' tcx > ( gcx : TyCtxt < ' tcx > , impl_did : DefId ) -> CoerceUnsizedInfo {
325
+ pub fn coerce_unsized_info < ' tcx > ( tcx : TyCtxt < ' tcx > , impl_did : DefId ) -> CoerceUnsizedInfo {
326
326
debug ! ( "compute_coerce_unsized_info(impl_did={:?})" , impl_did) ;
327
- let coerce_unsized_trait = gcx . lang_items ( ) . coerce_unsized_trait ( ) . unwrap ( ) ;
327
+ let coerce_unsized_trait = tcx . lang_items ( ) . coerce_unsized_trait ( ) . unwrap ( ) ;
328
328
329
- let unsize_trait = gcx . lang_items ( ) . require ( UnsizeTraitLangItem ) . unwrap_or_else ( |err| {
330
- gcx . sess . fatal ( & format ! ( "`CoerceUnsized` implementation {}" , err) ) ;
329
+ let unsize_trait = tcx . lang_items ( ) . require ( UnsizeTraitLangItem ) . unwrap_or_else ( |err| {
330
+ tcx . sess . fatal ( & format ! ( "`CoerceUnsized` implementation {}" , err) ) ;
331
331
} ) ;
332
332
333
333
// this provider should only get invoked for local def-ids
334
- let impl_hir_id = gcx . hir ( ) . as_local_hir_id ( impl_did) . unwrap_or_else ( || {
334
+ let impl_hir_id = tcx . hir ( ) . as_local_hir_id ( impl_did) . unwrap_or_else ( || {
335
335
bug ! ( "coerce_unsized_info: invoked for non-local def-id {:?}" , impl_did)
336
336
} ) ;
337
337
338
- let source = gcx . type_of ( impl_did) ;
339
- let trait_ref = gcx . impl_trait_ref ( impl_did) . unwrap ( ) ;
338
+ let source = tcx . type_of ( impl_did) ;
339
+ let trait_ref = tcx . impl_trait_ref ( impl_did) . unwrap ( ) ;
340
340
assert_eq ! ( trait_ref. def_id, coerce_unsized_trait) ;
341
341
let target = trait_ref. substs . type_at ( 1 ) ;
342
342
debug ! ( "visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)" ,
343
343
source,
344
344
target) ;
345
345
346
- let span = gcx . hir ( ) . span ( impl_hir_id) ;
347
- let param_env = gcx . param_env ( impl_did) ;
346
+ let span = tcx . hir ( ) . span ( impl_hir_id) ;
347
+ let param_env = tcx . param_env ( impl_did) ;
348
348
assert ! ( !source. has_escaping_bound_vars( ) ) ;
349
349
350
350
let err_info = CoerceUnsizedInfo { custom_kind : None } ;
@@ -353,7 +353,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
353
353
source,
354
354
target) ;
355
355
356
- gcx . infer_ctxt ( ) . enter ( |infcx| {
356
+ tcx . infer_ctxt ( ) . enter ( |infcx| {
357
357
let cause = ObligationCause :: misc ( span, impl_hir_id) ;
358
358
let check_mutbl = |mt_a : ty:: TypeAndMut < ' tcx > ,
359
359
mt_b : ty:: TypeAndMut < ' tcx > ,
@@ -372,24 +372,24 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
372
372
infcx. sub_regions ( infer:: RelateObjectBound ( span) , r_b, r_a) ;
373
373
let mt_a = ty:: TypeAndMut { ty : ty_a, mutbl : mutbl_a } ;
374
374
let mt_b = ty:: TypeAndMut { ty : ty_b, mutbl : mutbl_b } ;
375
- check_mutbl ( mt_a, mt_b, & |ty| gcx . mk_imm_ref ( r_b, ty) )
375
+ check_mutbl ( mt_a, mt_b, & |ty| tcx . mk_imm_ref ( r_b, ty) )
376
376
}
377
377
378
378
( & ty:: Ref ( _, ty_a, mutbl_a) , & ty:: RawPtr ( mt_b) ) => {
379
379
let mt_a = ty:: TypeAndMut { ty : ty_a, mutbl : mutbl_a } ;
380
- check_mutbl ( mt_a, mt_b, & |ty| gcx . mk_imm_ptr ( ty) )
380
+ check_mutbl ( mt_a, mt_b, & |ty| tcx . mk_imm_ptr ( ty) )
381
381
}
382
382
383
383
( & ty:: RawPtr ( mt_a) , & ty:: RawPtr ( mt_b) ) => {
384
- check_mutbl ( mt_a, mt_b, & |ty| gcx . mk_imm_ptr ( ty) )
384
+ check_mutbl ( mt_a, mt_b, & |ty| tcx . mk_imm_ptr ( ty) )
385
385
}
386
386
387
387
( & ty:: Adt ( def_a, substs_a) , & ty:: Adt ( def_b, substs_b) ) if def_a. is_struct ( ) &&
388
388
def_b. is_struct ( ) => {
389
389
if def_a != def_b {
390
- let source_path = gcx . def_path_str ( def_a. did ) ;
391
- let target_path = gcx . def_path_str ( def_b. did ) ;
392
- span_err ! ( gcx . sess,
390
+ let source_path = tcx . def_path_str ( def_a. did ) ;
391
+ let target_path = tcx . def_path_str ( def_b. did ) ;
392
+ span_err ! ( tcx . sess,
393
393
span,
394
394
E0377 ,
395
395
"the trait `CoerceUnsized` may only be implemented \
@@ -443,9 +443,9 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
443
443
let diff_fields = fields. iter ( )
444
444
. enumerate ( )
445
445
. filter_map ( |( i, f) | {
446
- let ( a, b) = ( f. ty ( gcx , substs_a) , f. ty ( gcx , substs_b) ) ;
446
+ let ( a, b) = ( f. ty ( tcx , substs_a) , f. ty ( tcx , substs_b) ) ;
447
447
448
- if gcx . type_of ( f. did ) . is_phantom_data ( ) {
448
+ if tcx . type_of ( f. did ) . is_phantom_data ( ) {
449
449
// Ignore PhantomData fields
450
450
return None ;
451
451
}
@@ -472,22 +472,22 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
472
472
. collect :: < Vec < _ > > ( ) ;
473
473
474
474
if diff_fields. is_empty ( ) {
475
- span_err ! ( gcx . sess,
475
+ span_err ! ( tcx . sess,
476
476
span,
477
477
E0374 ,
478
478
"the trait `CoerceUnsized` may only be implemented \
479
479
for a coercion between structures with one field \
480
480
being coerced, none found") ;
481
481
return err_info;
482
482
} else if diff_fields. len ( ) > 1 {
483
- let item = gcx . hir ( ) . expect_item ( impl_hir_id) ;
483
+ let item = tcx . hir ( ) . expect_item ( impl_hir_id) ;
484
484
let span = if let ItemKind :: Impl ( .., Some ( ref t) , _, _) = item. node {
485
485
t. path . span
486
486
} else {
487
- gcx . hir ( ) . span ( impl_hir_id)
487
+ tcx . hir ( ) . span ( impl_hir_id)
488
488
} ;
489
489
490
- let mut err = struct_span_err ! ( gcx . sess,
490
+ let mut err = struct_span_err ! ( tcx . sess,
491
491
span,
492
492
E0375 ,
493
493
"implementing the trait \
@@ -514,7 +514,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
514
514
}
515
515
516
516
_ => {
517
- span_err ! ( gcx . sess,
517
+ span_err ! ( tcx . sess,
518
518
span,
519
519
E0376 ,
520
520
"the trait `CoerceUnsized` may only be implemented \
@@ -527,7 +527,7 @@ pub fn coerce_unsized_info<'tcx>(gcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
527
527
528
528
// Register an obligation for `A: Trait<B>`.
529
529
let cause = traits:: ObligationCause :: misc ( span, impl_hir_id) ;
530
- let predicate = gcx . predicate_for_trait_def ( param_env,
530
+ let predicate = tcx . predicate_for_trait_def ( param_env,
531
531
cause,
532
532
trait_def_id,
533
533
0 ,
0 commit comments