@@ -981,18 +981,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
981
981
) -> Ty < ' tcx > {
982
982
let tcx = self . tcx ;
983
983
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) {
985
985
// `demand::subtype` would be good enough, but using `eqtype` turns
986
986
// out to be equally general. See (note_1) for details.
987
987
988
988
// Take region, inner-type from expected type if we can,
989
989
// to avoid creating needless variables. This also helps with
990
990
// the bad interactions of the given hack detailed in (note_1).
991
991
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) ,
996
994
_ => {
997
995
let inner_ty = self . next_ty_var (
998
996
TypeVariableOrigin {
@@ -1012,14 +1010,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1012
1010
}
1013
1011
( rptr_ty, inner_ty)
1014
1012
}
1015
- } ;
1016
-
1017
- self . check_pat ( & inner, inner_ty, def_bm, discrim_span) ;
1018
- rptr_ty
1013
+ }
1019
1014
} 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
1023
1019
}
1024
1020
1025
1021
/// Create a reference type with a fresh region variable.
0 commit comments