@@ -6,6 +6,7 @@ use rustc::hir::pat_util::EnumerateAndAdjustIterator;
66use rustc:: hir:: { self , HirId , Pat , PatKind } ;
77use rustc:: infer;
88use rustc:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
9+ use rustc:: traits:: Pattern ;
910use rustc:: ty:: subst:: GenericArg ;
1011use rustc:: ty:: { self , BindingMode , Ty , TypeFoldable } ;
1112use syntax:: ast;
@@ -29,6 +30,34 @@ pointers. If you encounter this error you should try to avoid dereferencing the
2930You can read more about trait objects in the Trait Objects section of the Reference: \
3031 https://doc.rust-lang.org/reference/types.html#trait-objects";
3132
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+
3261impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
3362 pub fn check_pat_top (
3463 & self ,
0 commit comments