@@ -6,6 +6,7 @@ use rustc::hir::pat_util::EnumerateAndAdjustIterator;
6
6
use rustc:: hir:: { self , HirId , Pat , PatKind } ;
7
7
use rustc:: infer;
8
8
use rustc:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
9
+ use rustc:: traits:: Pattern ;
9
10
use rustc:: ty:: subst:: GenericArg ;
10
11
use rustc:: ty:: { self , BindingMode , Ty , TypeFoldable } ;
11
12
use syntax:: ast;
@@ -29,6 +30,34 @@ pointers. If you encounter this error you should try to avoid dereferencing the
29
30
You can read more about trait objects in the Trait Objects section of the Reference: \
30
31
https://doc.rust-lang.org/reference/types.html#trait-objects";
31
32
33
+ impl < ' tcx > FnCtxt < ' _ , ' tcx > {
34
+ fn demand_eqtype_pat_diag (
35
+ & self ,
36
+ cause_span : Span ,
37
+ expected : Ty < ' tcx > ,
38
+ actual : Ty < ' tcx > ,
39
+ match_expr_span : Option < Span > ,
40
+ ) -> Option < DiagnosticBuilder < ' tcx > > {
41
+ let cause = if let Some ( span) = match_expr_span {
42
+ self . cause ( cause_span, Pattern { span, ty : expected } )
43
+ } else {
44
+ self . misc ( cause_span)
45
+ } ;
46
+ self . demand_eqtype_with_origin ( & cause, expected, actual)
47
+ }
48
+
49
+ fn demand_eqtype_pat (
50
+ & self ,
51
+ cause_span : Span ,
52
+ expected : Ty < ' tcx > ,
53
+ actual : Ty < ' tcx > ,
54
+ match_expr_span : Option < Span > ,
55
+ ) {
56
+ self . demand_eqtype_pat_diag ( cause_span, expected, actual, match_expr_span)
57
+ . map ( |mut err| err. emit ( ) ) ;
58
+ }
59
+ }
60
+
32
61
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
33
62
pub fn check_pat_top (
34
63
& self ,
0 commit comments