@@ -400,8 +400,12 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
400400 ( ty:: Placeholder ( p1) , ty:: Placeholder ( p2) ) if p1 == p2 => Ok ( a) ,
401401
402402 ( ty:: Adt ( a_def, a_args) , ty:: Adt ( b_def, b_args) ) if a_def == b_def => {
403- let args = relation. relate_item_args ( a_def. def_id ( ) , a_args, b_args) ?;
404- Ok ( Ty :: new_adt ( cx, a_def, args) )
403+ Ok ( if a_args. is_empty ( ) {
404+ a
405+ } else {
406+ let args = relation. relate_item_args ( a_def. def_id ( ) , a_args, b_args) ?;
407+ if args == a_args { a } else { Ty :: new_adt ( cx, a_def, args) }
408+ } )
405409 }
406410
407411 ( ty:: Foreign ( a_id) , ty:: Foreign ( b_id) ) if a_id == b_id => Ok ( Ty :: new_foreign ( cx, a_id) ) ,
@@ -515,8 +519,12 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
515519 }
516520
517521 ( ty:: FnDef ( a_def_id, a_args) , ty:: FnDef ( b_def_id, b_args) ) if a_def_id == b_def_id => {
518- let args = relation. relate_item_args ( a_def_id, a_args, b_args) ?;
519- Ok ( Ty :: new_fn_def ( cx, a_def_id, args) )
522+ Ok ( if a_args. is_empty ( ) {
523+ a
524+ } else {
525+ let args = relation. relate_item_args ( a_def_id, a_args, b_args) ?;
526+ if args == a_args { a } else { Ty :: new_fn_def ( cx, a_def_id, args) }
527+ } )
520528 }
521529
522530 ( ty:: FnPtr ( a_sig_tys, a_hdr) , ty:: FnPtr ( b_sig_tys, b_hdr) ) => {
0 commit comments