@@ -2330,9 +2330,9 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
2330
2330
#[ instrument( level = "debug" , skip( self ) , ret) ]
2331
2331
fn constituent_types_for_ty (
2332
2332
& self ,
2333
- t : ty :: Binder < ' tcx , Ty < ' tcx > > ,
2333
+ t : Ty < ' tcx > ,
2334
2334
) -> Result < ty:: Binder < ' tcx , Vec < Ty < ' tcx > > > , SelectionError < ' tcx > > {
2335
- Ok ( match * t. skip_binder ( ) . kind ( ) {
2335
+ Ok ( match * t. kind ( ) {
2336
2336
ty:: Uint ( _)
2337
2337
| ty:: Int ( _)
2338
2338
| ty:: Bool
@@ -2349,8 +2349,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
2349
2349
// `assemble_candidates_from_auto_impls`.
2350
2350
ty:: Foreign ( ..) => ty:: Binder :: dummy ( Vec :: new ( ) ) ,
2351
2351
2352
- // FIXME(unsafe_binders): Squash the double binder for now, I guess.
2353
- ty:: UnsafeBinder ( _) => return Err ( SelectionError :: Unimplemented ) ,
2352
+ ty:: UnsafeBinder ( ty) => ty. map_bound ( |ty| vec ! [ ty] ) ,
2354
2353
2355
2354
// Treat this like `struct str([u8]);`
2356
2355
ty:: Str => ty:: Binder :: dummy ( vec ! [ Ty :: new_slice( self . tcx( ) , self . tcx( ) . types. u8 ) ] ) ,
@@ -2364,40 +2363,47 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
2364
2363
bug ! ( "asked to assemble constituent types of unexpected type: {:?}" , t) ;
2365
2364
}
2366
2365
2367
- ty:: RawPtr ( element_ty, _) | ty:: Ref ( _, element_ty, _) => t. rebind ( vec ! [ element_ty] ) ,
2366
+ ty:: RawPtr ( element_ty, _) | ty:: Ref ( _, element_ty, _) => {
2367
+ ty:: Binder :: dummy ( vec ! [ element_ty] )
2368
+ }
2368
2369
2369
- ty:: Pat ( ty, _) | ty:: Array ( ty, _) | ty:: Slice ( ty) => t . rebind ( vec ! [ ty] ) ,
2370
+ ty:: Pat ( ty, _) | ty:: Array ( ty, _) | ty:: Slice ( ty) => ty :: Binder :: dummy ( vec ! [ ty] ) ,
2370
2371
2371
2372
ty:: Tuple ( tys) => {
2372
2373
// (T1, ..., Tn) -- meets any bound that all of T1...Tn meet
2373
- t . rebind ( tys. iter ( ) . collect ( ) )
2374
+ ty :: Binder :: dummy ( tys. iter ( ) . collect ( ) )
2374
2375
}
2375
2376
2376
2377
ty:: Closure ( _, args) => {
2377
2378
let ty = self . infcx . shallow_resolve ( args. as_closure ( ) . tupled_upvars_ty ( ) ) ;
2378
- t . rebind ( vec ! [ ty] )
2379
+ ty :: Binder :: dummy ( vec ! [ ty] )
2379
2380
}
2380
2381
2381
2382
ty:: CoroutineClosure ( _, args) => {
2382
2383
let ty = self . infcx . shallow_resolve ( args. as_coroutine_closure ( ) . tupled_upvars_ty ( ) ) ;
2383
- t . rebind ( vec ! [ ty] )
2384
+ ty :: Binder :: dummy ( vec ! [ ty] )
2384
2385
}
2385
2386
2386
2387
ty:: Coroutine ( _, args) => {
2387
2388
let ty = self . infcx . shallow_resolve ( args. as_coroutine ( ) . tupled_upvars_ty ( ) ) ;
2388
2389
let witness = args. as_coroutine ( ) . witness ( ) ;
2389
- t . rebind ( [ ty] . into_iter ( ) . chain ( iter:: once ( witness) ) . collect ( ) )
2390
+ ty :: Binder :: dummy ( [ ty] . into_iter ( ) . chain ( iter:: once ( witness) ) . collect ( ) )
2390
2391
}
2391
2392
2392
- ty:: CoroutineWitness ( def_id, args) => {
2393
- rebind_coroutine_witness_types ( self . infcx . tcx , def_id, args, t. bound_vars ( ) )
2394
- }
2393
+ ty:: CoroutineWitness ( def_id, args) => self
2394
+ . infcx
2395
+ . tcx
2396
+ . coroutine_hidden_types ( def_id)
2397
+ . instantiate ( self . infcx . tcx , args)
2398
+ . map_bound ( |witness| witness. types . to_vec ( ) ) ,
2395
2399
2396
2400
// For `PhantomData<T>`, we pass `T`.
2397
- ty:: Adt ( def, args) if def. is_phantom_data ( ) => t. rebind ( args. types ( ) . collect ( ) ) ,
2401
+ ty:: Adt ( def, args) if def. is_phantom_data ( ) => {
2402
+ ty:: Binder :: dummy ( args. types ( ) . collect ( ) )
2403
+ }
2398
2404
2399
2405
ty:: Adt ( def, args) => {
2400
- t . rebind ( def. all_fields ( ) . map ( |f| f. ty ( self . tcx ( ) , args) ) . collect ( ) )
2406
+ ty :: Binder :: dummy ( def. all_fields ( ) . map ( |f| f. ty ( self . tcx ( ) , args) ) . collect ( ) )
2401
2407
}
2402
2408
2403
2409
ty:: Alias ( ty:: Opaque , ty:: AliasTy { def_id, args, .. } ) => {
@@ -2408,7 +2414,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
2408
2414
// which enforces a DAG between the functions requiring
2409
2415
// the auto trait bounds in question.
2410
2416
match self . tcx ( ) . type_of_opaque ( def_id) {
2411
- Ok ( ty) => t . rebind ( vec ! [ ty. instantiate( self . tcx( ) , args) ] ) ,
2417
+ Ok ( ty) => ty :: Binder :: dummy ( vec ! [ ty. instantiate( self . tcx( ) , args) ] ) ,
2412
2418
Err ( _) => {
2413
2419
return Err ( SelectionError :: OpaqueTypeAutoTraitLeakageUnknown ( def_id) ) ;
2414
2420
}
0 commit comments