@@ -802,6 +802,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
802
802
803
803
// Resolve the path and check the definition for errors.
804
804
let ( def, opt_ty, segments) = self . resolve_ty_and_def_ufcs ( qpath, pat. id , pat. span ) ;
805
+
805
806
if def == Def :: Err {
806
807
self . set_tainted_by_errors ( ) ;
807
808
on_error ( ) ;
@@ -814,11 +815,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
814
815
report_unexpected_def ( def) ;
815
816
return self . tcx . types . err ;
816
817
}
817
- // Replace constructor type with constructed type for tuple struct patterns.
818
- let pat_ty = pat_ty. fn_sig ( tcx) . output ( ) ;
819
- let pat_ty = pat_ty. no_bound_vars ( ) . expect ( "expected fn type" ) ;
820
-
821
- self . demand_eqtype ( pat. span , expected, pat_ty) ;
822
818
823
819
let variant = match def {
824
820
Def :: Err => {
@@ -836,6 +832,13 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
836
832
}
837
833
_ => bug ! ( "unexpected pattern definition: {:?}" , def)
838
834
} ;
835
+
836
+ // Replace constructor type with constructed type for tuple struct patterns.
837
+ let pat_ty = pat_ty. fn_sig ( tcx) . output ( ) ;
838
+ let pat_ty = pat_ty. no_bound_vars ( ) . expect ( "expected fn type" ) ;
839
+
840
+ self . demand_eqtype ( pat. span , expected, pat_ty) ;
841
+
839
842
// Type check subpatterns.
840
843
if subpats. len ( ) == variant. fields . len ( ) ||
841
844
subpats. len ( ) < variant. fields . len ( ) && ddpos. is_some ( ) {
0 commit comments