@@ -324,19 +324,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
324
324
fn impl_provided_for (
325
325
& self ,
326
326
auto_trait_id : chalk_ir:: TraitId < RustInterner < ' tcx > > ,
327
- app_ty : & chalk_ir:: ApplicationTy < RustInterner < ' tcx > > ,
327
+ chalk_ty : & chalk_ir:: TyKind < RustInterner < ' tcx > > ,
328
328
) -> bool {
329
329
use chalk_ir:: Scalar :: * ;
330
- use chalk_ir:: TypeName :: * ;
330
+ use chalk_ir:: TyKind :: * ;
331
331
332
332
let trait_def_id = auto_trait_id. 0 ;
333
333
let all_impls = self . interner . tcx . all_impls ( trait_def_id) ;
334
334
for impl_def_id in all_impls {
335
335
let trait_ref = self . interner . tcx . impl_trait_ref ( impl_def_id) . unwrap ( ) ;
336
336
let self_ty = trait_ref. self_ty ( ) ;
337
- let provides = match ( self_ty. kind ( ) , app_ty . name ) {
338
- ( & ty:: Adt ( impl_adt_def, ..) , Adt ( id) ) => impl_adt_def. did == id. 0 . did ,
339
- ( _, AssociatedType ( _ty_id) ) => {
337
+ let provides = match ( self_ty. kind ( ) , chalk_ty ) {
338
+ ( & ty:: Adt ( impl_adt_def, ..) , Adt ( id, .. ) ) => impl_adt_def. did == id. 0 . did ,
339
+ ( _, AssociatedType ( _ty_id, .. ) ) => {
340
340
// FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774
341
341
false
342
342
}
@@ -365,28 +365,30 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
365
365
( ast:: FloatTy :: F32 , chalk_ir:: FloatTy :: F32 )
366
366
| ( ast:: FloatTy :: F64 , chalk_ir:: FloatTy :: F64 )
367
367
) ,
368
- ( & ty:: Tuple ( .. ) , Tuple ( .. ) ) => true ,
369
- ( & ty:: Array ( ..) , Array ) => true ,
370
- ( & ty:: Slice ( ..) , Slice ) => true ,
371
- ( & ty:: RawPtr ( type_and_mut) , Raw ( mutability) ) => {
368
+ ( & ty:: Tuple ( substs ) , Tuple ( len , _ ) ) => substs . len ( ) == * len ,
369
+ ( & ty:: Array ( ..) , Array ( .. ) ) => true ,
370
+ ( & ty:: Slice ( ..) , Slice ( .. ) ) => true ,
371
+ ( & ty:: RawPtr ( type_and_mut) , Raw ( mutability, _ ) ) => {
372
372
match ( type_and_mut. mutbl , mutability) {
373
373
( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Mut ) => true ,
374
374
( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Not ) => false ,
375
375
( ast:: Mutability :: Not , chalk_ir:: Mutability :: Mut ) => false ,
376
376
( ast:: Mutability :: Not , chalk_ir:: Mutability :: Not ) => true ,
377
377
}
378
378
}
379
- ( & ty:: Ref ( .., mutability1) , Ref ( mutability2) ) => match ( mutability1, mutability2) {
380
- ( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Mut ) => true ,
381
- ( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Not ) => false ,
382
- ( ast:: Mutability :: Not , chalk_ir:: Mutability :: Mut ) => false ,
383
- ( ast:: Mutability :: Not , chalk_ir:: Mutability :: Not ) => true ,
384
- } ,
385
- ( & ty:: Opaque ( def_id, ..) , OpaqueType ( opaque_ty_id) ) => def_id == opaque_ty_id. 0 ,
386
- ( & ty:: FnDef ( def_id, ..) , FnDef ( fn_def_id) ) => def_id == fn_def_id. 0 ,
379
+ ( & ty:: Ref ( .., mutability1) , Ref ( mutability2, ..) ) => {
380
+ match ( mutability1, mutability2) {
381
+ ( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Mut ) => true ,
382
+ ( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Not ) => false ,
383
+ ( ast:: Mutability :: Not , chalk_ir:: Mutability :: Mut ) => false ,
384
+ ( ast:: Mutability :: Not , chalk_ir:: Mutability :: Not ) => true ,
385
+ }
386
+ }
387
+ ( & ty:: Opaque ( def_id, ..) , OpaqueType ( opaque_ty_id, ..) ) => def_id == opaque_ty_id. 0 ,
388
+ ( & ty:: FnDef ( def_id, ..) , FnDef ( fn_def_id, ..) ) => def_id == fn_def_id. 0 ,
387
389
( & ty:: Str , Str ) => true ,
388
390
( & ty:: Never , Never ) => true ,
389
- ( & ty:: Closure ( def_id, ..) , Closure ( closure_id) ) => def_id == closure_id. 0 ,
391
+ ( & ty:: Closure ( def_id, ..) , Closure ( closure_id, _ ) ) => def_id == closure_id. 0 ,
390
392
( & ty:: Foreign ( def_id) , Foreign ( foreign_def_id) ) => def_id == foreign_def_id. 0 ,
391
393
( & ty:: Error ( ..) , Error ) => false ,
392
394
_ => false ,
@@ -506,17 +508,11 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
506
508
substs : & chalk_ir:: Substitution < RustInterner < ' tcx > > ,
507
509
) -> chalk_solve:: rust_ir:: ClosureKind {
508
510
let kind = & substs. as_slice ( & self . interner ) [ substs. len ( & self . interner ) - 3 ] ;
509
- match kind. assert_ty_ref ( & self . interner ) . data ( & self . interner ) {
510
- chalk_ir:: TyData :: Apply ( apply) => match apply. name {
511
- chalk_ir:: TypeName :: Scalar ( scalar) => match scalar {
512
- chalk_ir:: Scalar :: Int ( int_ty) => match int_ty {
513
- chalk_ir:: IntTy :: I8 => chalk_solve:: rust_ir:: ClosureKind :: Fn ,
514
- chalk_ir:: IntTy :: I16 => chalk_solve:: rust_ir:: ClosureKind :: FnMut ,
515
- chalk_ir:: IntTy :: I32 => chalk_solve:: rust_ir:: ClosureKind :: FnOnce ,
516
- _ => bug ! ( "bad closure kind" ) ,
517
- } ,
518
- _ => bug ! ( "bad closure kind" ) ,
519
- } ,
511
+ match kind. assert_ty_ref ( & self . interner ) . kind ( & self . interner ) {
512
+ chalk_ir:: TyKind :: Scalar ( chalk_ir:: Scalar :: Int ( int_ty) ) => match int_ty {
513
+ chalk_ir:: IntTy :: I8 => chalk_solve:: rust_ir:: ClosureKind :: Fn ,
514
+ chalk_ir:: IntTy :: I16 => chalk_solve:: rust_ir:: ClosureKind :: FnMut ,
515
+ chalk_ir:: IntTy :: I32 => chalk_solve:: rust_ir:: ClosureKind :: FnOnce ,
520
516
_ => bug ! ( "bad closure kind" ) ,
521
517
} ,
522
518
_ => bug ! ( "bad closure kind" ) ,
@@ -530,23 +526,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
530
526
) -> chalk_ir:: Binders < chalk_solve:: rust_ir:: FnDefInputsAndOutputDatum < RustInterner < ' tcx > > >
531
527
{
532
528
let sig = & substs. as_slice ( & self . interner ) [ substs. len ( & self . interner ) - 2 ] ;
533
- match sig. assert_ty_ref ( & self . interner ) . data ( & self . interner ) {
534
- chalk_ir:: TyData :: Function ( f) => {
529
+ match sig. assert_ty_ref ( & self . interner ) . kind ( & self . interner ) {
530
+ chalk_ir:: TyKind :: Function ( f) => {
535
531
let substitution = f. substitution . as_slice ( & self . interner ) ;
536
532
let return_type =
537
533
substitution. last ( ) . unwrap ( ) . assert_ty_ref ( & self . interner ) . clone ( ) ;
538
534
// Closure arguments are tupled
539
535
let argument_tuple = substitution[ 0 ] . assert_ty_ref ( & self . interner ) ;
540
- let argument_types = match argument_tuple. data ( & self . interner ) {
541
- chalk_ir:: TyData :: Apply ( apply) => match apply. name {
542
- chalk_ir:: TypeName :: Tuple ( _) => apply
543
- . substitution
544
- . iter ( & self . interner )
545
- . map ( |arg| arg. assert_ty_ref ( & self . interner ) )
546
- . cloned ( )
547
- . collect ( ) ,
548
- _ => bug ! ( "Expecting closure FnSig args to be tupled." ) ,
549
- } ,
536
+ let argument_types = match argument_tuple. kind ( & self . interner ) {
537
+ chalk_ir:: TyKind :: Tuple ( _len, substitution) => substitution
538
+ . iter ( & self . interner )
539
+ . map ( |arg| arg. assert_ty_ref ( & self . interner ) )
540
+ . cloned ( )
541
+ . collect ( ) ,
550
542
_ => bug ! ( "Expecting closure FnSig args to be tupled." ) ,
551
543
} ;
552
544
@@ -637,7 +629,7 @@ fn binders_for<'tcx>(
637
629
bound_vars. iter ( ) . map ( |arg| match arg. unpack ( ) {
638
630
ty:: subst:: GenericArgKind :: Lifetime ( _re) => chalk_ir:: VariableKind :: Lifetime ,
639
631
ty:: subst:: GenericArgKind :: Type ( _ty) => {
640
- chalk_ir:: VariableKind :: Ty ( chalk_ir:: TyKind :: General )
632
+ chalk_ir:: VariableKind :: Ty ( chalk_ir:: TyVariableKind :: General )
641
633
}
642
634
ty:: subst:: GenericArgKind :: Const ( c) => {
643
635
chalk_ir:: VariableKind :: Const ( c. ty . lower_into ( interner) )
0 commit comments