@@ -76,17 +76,13 @@ pub trait TypeRelation<I: Interner>: Sized {
7676 /// Relate the two args for the given item. The default
7777 /// is to look up the variance for the item and proceed
7878 /// accordingly.
79- #[ instrument( skip( self ) , level = "trace" ) ]
8079 fn relate_item_args (
8180 & mut self ,
8281 item_def_id : I :: DefId ,
8382 a_arg : I :: GenericArgs ,
8483 b_arg : I :: GenericArgs ,
85- ) -> RelateResult < I , I :: GenericArgs > {
86- let cx = self . cx ( ) ;
87- let opt_variances = cx. variances_of ( item_def_id) ;
88- relate_args_with_variances ( self , item_def_id, opt_variances, a_arg, b_arg, true )
89- }
84+ f : impl FnOnce ( I :: GenericArgs ) -> I :: Ty ,
85+ ) -> RelateResult < I , I :: Ty > ;
9086
9187 /// Switch variance for the purpose of relating `a` and `b`.
9288 fn relate_with_variance < T : Relate < I > > (
@@ -402,12 +398,13 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
402398 ( ty:: Placeholder ( p1) , ty:: Placeholder ( p2) ) if p1 == p2 => Ok ( a) ,
403399
404400 ( ty:: Adt ( a_def, a_args) , ty:: Adt ( b_def, b_args) ) if a_def == b_def => {
405- Ok ( if a_args. is_empty ( ) {
406- a
401+ if a_args. is_empty ( ) {
402+ Ok ( a )
407403 } else {
408- let args = relation. relate_item_args ( a_def. def_id ( ) . into ( ) , a_args, b_args) ?;
409- if args == a_args { a } else { Ty :: new_adt ( cx, a_def, args) }
410- } )
404+ relation. relate_item_args ( a_def. def_id ( ) . into ( ) , a_args, b_args, |args| {
405+ if args == a_args { a } else { Ty :: new_adt ( cx, a_def, args) }
406+ } )
407+ }
411408 }
412409
413410 ( ty:: Foreign ( a_id) , ty:: Foreign ( b_id) ) if a_id == b_id => Ok ( Ty :: new_foreign ( cx, a_id) ) ,
@@ -516,12 +513,13 @@ pub fn structurally_relate_tys<I: Interner, R: TypeRelation<I>>(
516513 }
517514
518515 ( ty:: FnDef ( a_def_id, a_args) , ty:: FnDef ( b_def_id, b_args) ) if a_def_id == b_def_id => {
519- Ok ( if a_args. is_empty ( ) {
520- a
516+ if a_args. is_empty ( ) {
517+ Ok ( a )
521518 } else {
522- let args = relation. relate_item_args ( a_def_id. into ( ) , a_args, b_args) ?;
523- if args == a_args { a } else { Ty :: new_fn_def ( cx, a_def_id, args) }
524- } )
519+ relation. relate_item_args ( a_def_id. into ( ) , a_args, b_args, |args| {
520+ if args == a_args { a } else { Ty :: new_fn_def ( cx, a_def_id, args) }
521+ } )
522+ }
525523 }
526524
527525 ( ty:: FnPtr ( a_sig_tys, a_hdr) , ty:: FnPtr ( b_sig_tys, b_hdr) ) => {
0 commit comments