File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 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");
626626 let discrim_diverges = self . diverges . get ( ) ;
627627 self . diverges . set ( Diverges :: Maybe ) ;
628628
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| {
632632 let mut all_pats_diverge = Diverges :: WarnedAlways ;
633633 for p in & arm. pats {
634634 self . diverges . set ( Diverges :: Maybe ) ;
@@ -644,7 +644,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
644644 Diverges :: Maybe => Diverges :: Maybe ,
645645 Diverges :: Always | Diverges :: WarnedAlways => Diverges :: WarnedAlways ,
646646 }
647- } ) ;
647+ } ) . collect ( ) ;
648648
649649 // Now typecheck the blocks.
650650 //
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