@@ -2670,8 +2670,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
26702670 /// Float types, respectively). When comparing two ADTs, these rules apply recursively.
26712671 pub fn same_type_modulo_infer ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> bool {
26722672 let ( a, b) = self . resolve_vars_if_possible ( ( a, b) ) ;
2673- match ( & a. kind ( ) , & b. kind ( ) ) {
2674- ( & ty:: Adt ( did_a, substs_a) , & ty:: Adt ( did_b, substs_b) ) => {
2673+ match ( a. kind ( ) , b. kind ( ) ) {
2674+ ( & ty:: Adt ( def_a, substs_a) , & ty:: Adt ( def_b, substs_b) ) => {
2675+ if def_a != def_b {
2676+ return false ;
2677+ }
2678+
2679+ substs_a
2680+ . types ( )
2681+ . zip ( substs_b. types ( ) )
2682+ . all ( |( a, b) | self . same_type_modulo_infer ( a, b) )
2683+ }
2684+ ( & ty:: FnDef ( did_a, substs_a) , & ty:: FnDef ( did_b, substs_b) ) => {
26752685 if did_a != did_b {
26762686 return false ;
26772687 }
@@ -2694,7 +2704,28 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
26942704 | ( & ty:: Infer ( ty:: InferTy :: TyVar ( _) ) , _)
26952705 | ( _, & ty:: Infer ( ty:: InferTy :: TyVar ( _) ) ) => true ,
26962706 ( & ty:: Ref ( _, ty_a, mut_a) , & ty:: Ref ( _, ty_b, mut_b) ) => {
2697- mut_a == mut_b && self . same_type_modulo_infer ( * ty_a, * ty_b)
2707+ mut_a == mut_b && self . same_type_modulo_infer ( ty_a, ty_b)
2708+ }
2709+ ( & ty:: RawPtr ( a) , & ty:: RawPtr ( b) ) => {
2710+ a. mutbl == b. mutbl && self . same_type_modulo_infer ( a. ty , b. ty )
2711+ }
2712+ ( & ty:: Slice ( a) , & ty:: Slice ( b) ) => self . same_type_modulo_infer ( a, b) ,
2713+ ( & ty:: Array ( a_ty, a_ct) , & ty:: Array ( b_ty, b_ct) ) => {
2714+ self . same_type_modulo_infer ( a_ty, b_ty) && a_ct == b_ct
2715+ }
2716+ ( & ty:: Tuple ( a) , & ty:: Tuple ( b) ) => {
2717+ if a. len ( ) != b. len ( ) {
2718+ return false ;
2719+ }
2720+ std:: iter:: zip ( a. iter ( ) , b. iter ( ) ) . all ( |( a, b) | self . same_type_modulo_infer ( a, b) )
2721+ }
2722+ ( & ty:: FnPtr ( a) , & ty:: FnPtr ( b) ) => {
2723+ let a = a. skip_binder ( ) . inputs_and_output ;
2724+ let b = b. skip_binder ( ) . inputs_and_output ;
2725+ if a. len ( ) != b. len ( ) {
2726+ return false ;
2727+ }
2728+ std:: iter:: zip ( a. iter ( ) , b. iter ( ) ) . all ( |( a, b) | self . same_type_modulo_infer ( a, b) )
26982729 }
26992730 // FIXME(compiler-errors): This needs to be generalized more
27002731 _ => a == b,
0 commit comments