@@ -400,8 +400,12 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
400
400
( ty:: Placeholder ( p1) , ty:: Placeholder ( p2) ) if p1 == p2 => Ok ( a) ,
401
401
402
402
( 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
+ } )
405
409
}
406
410
407
411
( 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>>(
515
519
}
516
520
517
521
( 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
+ } )
520
528
}
521
529
522
530
( ty:: FnPtr ( a_sig_tys, a_hdr) , ty:: FnPtr ( b_sig_tys, b_hdr) ) => {
0 commit comments