@@ -172,34 +172,34 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
172
172
}
173
173
}
174
174
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 > ,
176
176
impl_did : DefId )
177
177
-> CoerceUnsizedInfo {
178
178
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 ( ) ;
180
180
181
- let unsize_trait = match tcx . lang_items ( ) . require ( UnsizeTraitLangItem ) {
181
+ let unsize_trait = match gcx . lang_items ( ) . require ( UnsizeTraitLangItem ) {
182
182
Ok ( id) => id,
183
183
Err ( err) => {
184
- tcx . sess . fatal ( & format ! ( "`CoerceUnsized` implementation {}" , err) ) ;
184
+ gcx . sess . fatal ( & format ! ( "`CoerceUnsized` implementation {}" , err) ) ;
185
185
}
186
186
} ;
187
187
188
188
// 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 ( || {
190
190
bug ! ( "coerce_unsized_info: invoked for non-local def-id {:?}" , impl_did)
191
191
} ) ;
192
192
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 ( ) ;
195
195
assert_eq ! ( trait_ref. def_id, coerce_unsized_trait) ;
196
196
let target = trait_ref. substs . type_at ( 1 ) ;
197
197
debug ! ( "visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)" ,
198
198
source,
199
199
target) ;
200
200
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) ;
203
203
assert ! ( !source. has_escaping_regions( ) ) ;
204
204
205
205
let err_info = CoerceUnsizedInfo { custom_kind : None } ;
@@ -208,11 +208,11 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
208
208
source,
209
209
target) ;
210
210
211
- tcx . infer_ctxt ( ) . enter ( |infcx| {
211
+ gcx . infer_ctxt ( ) . enter ( |infcx| {
212
212
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 > | {
216
216
if ( mt_a. mutbl , mt_b. mutbl ) == ( hir:: MutImmutable , hir:: MutMutable ) {
217
217
infcx. report_mismatched_types ( & cause,
218
218
mk_ptr ( mt_b. ty ) ,
@@ -225,20 +225,20 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
225
225
let ( source, target, trait_def_id, kind) = match ( & source. sty , & target. sty ) {
226
226
( & ty:: TyRef ( r_a, mt_a) , & ty:: TyRef ( r_b, mt_b) ) => {
227
227
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) )
229
229
}
230
230
231
231
( & ty:: TyRef ( _, mt_a) , & ty:: TyRawPtr ( mt_b) ) |
232
232
( & 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) )
234
234
}
235
235
236
236
( & ty:: TyAdt ( def_a, substs_a) , & ty:: TyAdt ( def_b, substs_b) ) if def_a. is_struct ( ) &&
237
237
def_b. is_struct ( ) => {
238
238
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,
242
242
span,
243
243
E0377 ,
244
244
"the trait `CoerceUnsized` may only be implemented \
@@ -292,9 +292,9 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
292
292
let diff_fields = fields. iter ( )
293
293
. enumerate ( )
294
294
. 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) ) ;
296
296
297
- if tcx . type_of ( f. did ) . is_phantom_data ( ) {
297
+ if gcx . type_of ( f. did ) . is_phantom_data ( ) {
298
298
// Ignore PhantomData fields
299
299
return None ;
300
300
}
@@ -321,22 +321,22 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
321
321
. collect :: < Vec < _ > > ( ) ;
322
322
323
323
if diff_fields. is_empty ( ) {
324
- span_err ! ( tcx . sess,
324
+ span_err ! ( gcx . sess,
325
325
span,
326
326
E0374 ,
327
327
"the trait `CoerceUnsized` may only be implemented \
328
328
for a coercion between structures with one field \
329
329
being coerced, none found") ;
330
330
return err_info;
331
331
} 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) ;
333
333
let span = if let ItemImpl ( .., Some ( ref t) , _, _) = item. node {
334
334
t. path . span
335
335
} else {
336
- tcx . hir . span ( impl_node_id)
336
+ gcx . hir . span ( impl_node_id)
337
337
} ;
338
338
339
- let mut err = struct_span_err ! ( tcx . sess,
339
+ let mut err = struct_span_err ! ( gcx . sess,
340
340
span,
341
341
E0375 ,
342
342
"implementing the trait \
@@ -363,7 +363,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
363
363
}
364
364
365
365
_ => {
366
- span_err ! ( tcx . sess,
366
+ span_err ! ( gcx . sess,
367
367
span,
368
368
E0376 ,
369
369
"the trait `CoerceUnsized` may only be implemented \
@@ -376,7 +376,7 @@ pub fn coerce_unsized_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
376
376
377
377
// Register an obligation for `A: Trait<B>`.
378
378
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,
380
380
cause,
381
381
trait_def_id,
382
382
0 ,
0 commit comments