@@ -324,19 +324,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
324324 fn impl_provided_for (
325325 & self ,
326326 auto_trait_id : chalk_ir:: TraitId < RustInterner < ' tcx > > ,
327- app_ty : & chalk_ir:: ApplicationTy < RustInterner < ' tcx > > ,
327+ chalk_ty : & chalk_ir:: TyKind < RustInterner < ' tcx > > ,
328328 ) -> bool {
329329 use chalk_ir:: Scalar :: * ;
330- use chalk_ir:: TypeName :: * ;
330+ use chalk_ir:: TyKind :: * ;
331331
332332 let trait_def_id = auto_trait_id. 0 ;
333333 let all_impls = self . interner . tcx . all_impls ( trait_def_id) ;
334334 for impl_def_id in all_impls {
335335 let trait_ref = self . interner . tcx . impl_trait_ref ( impl_def_id) . unwrap ( ) ;
336336 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, .. ) ) => {
340340 // FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774
341341 false
342342 }
@@ -365,28 +365,30 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
365365 ( ast:: FloatTy :: F32 , chalk_ir:: FloatTy :: F32 )
366366 | ( ast:: FloatTy :: F64 , chalk_ir:: FloatTy :: F64 )
367367 ) ,
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, _ ) ) => {
372372 match ( type_and_mut. mutbl , mutability) {
373373 ( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Mut ) => true ,
374374 ( ast:: Mutability :: Mut , chalk_ir:: Mutability :: Not ) => false ,
375375 ( ast:: Mutability :: Not , chalk_ir:: Mutability :: Mut ) => false ,
376376 ( ast:: Mutability :: Not , chalk_ir:: Mutability :: Not ) => true ,
377377 }
378378 }
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 ,
387389 ( & ty:: Str , Str ) => true ,
388390 ( & 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 ,
390392 ( & ty:: Foreign ( def_id) , Foreign ( foreign_def_id) ) => def_id == foreign_def_id. 0 ,
391393 ( & ty:: Error ( ..) , Error ) => false ,
392394 _ => false ,
@@ -506,17 +508,11 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
506508 substs : & chalk_ir:: Substitution < RustInterner < ' tcx > > ,
507509 ) -> chalk_solve:: rust_ir:: ClosureKind {
508510 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 ,
520516 _ => bug ! ( "bad closure kind" ) ,
521517 } ,
522518 _ => bug ! ( "bad closure kind" ) ,
@@ -530,23 +526,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
530526 ) -> chalk_ir:: Binders < chalk_solve:: rust_ir:: FnDefInputsAndOutputDatum < RustInterner < ' tcx > > >
531527 {
532528 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) => {
535531 let substitution = f. substitution . as_slice ( & self . interner ) ;
536532 let return_type =
537533 substitution. last ( ) . unwrap ( ) . assert_ty_ref ( & self . interner ) . clone ( ) ;
538534 // Closure arguments are tupled
539535 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 ( ) ,
550542 _ => bug ! ( "Expecting closure FnSig args to be tupled." ) ,
551543 } ;
552544
@@ -637,7 +629,7 @@ fn binders_for<'tcx>(
637629 bound_vars. iter ( ) . map ( |arg| match arg. unpack ( ) {
638630 ty:: subst:: GenericArgKind :: Lifetime ( _re) => chalk_ir:: VariableKind :: Lifetime ,
639631 ty:: subst:: GenericArgKind :: Type ( _ty) => {
640- chalk_ir:: VariableKind :: Ty ( chalk_ir:: TyKind :: General )
632+ chalk_ir:: VariableKind :: Ty ( chalk_ir:: TyVariableKind :: General )
641633 }
642634 ty:: subst:: GenericArgKind :: Const ( c) => {
643635 chalk_ir:: VariableKind :: Const ( c. ty . lower_into ( interner) )
0 commit comments