@@ -172,34 +172,34 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
172172 }
173173}
174174
175- pub fn coerce_unsized_info < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
175+ pub fn coerce_unsized_info < ' a , ' gcx > ( gcx : TyCtxt < ' a , ' gcx , ' gcx > ,
176176 impl_did : DefId )
177177 -> CoerceUnsizedInfo {
178178 debug ! ( "compute_coerce_unsized_info(impl_did={:?})" , impl_did) ;
179- let coerce_unsized_trait = tcx . lang_items ( ) . coerce_unsized_trait ( ) . unwrap ( ) ;
179+ let coerce_unsized_trait = gcx . lang_items ( ) . coerce_unsized_trait ( ) . unwrap ( ) ;
180180
181- let unsize_trait = match tcx . lang_items ( ) . require ( UnsizeTraitLangItem ) {
181+ let unsize_trait = match gcx . lang_items ( ) . require ( UnsizeTraitLangItem ) {
182182 Ok ( id) => id,
183183 Err ( err) => {
184- tcx . sess . fatal ( & format ! ( "`CoerceUnsized` implementation {}" , err) ) ;
184+ gcx . sess . fatal ( & format ! ( "`CoerceUnsized` implementation {}" , err) ) ;
185185 }
186186 } ;
187187
188188 // this provider should only get invoked for local def-ids
189- let impl_node_id = tcx . hir . as_local_node_id ( impl_did) . unwrap_or_else ( || {
189+ let impl_node_id = gcx . hir . as_local_node_id ( impl_did) . unwrap_or_else ( || {
190190 bug ! ( "coerce_unsized_info: invoked for non-local def-id {:?}" , impl_did)
191191 } ) ;
192192
193- let source = tcx . type_of ( impl_did) ;
194- let trait_ref = tcx . impl_trait_ref ( impl_did) . unwrap ( ) ;
193+ let source = gcx . type_of ( impl_did) ;
194+ let trait_ref = gcx . impl_trait_ref ( impl_did) . unwrap ( ) ;
195195 assert_eq ! ( trait_ref. def_id, coerce_unsized_trait) ;
196196 let target = trait_ref. substs . type_at ( 1 ) ;
197197 debug ! ( "visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)" ,
198198 source,
199199 target) ;
200200
201- let span = tcx . hir . span ( impl_node_id) ;
202- let param_env = tcx . param_env ( impl_did) ;
201+ let span = gcx . hir . span ( impl_node_id) ;
202+ let param_env = gcx . param_env ( impl_did) ;
203203 assert ! ( !source. has_escaping_regions( ) ) ;
204204
205205 let err_info = CoerceUnsizedInfo { custom_kind : None } ;
@@ -208,11 +208,11 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
208208 source,
209209 target) ;
210210
211- tcx . infer_ctxt ( ) . enter ( |infcx| {
211+ gcx . infer_ctxt ( ) . enter ( |infcx| {
212212 let cause = ObligationCause :: misc ( span, impl_node_id) ;
213- let check_mutbl = |mt_a : ty:: TypeAndMut < ' tcx > ,
214- mt_b : ty:: TypeAndMut < ' tcx > ,
215- mk_ptr : & Fn ( Ty < ' tcx > ) -> Ty < ' tcx > | {
213+ let check_mutbl = |mt_a : ty:: TypeAndMut < ' gcx > ,
214+ mt_b : ty:: TypeAndMut < ' gcx > ,
215+ mk_ptr : & Fn ( Ty < ' gcx > ) -> Ty < ' gcx > | {
216216 if ( mt_a. mutbl , mt_b. mutbl ) == ( hir:: MutImmutable , hir:: MutMutable ) {
217217 infcx. report_mismatched_types ( & cause,
218218 mk_ptr ( mt_b. ty ) ,
@@ -225,20 +225,20 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
225225 let ( source, target, trait_def_id, kind) = match ( & source. sty , & target. sty ) {
226226 ( & ty:: TyRef ( r_a, mt_a) , & ty:: TyRef ( r_b, mt_b) ) => {
227227 infcx. sub_regions ( infer:: RelateObjectBound ( span) , r_b, r_a) ;
228- check_mutbl ( mt_a, mt_b, & |ty| tcx . mk_imm_ref ( r_b, ty) )
228+ check_mutbl ( mt_a, mt_b, & |ty| gcx . mk_imm_ref ( r_b, ty) )
229229 }
230230
231231 ( & ty:: TyRef ( _, mt_a) , & ty:: TyRawPtr ( mt_b) ) |
232232 ( & ty:: TyRawPtr ( mt_a) , & ty:: TyRawPtr ( mt_b) ) => {
233- check_mutbl ( mt_a, mt_b, & |ty| tcx . mk_imm_ptr ( ty) )
233+ check_mutbl ( mt_a, mt_b, & |ty| gcx . mk_imm_ptr ( ty) )
234234 }
235235
236236 ( & ty:: TyAdt ( def_a, substs_a) , & ty:: TyAdt ( def_b, substs_b) ) if def_a. is_struct ( ) &&
237237 def_b. is_struct ( ) => {
238238 if def_a != def_b {
239- let source_path = tcx . item_path_str ( def_a. did ) ;
240- let target_path = tcx . item_path_str ( def_b. did ) ;
241- span_err ! ( tcx . sess,
239+ let source_path = gcx . item_path_str ( def_a. did ) ;
240+ let target_path = gcx . item_path_str ( def_b. did ) ;
241+ span_err ! ( gcx . sess,
242242 span,
243243 E0377 ,
244244 "the trait `CoerceUnsized` may only be implemented \
@@ -292,9 +292,9 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
292292 let diff_fields = fields. iter ( )
293293 . enumerate ( )
294294 . filter_map ( |( i, f) | {
295- let ( a, b) = ( f. ty ( tcx , substs_a) , f. ty ( tcx , substs_b) ) ;
295+ let ( a, b) = ( f. ty ( gcx , substs_a) , f. ty ( gcx , substs_b) ) ;
296296
297- if tcx . type_of ( f. did ) . is_phantom_data ( ) {
297+ if gcx . type_of ( f. did ) . is_phantom_data ( ) {
298298 // Ignore PhantomData fields
299299 return None ;
300300 }
@@ -321,22 +321,22 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
321321 . collect :: < Vec < _ > > ( ) ;
322322
323323 if diff_fields. is_empty ( ) {
324- span_err ! ( tcx . sess,
324+ span_err ! ( gcx . sess,
325325 span,
326326 E0374 ,
327327 "the trait `CoerceUnsized` may only be implemented \
328328 for a coercion between structures with one field \
329329 being coerced, none found") ;
330330 return err_info;
331331 } else if diff_fields. len ( ) > 1 {
332- let item = tcx . hir . expect_item ( impl_node_id) ;
332+ let item = gcx . hir . expect_item ( impl_node_id) ;
333333 let span = if let ItemImpl ( .., Some ( ref t) , _, _) = item. node {
334334 t. path . span
335335 } else {
336- tcx . hir . span ( impl_node_id)
336+ gcx . hir . span ( impl_node_id)
337337 } ;
338338
339- let mut err = struct_span_err ! ( tcx . sess,
339+ let mut err = struct_span_err ! ( gcx . sess,
340340 span,
341341 E0375 ,
342342 "implementing the trait \
@@ -363,7 +363,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
363363 }
364364
365365 _ => {
366- span_err ! ( tcx . sess,
366+ span_err ! ( gcx . sess,
367367 span,
368368 E0376 ,
369369 "the trait `CoerceUnsized` may only be implemented \
@@ -376,7 +376,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
376376
377377 // Register an obligation for `A: Trait<B>`.
378378 let cause = traits:: ObligationCause :: misc ( span, impl_node_id) ;
379- let predicate = tcx . predicate_for_trait_def ( param_env,
379+ let predicate = gcx . predicate_for_trait_def ( param_env,
380380 cause,
381381 trait_def_id,
382382 0 ,
0 commit comments