File tree 2 files changed +27
-4
lines changed
2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -626,9 +626,9 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
626
626
let discrim_diverges = self . diverges . get ( ) ;
627
627
self . diverges . set ( Diverges :: Maybe ) ;
628
628
629
- // Typecheck the patterns first, so that we get types for all the
630
- // bindings.
631
- let all_arm_pats_diverge = arms. iter ( ) . map ( |arm| {
629
+ // rust-lang/rust#55810: Typecheck patterns first (via eager
630
+ // collection into `Vec`), so we get types for all bindings.
631
+ let all_arm_pats_diverge: Vec < _ > = arms. iter ( ) . map ( |arm| {
632
632
let mut all_pats_diverge = Diverges :: WarnedAlways ;
633
633
for p in & arm. pats {
634
634
self . diverges . set ( Diverges :: Maybe ) ;
@@ -644,7 +644,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
644
644
Diverges :: Maybe => Diverges :: Maybe ,
645
645
Diverges :: Always | Diverges :: WarnedAlways => Diverges :: WarnedAlways ,
646
646
}
647
- } ) ;
647
+ } ) . collect ( ) ;
648
648
649
649
// Now typecheck the blocks.
650
650
//
Original file line number Diff line number Diff line change
1
+ // compile-pass
2
+
3
+ // rust-lang/rust#55810: types for a binding in a match arm can be
4
+ // inferred from arms that come later in the match.
5
+
6
+ struct S ;
7
+
8
+ impl S {
9
+ fn method ( & self ) -> bool {
10
+ unimplemented ! ( )
11
+ }
12
+ }
13
+
14
+ fn get < T > ( ) -> T {
15
+ unimplemented ! ( )
16
+ }
17
+
18
+ fn main ( ) {
19
+ match get ( ) {
20
+ x if x. method ( ) => { }
21
+ & S => { }
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments