@@ -981,18 +981,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
981981 ) -> Ty < ' tcx > {
982982 let tcx = self . tcx ;
983983 let expected = self . shallow_resolve ( expected) ;
984- if self . check_dereferencable ( pat. span , expected, & inner) {
984+ let ( rptr_ty , inner_ty ) = if self . check_dereferencable ( pat. span , expected, & inner) {
985985 // `demand::subtype` would be good enough, but using `eqtype` turns
986986 // out to be equally general. See (note_1) for details.
987987
988988 // Take region, inner-type from expected type if we can,
989989 // to avoid creating needless variables. This also helps with
990990 // the bad interactions of the given hack detailed in (note_1).
991991 debug ! ( "check_pat_ref: expected={:?}" , expected) ;
992- let ( rptr_ty, inner_ty) = match expected. sty {
993- ty:: Ref ( _, r_ty, r_mutbl) if r_mutbl == mutbl => {
994- ( expected, r_ty)
995- }
992+ match expected. sty {
993+ ty:: Ref ( _, r_ty, r_mutbl) if r_mutbl == mutbl => ( expected, r_ty) ,
996994 _ => {
997995 let inner_ty = self . next_ty_var (
998996 TypeVariableOrigin {
@@ -1012,14 +1010,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10121010 }
10131011 ( rptr_ty, inner_ty)
10141012 }
1015- } ;
1016-
1017- self . check_pat ( & inner, inner_ty, def_bm, discrim_span) ;
1018- rptr_ty
1013+ }
10191014 } else {
1020- self . check_pat ( & inner, tcx. types . err , def_bm, discrim_span) ;
1021- tcx. types . err
1022- }
1015+ ( tcx. types . err , tcx. types . err )
1016+ } ;
1017+ self . check_pat ( & inner, inner_ty, def_bm, discrim_span) ;
1018+ rptr_ty
10231019 }
10241020
10251021 /// Create a reference type with a fresh region variable.
0 commit comments