@@ -14,21 +14,27 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
14
14
fn tag ( & self ) -> & ' static str {
15
15
"CollectAllMismatches"
16
16
}
17
+
17
18
fn tcx ( & self ) -> TyCtxt < ' tcx > {
18
19
self . infcx . tcx
19
20
}
21
+
20
22
fn intercrate ( & self ) -> bool {
21
23
false
22
24
}
25
+
23
26
fn param_env ( & self ) -> ty:: ParamEnv < ' tcx > {
24
27
self . param_env
25
28
}
29
+
26
30
fn a_is_expected ( & self ) -> bool {
27
31
true
28
- } // irrelevant
32
+ }
33
+
29
34
fn mark_ambiguous ( & mut self ) {
30
35
bug ! ( )
31
36
}
37
+
32
38
fn relate_with_variance < T : Relate < ' tcx > > (
33
39
& mut self ,
34
40
_: ty:: Variance ,
@@ -38,22 +44,28 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
38
44
) -> RelateResult < ' tcx , T > {
39
45
self . relate ( a, b)
40
46
}
47
+
41
48
fn regions (
42
49
& mut self ,
43
50
a : ty:: Region < ' tcx > ,
44
51
_b : ty:: Region < ' tcx > ,
45
52
) -> RelateResult < ' tcx , ty:: Region < ' tcx > > {
46
53
Ok ( a)
47
54
}
55
+
48
56
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
+ }
55
66
} )
56
67
}
68
+
57
69
fn consts (
58
70
& mut self ,
59
71
a : ty:: Const < ' tcx > ,
@@ -64,6 +76,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for CollectAllMismatches<'a, 'tcx> {
64
76
}
65
77
relate:: super_relate_consts ( self , a, b) // could do something similar here for constants!
66
78
}
79
+
67
80
fn binders < T : Relate < ' tcx > > (
68
81
& mut self ,
69
82
a : ty:: Binder < ' tcx , T > ,
0 commit comments