@@ -19,6 +19,7 @@ use syntax_pos::{self, Span};
19
19
use rustc:: hir;
20
20
use rustc:: hir:: def:: Def ;
21
21
use rustc:: ty:: { self , AssociatedItem } ;
22
+ use errors:: DiagnosticBuilder ;
22
23
23
24
use super :: method:: probe;
24
25
@@ -38,20 +39,29 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
38
39
}
39
40
40
41
pub fn demand_eqtype ( & self , sp : Span , expected : Ty < ' tcx > , actual : Ty < ' tcx > ) {
41
- self . demand_eqtype_with_origin ( & self . misc ( sp) , expected, actual) ;
42
+ if let Some ( mut err) = self . demand_eqtype_diag ( sp, expected, actual) {
43
+ err. emit ( ) ;
44
+ }
45
+ }
46
+
47
+ pub fn demand_eqtype_diag ( & self ,
48
+ sp : Span ,
49
+ expected : Ty < ' tcx > ,
50
+ actual : Ty < ' tcx > ) -> Option < DiagnosticBuilder < ' tcx > > {
51
+ self . demand_eqtype_with_origin ( & self . misc ( sp) , expected, actual)
42
52
}
43
53
44
54
pub fn demand_eqtype_with_origin ( & self ,
45
55
cause : & ObligationCause < ' tcx > ,
46
56
expected : Ty < ' tcx > ,
47
- actual : Ty < ' tcx > )
48
- {
57
+ actual : Ty < ' tcx > ) -> Option < DiagnosticBuilder < ' tcx > > {
49
58
match self . eq_types ( false , cause, actual, expected) {
50
59
Ok ( InferOk { obligations, value : ( ) } ) => {
51
60
self . register_predicates ( obligations) ;
61
+ None
52
62
} ,
53
63
Err ( e) => {
54
- self . report_mismatched_types ( cause, expected, actual, e) . emit ( ) ;
64
+ Some ( self . report_mismatched_types ( cause, expected, actual, e) )
55
65
}
56
66
}
57
67
}
0 commit comments