File tree 3 files changed +34
-5
lines changed
3 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -814,11 +814,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
814
814
report_unexpected_def ( def) ;
815
815
return self . tcx . types . err ;
816
816
}
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_late_bound_regions ( ) . expect ( "expected fn type" ) ;
820
-
821
- self . demand_eqtype ( pat. span , expected, pat_ty) ;
822
817
823
818
let variant = match def {
824
819
Def :: Err => {
@@ -836,6 +831,13 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
836
831
}
837
832
_ => bug ! ( "unexpected pattern definition: {:?}" , def)
838
833
} ;
834
+
835
+ // Replace constructor type with constructed type for tuple struct patterns.
836
+ let pat_ty = pat_ty. fn_sig ( tcx) . output ( ) ;
837
+ let pat_ty = pat_ty. no_late_bound_regions ( ) . expect ( "expected fn type" ) ;
838
+
839
+ self . demand_eqtype ( pat. span , expected, pat_ty) ;
840
+
839
841
// Type check subpatterns.
840
842
if subpats. len ( ) == variant. fields . len ( ) ||
841
843
subpats. len ( ) < variant. fields . len ( ) && ddpos. is_some ( ) {
Original file line number Diff line number Diff line change
1
+ use std:: path:: Path ;
2
+
3
+ fn main ( ) {
4
+ let path = Path :: new ( "foo" ) ;
5
+ match path {
6
+ Path :: new( "foo" ) => println ! ( "foo" ) ,
7
+ //~^ ERROR expected tuple struct/variant
8
+ Path :: new( "bar" ) => println ! ( "bar" ) ,
9
+ //~^ ERROR expected tuple struct/variant
10
+ _ => ( ) ,
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ error[E0164]: expected tuple struct/variant, found method `<Path>::new`
2
+ --> $DIR/match-fn-call.rs:6:9
3
+ |
4
+ LL | Path::new("foo") => println!("foo"),
5
+ | ^^^^^^^^^^^^^^^^ not a tuple variant or struct
6
+
7
+ error[E0164]: expected tuple struct/variant, found method `<Path>::new`
8
+ --> $DIR/match-fn-call.rs:8:9
9
+ |
10
+ LL | Path::new("bar") => println!("bar"),
11
+ | ^^^^^^^^^^^^^^^^ not a tuple variant or struct
12
+
13
+ error: aborting due to 2 previous errors
14
+
15
+ For more information about this error, try `rustc --explain E0164`.
You can’t perform that action at this time.
0 commit comments