@@ -14,21 +14,27 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
1414 fn tag ( & self ) -> & ' static str {
1515 "CollectAllMismatches"
1616 }
17+
1718 fn tcx ( & self ) -> TyCtxt < ' tcx > {
1819 self . infcx . tcx
1920 }
21+
2022 fn intercrate ( & self ) -> bool {
2123 false
2224 }
25+
2326 fn param_env ( & self ) -> ty:: ParamEnv < ' tcx > {
2427 self . param_env
2528 }
29+
2630 fn a_is_expected ( & self ) -> bool {
2731 true
28- } // irrelevant
32+ }
33+
2934 fn mark_ambiguous ( & mut self ) {
3035 bug ! ( )
3136 }
37+
3238 fn relate_with_variance < T : Relate < ' tcx > > (
3339 & mut self ,
3440 _: ty:: Variance ,
@@ -38,22 +44,28 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
3844 ) -> RelateResult < ' tcx , T > {
3945 self . relate ( a, b)
4046 }
47+
4148 fn regions (
4249 & mut self ,
4350 a : ty:: Region < ' tcx > ,
4451 _b : ty:: Region < ' tcx > ,
4552 ) -> RelateResult < ' tcx , ty:: Region < ' tcx > > {
4653 Ok ( a)
4754 }
55+
4856 fn tys ( & mut self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> RelateResult < ' tcx , Ty < ' tcx > > {
49- if a == b || matches ! ( a. kind( ) , ty:: Infer ( _) ) || matches ! ( b. kind( ) , ty:: Infer ( _) ) {
50- return Ok ( a) ;
51- }
52- relate:: super_relate_tys ( self , a, b) . or_else ( |e| {
53- self . errors . push ( e) ;
54- Ok ( a)
57+ self . infcx . probe ( |_| {
58+ if a. is_ty_infer ( ) || b. is_ty_infer ( ) {
59+ Ok ( a)
60+ } else {
61+ self . infcx . super_combine_tys ( self , a, b) . or_else ( |e| {
62+ self . errors . push ( e) ;
63+ Ok ( a)
64+ } )
65+ }
5566 } )
5667 }
68+
5769 fn consts (
5870 & mut self ,
5971 a : ty:: Const < ' tcx > ,
@@ -64,6 +76,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
6476 }
6577 relate:: super_relate_consts ( self , a, b) // could do something similar here for constants!
6678 }
79+
6780 fn binders < T : Relate < ' tcx > > (
6881 & mut self ,
6982 a : ty:: Binder < ' tcx , T > ,
0 commit comments